From 7c766337b6aea8a65eddd8e950aa15618a8faa80 Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Sat, 4 Feb 2017 12:43:50 -0500 Subject: [PATCH] Remove all references to NA --- plexapi/audio.py | 82 +++++++++++++------------- plexapi/photo.py | 53 +++++++++-------- plexapi/playlist.py | 29 +++++----- plexapi/server.py | 8 +-- plexapi/utils.py | 38 +++---------- plexapi/video.py | 136 ++++++++++++++++++++++---------------------- 6 files changed, 159 insertions(+), 187 deletions(-) diff --git a/plexapi/audio.py b/plexapi/audio.py index 7eff8470..79924884 100644 --- a/plexapi/audio.py +++ b/plexapi/audio.py @@ -2,8 +2,6 @@ from plexapi import media, utils from plexapi.utils import Playable, PlexPartialObject -NA = utils.NA - class Audio(PlexPartialObject): """ Base class for audio :class:`~plexapi.audio.Artist`, :class:`~plexapi.audio.Album` @@ -38,18 +36,18 @@ class Audio(PlexPartialObject): def _loadData(self, data): """ Load attribute values from Plex XML response. """ self.listType = 'audio' - self.addedAt = utils.toDatetime(data.attrib.get('addedAt', NA)) - self.index = data.attrib.get('index', NA) - self.key = data.attrib.get('key', NA) - self.lastViewedAt = utils.toDatetime(data.attrib.get('lastViewedAt', NA)) - self.librarySectionID = data.attrib.get('librarySectionID', NA) - self.ratingKey = utils.cast(int, data.attrib.get('ratingKey', NA)) - self.summary = data.attrib.get('summary', NA) - self.thumb = data.attrib.get('thumb', NA) - self.title = data.attrib.get('title', NA) + self.addedAt = utils.toDatetime(data.attrib.get('addedAt')) + self.index = data.attrib.get('index') + self.key = data.attrib.get('key') + self.lastViewedAt = utils.toDatetime(data.attrib.get('lastViewedAt')) + self.librarySectionID = data.attrib.get('librarySectionID') + self.ratingKey = utils.cast(int, data.attrib.get('ratingKey')) + self.summary = data.attrib.get('summary') + self.thumb = data.attrib.get('thumb') + self.title = data.attrib.get('title') self.titleSort = data.attrib.get('titleSort', self.title) - self.type = data.attrib.get('type', NA) - self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt', NA)) + self.type = data.attrib.get('type') + self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) self.viewCount = utils.cast(int, data.attrib.get('viewCount', 0)) @property @@ -90,8 +88,8 @@ class Artist(Audio): def _loadData(self, data): """ Load attribute values from Plex XML response. """ Audio._loadData(self, data) - self.art = data.attrib.get('art', NA) - self.guid = data.attrib.get('guid', NA) + self.art = data.attrib.get('art') + self.guid = data.attrib.get('guid') self.key = self.key.replace('/children', '') # FIX_BUG_50 self.location = utils.findLocations(data, single=True) if self.isFullObject(): # check if this is needed @@ -179,15 +177,15 @@ class Album(Audio): def _loadData(self, data): """ Load attribute values from Plex XML response. """ Audio._loadData(self, data) - self.art = data.attrib.get('art', NA) + self.art = data.attrib.get('art') self.key = self.key.replace('/children', '') # fixes bug #50 - self.originallyAvailableAt = utils.toDatetime(data.attrib.get('originallyAvailableAt', NA), '%Y-%m-%d') - self.parentKey = data.attrib.get('parentKey', NA) - self.parentRatingKey = data.attrib.get('parentRatingKey', NA) - self.parentThumb = data.attrib.get('parentThumb', NA) - self.parentTitle = data.attrib.get('parentTitle', NA) - self.studio = data.attrib.get('studio', NA) - self.year = utils.cast(int, data.attrib.get('year', NA)) + self.originallyAvailableAt = utils.toDatetime(data.attrib.get('originallyAvailableAt'), '%Y-%m-%d') + self.parentKey = data.attrib.get('parentKey') + self.parentRatingKey = data.attrib.get('parentRatingKey') + self.parentThumb = data.attrib.get('parentThumb') + self.parentTitle = data.attrib.get('parentTitle') + self.studio = data.attrib.get('studio') + self.year = utils.cast(int, data.attrib.get('year')) if self.isFullObject(): self.genres = [media.Genre(self.server, e) for e in data if e.tag == media.Genre.TYPE] @@ -278,25 +276,25 @@ class Track(Audio, Playable): """ Load attribute values from Plex XML response. """ Audio._loadData(self, data) Playable._loadData(self, data) - self.art = data.attrib.get('art', NA) - self.chapterSource = data.attrib.get('chapterSource', NA) - self.duration = utils.cast(int, data.attrib.get('duration', NA)) - self.grandparentArt = data.attrib.get('grandparentArt', NA) - self.grandparentKey = data.attrib.get('grandparentKey', NA) - self.grandparentRatingKey = data.attrib.get('grandparentRatingKey', NA) - self.grandparentThumb = data.attrib.get('grandparentThumb', NA) - self.grandparentTitle = data.attrib.get('grandparentTitle', NA) - self.guid = data.attrib.get('guid', NA) - self.originalTitle = data.attrib.get('originalTitle', NA) - self.parentIndex = data.attrib.get('parentIndex', NA) - self.parentKey = data.attrib.get('parentKey', NA) - self.parentRatingKey = data.attrib.get('parentRatingKey', NA) - self.parentThumb = data.attrib.get('parentThumb', NA) - self.parentTitle = data.attrib.get('parentTitle', NA) - self.primaryExtraKey = data.attrib.get('primaryExtraKey', NA) - self.ratingCount = utils.cast(int, data.attrib.get('ratingCount', NA)) + self.art = data.attrib.get('art') + self.chapterSource = data.attrib.get('chapterSource') + self.duration = utils.cast(int, data.attrib.get('duration')) + self.grandparentArt = data.attrib.get('grandparentArt') + self.grandparentKey = data.attrib.get('grandparentKey') + self.grandparentRatingKey = data.attrib.get('grandparentRatingKey') + self.grandparentThumb = data.attrib.get('grandparentThumb') + self.grandparentTitle = data.attrib.get('grandparentTitle') + self.guid = data.attrib.get('guid') + self.originalTitle = data.attrib.get('originalTitle') + self.parentIndex = data.attrib.get('parentIndex') + self.parentKey = data.attrib.get('parentKey') + self.parentRatingKey = data.attrib.get('parentRatingKey') + self.parentThumb = data.attrib.get('parentThumb') + self.parentTitle = data.attrib.get('parentTitle') + self.primaryExtraKey = data.attrib.get('primaryExtraKey') + self.ratingCount = utils.cast(int, data.attrib.get('ratingCount')) self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0)) - self.year = utils.cast(int, data.attrib.get('year', NA)) + self.year = utils.cast(int, data.attrib.get('year')) # media is included in /children self.media = [media.Media(self.server, e, self.initpath, self) for e in data if e.tag == media.Media.TYPE] @@ -305,7 +303,7 @@ class Track(Audio, Playable): #self.media = [media.Media(self.server, e, self.initpath, self) # for e in data if e.tag == media.Media.TYPE] # data for active sessions and history - self.sessionKey = utils.cast(int, data.attrib.get('sessionKey', NA)) + self.sessionKey = utils.cast(int, data.attrib.get('sessionKey')) self.username = utils.findUsername(data) self.player = utils.findPlayer(self.server, data) self.transcodeSession = utils.findTranscodeSession(self.server, data) diff --git a/plexapi/photo.py b/plexapi/photo.py index 16f71b04..07e1f04c 100644 --- a/plexapi/photo.py +++ b/plexapi/photo.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from plexapi import media, utils from plexapi.utils import PlexPartialObject -NA = utils.NA @utils.register_libtype @@ -37,19 +36,19 @@ class Photoalbum(PlexPartialObject): def _loadData(self, data): """ Load attribute values from Plex XML response. """ self.listType = 'photo' - self.addedAt = utils.toDatetime(data.attrib.get('addedAt', NA)) - self.art = data.attrib.get('art', NA) - self.composite = data.attrib.get('composite', NA) - self.guid = data.attrib.get('guid', NA) - self.index = utils.cast(int, data.attrib.get('index', NA)) - self.key = data.attrib.get('key', NA) - self.librarySectionID = data.attrib.get('librarySectionID', NA) - self.ratingKey = data.attrib.get('ratingKey', NA) - self.summary = data.attrib.get('summary', NA) - self.thumb = data.attrib.get('thumb', NA) - self.title = data.attrib.get('title', NA) - self.type = data.attrib.get('type', NA) - self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt', NA)) + self.addedAt = utils.toDatetime(data.attrib.get('addedAt')) + self.art = data.attrib.get('art') + self.composite = data.attrib.get('composite') + self.guid = data.attrib.get('guid') + self.index = utils.cast(int, data.attrib.get('index')) + self.key = data.attrib.get('key') + self.librarySectionID = data.attrib.get('librarySectionID') + self.ratingKey = data.attrib.get('ratingKey') + self.summary = data.attrib.get('summary') + self.thumb = data.attrib.get('thumb') + self.title = data.attrib.get('title') + self.type = data.attrib.get('type') + self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) def photos(self): """ Returns a list of :class:`~plexapi.photo.Photo` objects in this album. """ @@ -100,20 +99,20 @@ class Photo(PlexPartialObject): def _loadData(self, data): """ Load attribute values from Plex XML response. """ self.listType = 'photo' - self.addedAt = utils.toDatetime(data.attrib.get('addedAt', NA)) - self.index = utils.cast(int, data.attrib.get('index', NA)) - self.key = data.attrib.get('key', NA) + self.addedAt = utils.toDatetime(data.attrib.get('addedAt')) + self.index = utils.cast(int, data.attrib.get('index')) + self.key = data.attrib.get('key') self.originallyAvailableAt = utils.toDatetime( - data.attrib.get('originallyAvailableAt', NA), '%Y-%m-%d') - self.parentKey = data.attrib.get('parentKey', NA) - self.parentRatingKey = data.attrib.get('parentRatingKey', NA) - self.ratingKey = data.attrib.get('ratingKey', NA) - self.summary = data.attrib.get('summary', NA) - self.thumb = data.attrib.get('thumb', NA) - self.title = data.attrib.get('title', NA) - self.type = data.attrib.get('type', NA) - self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt', NA)) - self.year = utils.cast(int, data.attrib.get('year', NA)) + data.attrib.get('originallyAvailableAt'), '%Y-%m-%d') + self.parentKey = data.attrib.get('parentKey') + self.parentRatingKey = data.attrib.get('parentRatingKey') + self.ratingKey = data.attrib.get('ratingKey') + self.summary = data.attrib.get('summary') + self.thumb = data.attrib.get('thumb') + self.title = data.attrib.get('title') + self.type = data.attrib.get('type') + self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) + self.year = utils.cast(int, data.attrib.get('year')) if self.isFullObject(): self.media = [media.Media(self.server, e, self.initpath, self) for e in data if e.tag == media.Media.TYPE] diff --git a/plexapi/playlist.py b/plexapi/playlist.py index 7fd50037..8f196e26 100644 --- a/plexapi/playlist.py +++ b/plexapi/playlist.py @@ -3,7 +3,6 @@ from plexapi import utils from plexapi.exceptions import BadRequest from plexapi.utils import cast, toDatetime from plexapi.utils import PlexPartialObject, Playable -NA = utils.NA @utils.register_libtype @@ -28,21 +27,21 @@ class Playlist(PlexPartialObject, Playable): data (Element): Usually built from server.query """ Playable._loadData(self, data) - self.addedAt = toDatetime(data.attrib.get('addedAt', NA)) - self.composite = data.attrib.get('composite', NA) # url to thumbnail - self.duration = cast(int, data.attrib.get('duration', NA)) - self.durationInSeconds = cast(int, data.attrib.get('durationInSeconds', NA)) - self.guid = data.attrib.get('guid', NA) - self.key = data.attrib.get('key', NA) + self.addedAt = toDatetime(data.attrib.get('addedAt')) + self.composite = data.attrib.get('composite') # url to thumbnail + self.duration = cast(int, data.attrib.get('duration')) + self.durationInSeconds = cast(int, data.attrib.get('durationInSeconds')) + self.guid = data.attrib.get('guid') + self.key = data.attrib.get('key') self.key = self.key.replace('/items', '') if self.key else self.key # FIX_BUG_50 - self.leafCount = cast(int, data.attrib.get('leafCount', NA)) - self.playlistType = data.attrib.get('playlistType', NA) - self.ratingKey = cast(int, data.attrib.get('ratingKey', NA)) - self.smart = cast(bool, data.attrib.get('smart', NA)) - self.summary = data.attrib.get('summary', NA) - self.title = data.attrib.get('title', NA) - self.type = data.attrib.get('type', NA) - self.updatedAt = toDatetime(data.attrib.get('updatedAt', NA)) + self.leafCount = cast(int, data.attrib.get('leafCount')) + self.playlistType = data.attrib.get('playlistType') + self.ratingKey = cast(int, data.attrib.get('ratingKey')) + self.smart = cast(bool, data.attrib.get('smart')) + self.summary = data.attrib.get('summary') + self.title = data.attrib.get('title') + self.type = data.attrib.get('type') + self.updatedAt = toDatetime(data.attrib.get('updatedAt')) def items(self): """Return all items in the playlist.""" diff --git a/plexapi/server.py b/plexapi/server.py index 2c6ead20..e2aae5c5 100644 --- a/plexapi/server.py +++ b/plexapi/server.py @@ -9,7 +9,7 @@ from plexapi.exceptions import BadRequest, NotFound from plexapi.library import Library from plexapi.playlist import Playlist from plexapi.playqueue import PlayQueue -from plexapi.utils import NA, cast +from plexapi.utils import cast # import media to populate utils.LIBRARY_TYPES. from plexapi import audio, video, photo, playlist as _pl @@ -132,7 +132,7 @@ class PlexServer(object): self.transcoderVideoBitrates = utils.toList(data.attrib.get('transcoderVideoBitrates')) self.transcoderVideoQualities = utils.toList(data.attrib.get('transcoderVideoQualities')) self.transcoderVideoResolutions = utils.toList(data.attrib.get('transcoderVideoResolutions')) - self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt', NA)) + self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) self.updater = cast(bool, data.attrib.get('updater')) self.version = data.attrib.get('version') self.voiceSearch = cast(bool, data.attrib.get('voiceSearch')) @@ -307,8 +307,8 @@ class PlexServer(object): def transcodeImage(self, media, height, width, opacity=100, saturation=100): """ Returns the URL for a transcoded image from the specified media object. - Returns None if no media specified (needed to prevent transcoding NA, or - user tries to pass thumb, or art directly). + Returns None if no media specified (needed if user tries to pass thumb + or art directly). Parameters: height (int): Height to transcode the image to. diff --git a/plexapi/utils.py b/plexapi/utils.py index 1381e9cb..a3552717 100644 --- a/plexapi/utils.py +++ b/plexapi/utils.py @@ -20,28 +20,6 @@ def register_libtype(cls): return cls -class _NA(object): - """ This used to be a simple variable equal to '__NA__'. There has been need to - compare NA against None in some use cases. This object allows the internals - of PlexAPI to distinguish between unfetched values and fetched, but non-existent - values. (NA == None results to True; NA is None results to False) - """ - - def __bool__(self): - return False - - def __eq__(self, other): - return isinstance(other, _NA) or other in [None, '__NA__'] - - def __nonzero__(self): - return False - - def __repr__(self): - return '__NA__' - -NA = _NA() # Keep this for now. - - class SecretsFilter(logging.Filter): """ Logging filter to hide secrets. """ def __init__(self, secrets=None): @@ -89,13 +67,13 @@ class PlexPartialObject(object): def __getattr__(self, attr): # Auto reload self, from the full key (path) when needed. if attr == 'key' or self.__dict__.get(attr) or self.isFullObject(): - return self.__dict__.get(attr, NA) + return self.__dict__.get(attr) print('reload because of %s' % attr) self.reload() - return self.__dict__.get(attr, NA) + return self.__dict__.get(attr) def __setattr__(self, attr, value): - if value != NA or self.isFullObject(): + if value is not None or self.isFullObject(): self.__dict__[attr] = value def _loadData(self, data): @@ -139,14 +117,14 @@ class Playable(object): def _loadData(self, data): # Load data for active sessions (/status/sessions) - self.sessionKey = cast(int, data.attrib.get('sessionKey', NA)) + self.sessionKey = cast(int, data.attrib.get('sessionKey')) self.username = findUsername(data) self.player = findPlayer(self.server, data) self.transcodeSession = findTranscodeSession(self.server, data) # Load data for history details (/status/sessions/history/all) - self.viewedAt = toDatetime(data.attrib.get('viewedAt', NA)) + self.viewedAt = toDatetime(data.attrib.get('viewedAt')) # Load data for playlist items - self.playlistItemID = cast(int, data.attrib.get('playlistItemID', NA)) + self.playlistItemID = cast(int, data.attrib.get('playlistItemID')) def getStreamURL(self, **params): """ Returns a stream url that may be used by external applications such as VLC. @@ -256,7 +234,7 @@ def cast(func, value): func (func): Calback function to used cast to type (int, bool, float). value (any): value to be cast and returned. """ - if value not in (None, NA): + if value is not None: if func == bool: return bool(int(value)) elif func in (int, float): @@ -517,7 +495,7 @@ def toDatetime(value, format=None): value (str): value to return as a datetime format (str): Format to pass strftime (optional; if value is a str). """ - if value and value != NA: + if value and value is not None: if format: value = datetime.strptime(value, format) else: diff --git a/plexapi/video.py b/plexapi/video.py index 75afde72..8acd8c42 100644 --- a/plexapi/video.py +++ b/plexapi/video.py @@ -3,8 +3,6 @@ from plexapi import media, utils from plexapi.exceptions import NotFound from plexapi.utils import Playable, PlexPartialObject -NA = utils.NA - class Video(PlexPartialObject): TYPE = None @@ -27,17 +25,17 @@ class Video(PlexPartialObject): data (Element): Usually built from server.query """ self.listType = 'video' - self.addedAt = utils.toDatetime(data.attrib.get('addedAt', NA)) - self.key = data.attrib.get('key', NA) - self.lastViewedAt = utils.toDatetime(data.attrib.get('lastViewedAt', NA)) - self.librarySectionID = data.attrib.get('librarySectionID', NA) - self.ratingKey = utils.cast(int, data.attrib.get('ratingKey', NA)) - self.summary = data.attrib.get('summary', NA) - self.thumb = data.attrib.get('thumb', NA) - self.title = data.attrib.get('title', NA) + self.addedAt = utils.toDatetime(data.attrib.get('addedAt')) + self.key = data.attrib.get('key') + self.lastViewedAt = utils.toDatetime(data.attrib.get('lastViewedAt')) + self.librarySectionID = data.attrib.get('librarySectionID') + self.ratingKey = utils.cast(int, data.attrib.get('ratingKey')) + self.summary = data.attrib.get('summary') + self.thumb = data.attrib.get('thumb') + self.title = data.attrib.get('title') self.titleSort = data.attrib.get('titleSort', self.title) - self.type = data.attrib.get('type', NA) - self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt', NA)) + self.type = data.attrib.get('type') + self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) self.viewCount = utils.cast(int, data.attrib.get('viewCount', 0)) @property @@ -89,25 +87,25 @@ class Movie(Video, Playable): """ Video._loadData(self, data) Playable._loadData(self, data) - self.art = data.attrib.get('art', NA) + self.art = data.attrib.get('art') self.audienceRating = utils.cast( - float, data.attrib.get('audienceRating', NA)) - self.audienceRatingImage = data.attrib.get('audienceRatingImage', NA) - self.chapterSource = data.attrib.get('chapterSource', NA) - self.contentRating = data.attrib.get('contentRating', NA) - self.duration = utils.cast(int, data.attrib.get('duration', NA)) - self.guid = data.attrib.get('guid', NA) - self.originalTitle = data.attrib.get('originalTitle', NA) + float, data.attrib.get('audienceRating')) + self.audienceRatingImage = data.attrib.get('audienceRatingImage') + self.chapterSource = data.attrib.get('chapterSource') + self.contentRating = data.attrib.get('contentRating') + self.duration = utils.cast(int, data.attrib.get('duration')) + self.guid = data.attrib.get('guid') + self.originalTitle = data.attrib.get('originalTitle') self.originallyAvailableAt = utils.toDatetime( - data.attrib.get('originallyAvailableAt', NA), '%Y-%m-%d') - self.primaryExtraKey = data.attrib.get('primaryExtraKey', NA) - self.rating = data.attrib.get('rating', NA) - self.ratingImage = data.attrib.get('ratingImage', NA) - self.studio = data.attrib.get('studio', NA) - self.tagline = data.attrib.get('tagline', NA) - self.userRating = utils.cast(float, data.attrib.get('userRating', NA)) + data.attrib.get('originallyAvailableAt'), '%Y-%m-%d') + self.primaryExtraKey = data.attrib.get('primaryExtraKey') + self.rating = data.attrib.get('rating') + self.ratingImage = data.attrib.get('ratingImage') + self.studio = data.attrib.get('studio') + self.tagline = data.attrib.get('tagline') + self.userRating = utils.cast(float, data.attrib.get('userRating')) self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0)) - self.year = utils.cast(int, data.attrib.get('year', NA)) + self.year = utils.cast(int, data.attrib.get('year')) if self.isFullObject(): # check this self.collections = [media.Collection(self.server, e) for e in data if e.tag == media.Collection.TYPE] self.countries = [media.Country(self.server, e) for e in data if e.tag == media.Country.TYPE] @@ -174,23 +172,23 @@ class Show(Video): Video._loadData(self, data) # Incase this was loaded from search etc self.key = self.key.replace('/children', '') - self.art = data.attrib.get('art', NA) - self.banner = data.attrib.get('banner', NA) - self.childCount = utils.cast(int, data.attrib.get('childCount', NA)) - self.contentRating = data.attrib.get('contentRating', NA) - self.duration = utils.cast(int, data.attrib.get('duration', NA)) - self.guid = data.attrib.get('guid', NA) - self.index = data.attrib.get('index', NA) - self.leafCount = utils.cast(int, data.attrib.get('leafCount', NA)) - self.location = utils.findLocations(data, single=True) or NA + self.art = data.attrib.get('art') + self.banner = data.attrib.get('banner') + self.childCount = utils.cast(int, data.attrib.get('childCount')) + self.contentRating = data.attrib.get('contentRating') + self.duration = utils.cast(int, data.attrib.get('duration')) + self.guid = data.attrib.get('guid') + self.index = data.attrib.get('index') + self.leafCount = utils.cast(int, data.attrib.get('leafCount')) + self.location = utils.findLocations(data, single=True) or None self.originallyAvailableAt = utils.toDatetime( - data.attrib.get('originallyAvailableAt', NA), '%Y-%m-%d') - self.rating = utils.cast(float, data.attrib.get('rating', NA)) - self.studio = data.attrib.get('studio', NA) - self.theme = data.attrib.get('theme', NA) + data.attrib.get('originallyAvailableAt'), '%Y-%m-%d') + self.rating = utils.cast(float, data.attrib.get('rating')) + self.studio = data.attrib.get('studio') + self.theme = data.attrib.get('theme') self.viewedLeafCount = utils.cast( - int, data.attrib.get('viewedLeafCount', NA)) - self.year = utils.cast(int, data.attrib.get('year', NA)) + int, data.attrib.get('viewedLeafCount')) + self.year = utils.cast(int, data.attrib.get('year')) if self.isFullObject(): # will be fixed with docs. self.genres = [media.Genre(self.server, e) for e in data if e.tag == media.Genre.TYPE] self.roles = [media.Role(self.server, e) for e in data if e.tag == media.Role.TYPE] @@ -314,13 +312,13 @@ class Season(Video): """ Video._loadData(self, data) self.key = self.key.replace('/children', '') - self.leafCount = utils.cast(int, data.attrib.get('leafCount', NA)) - self.index = utils.cast(int, data.attrib.get('index', NA)) - self.parentKey = data.attrib.get('parentKey', NA) - self.parentRatingKey = utils.cast(int, data.attrib.get('parentRatingKey', NA)) - self.parentTitle = data.attrib.get('parentTitle', NA) + self.leafCount = utils.cast(int, data.attrib.get('leafCount')) + self.index = utils.cast(int, data.attrib.get('index')) + self.parentKey = data.attrib.get('parentKey') + self.parentRatingKey = utils.cast(int, data.attrib.get('parentRatingKey')) + self.parentTitle = data.attrib.get('parentTitle') self.viewedLeafCount = utils.cast( - int, data.attrib.get('viewedLeafCount', NA)) + int, data.attrib.get('viewedLeafCount')) @property def isWatched(self): @@ -430,26 +428,26 @@ class Episode(Video, Playable): """ Video._loadData(self, data) Playable._loadData(self, data) - self.art = data.attrib.get('art', NA) - self.chapterSource = data.attrib.get('chapterSource', NA) - self.contentRating = data.attrib.get('contentRating', NA) - self.duration = utils.cast(int, data.attrib.get('duration', NA)) - self.grandparentArt = data.attrib.get('grandparentArt', NA) - self.grandparentKey = data.attrib.get('grandparentKey', NA) - self.grandparentRatingKey = utils.cast(int, data.attrib.get('grandparentRatingKey', NA)) - self.grandparentTheme = data.attrib.get('grandparentTheme', NA) - self.grandparentThumb = data.attrib.get('grandparentThumb', NA) - self.grandparentTitle = data.attrib.get('grandparentTitle', NA) - self.guid = data.attrib.get('guid', NA) - self.index = utils.cast(int, data.attrib.get('index', NA)) - self.originallyAvailableAt = utils.toDatetime(data.attrib.get('originallyAvailableAt', NA), '%Y-%m-%d') - self.parentIndex = data.attrib.get('parentIndex', NA) - self.parentKey = data.attrib.get('parentKey', NA) - self.parentRatingKey = utils.cast(int, data.attrib.get('parentRatingKey', NA)) - self.parentThumb = data.attrib.get('parentThumb', NA) - self.rating = utils.cast(float, data.attrib.get('rating', NA)) + self.art = data.attrib.get('art') + self.chapterSource = data.attrib.get('chapterSource') + self.contentRating = data.attrib.get('contentRating') + self.duration = utils.cast(int, data.attrib.get('duration')) + self.grandparentArt = data.attrib.get('grandparentArt') + self.grandparentKey = data.attrib.get('grandparentKey') + self.grandparentRatingKey = utils.cast(int, data.attrib.get('grandparentRatingKey')) + self.grandparentTheme = data.attrib.get('grandparentTheme') + self.grandparentThumb = data.attrib.get('grandparentThumb') + self.grandparentTitle = data.attrib.get('grandparentTitle') + self.guid = data.attrib.get('guid') + self.index = utils.cast(int, data.attrib.get('index')) + self.originallyAvailableAt = utils.toDatetime(data.attrib.get('originallyAvailableAt'), '%Y-%m-%d') + self.parentIndex = data.attrib.get('parentIndex') + self.parentKey = data.attrib.get('parentKey') + self.parentRatingKey = utils.cast(int, data.attrib.get('parentRatingKey')) + self.parentThumb = data.attrib.get('parentThumb') + self.rating = utils.cast(float, data.attrib.get('rating')) self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0)) - self.year = utils.cast(int, data.attrib.get('year', NA)) + self.year = utils.cast(int, data.attrib.get('year')) self.directors = [media.Director(self.server, e) for e in data if e.tag == media.Director.TYPE] self.media = [media.Media(self.server, e, self.initpath, self) for e in data if e.tag == media.Media.TYPE] self.writers = [media.Writer(self.server, e) for e in data if e.tag == media.Writer.TYPE] @@ -457,7 +455,7 @@ class Episode(Video, Playable): self.audioStreams = utils.findStreams(self.media, 'audiostream') self.subtitleStreams = utils.findStreams(self.media, 'subtitlestream') # data for active sessions and history - self.sessionKey = utils.cast(int, data.attrib.get('sessionKey', NA)) + self.sessionKey = utils.cast(int, data.attrib.get('sessionKey')) self.username = utils.findUsername(data) self.player = utils.findPlayer(self.server, data) self.transcodeSession = utils.findTranscodeSession(self.server, data)