Refactor includes to PlexPartialObject

* Allows includes to be used by Audio, Video, Photoalbum, Photo, Collections, and Playlist
This commit is contained in:
JonnyWong16 2020-11-21 19:52:01 -08:00
parent 387ab17072
commit a5690579d5
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 23 additions and 26 deletions

View file

@ -95,9 +95,9 @@ class PlexObject(object):
or disable each parameter individually by setting it to False or 0. or disable each parameter individually by setting it to False or 0.
""" """
details_key = self.key details_key = self.key
if hasattr(self, '_includes'): if hasattr(self, '_INCLUDES'):
includes = {} includes = {}
for k, v in self._includes.items(): for k, v in self._INCLUDES.items():
value = kwargs.get(k, v) value = kwargs.get(k, v)
if value not in [False, 0, '0']: if value not in [False, 0, '0']:
includes[k] = 1 if value is True else value includes[k] = 1 if value is True else value
@ -303,6 +303,27 @@ class PlexPartialObject(PlexObject):
and if the specified value you request is None it will fetch the full object and if the specified value you request is None it will fetch the full object
automatically and update itself. automatically and update itself.
""" """
_INCLUDES = {
'checkFiles': 1,
'includeAllConcerts': 1,
'includeBandwidths': 1,
'includeChapters': 1,
'includeChildren': 1,
'includeConcerts': 1,
'includeExternalMedia': 1,
'includeExtras': 1,
'includeFields': [1, 'thumbBlurHash', 'artBlurHash'],
'includeGeolocation': 1,
'includeLoudnessRamps': 1,
'includeMarkers': 1,
'includeOnDeck': 1,
'includePopularLeaves': 1,
'includePreferences': 1,
'includeRelated': 1,
'includeRelatedCount': 1,
'includeReviews': 1,
'includeStations': 1
}
def __eq__(self, other): def __eq__(self, other):
return other not in [None, []] and self.key == other.key return other not in [None, []] and self.key == other.key

View file

@ -1429,10 +1429,6 @@ class Collections(PlexPartialObject):
TAG = 'Directory' TAG = 'Directory'
TYPE = 'collection' TYPE = 'collection'
_includes = {
'includeExternalMedia': 1,
'includePreferences': 1
}
def _loadData(self, data): def _loadData(self, data):
self.ratingKey = utils.cast(int, data.attrib.get('ratingKey')) self.ratingKey = utils.cast(int, data.attrib.get('ratingKey'))

View file

@ -28,26 +28,6 @@ class Video(PlexPartialObject):
updatedAt (datatime): Datetime this item was updated. updatedAt (datatime): Datetime this item was updated.
viewCount (int): Count of times this item was accessed. viewCount (int): Count of times this item was accessed.
""" """
_includes = {
'checkFiles': 1,
'includeAllConcerts': 1,
'includeBandwidths': 1,
'includeChapters': 1,
'includeChildren': 1,
'includeConcerts': 1,
'includeExtras': 1,
'includeFields': [1, 'thumbBlurHash', 'artBlurHash'],
'includeGeolocation': 1,
'includeLoudnessRamps': 1,
'includeMarkers': 1,
'includeOnDeck': 1,
'includePopularLeaves': 1,
'includePreferences': 1,
'includeRelated': 1,
'includeRelatedCount': 1,
'includeReviews': 1,
'includeStations': 1
}
def _loadData(self, data): def _loadData(self, data):
""" Load attribute values from Plex XML response. """ """ Load attribute values from Plex XML response. """