mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
Refactor includes to PlexPartialObject
* Allows includes to be used by Audio, Video, Photoalbum, Photo, Collections, and Playlist
This commit is contained in:
parent
387ab17072
commit
a5690579d5
3 changed files with 23 additions and 26 deletions
|
@ -95,9 +95,9 @@ class PlexObject(object):
|
|||
or disable each parameter individually by setting it to False or 0.
|
||||
"""
|
||||
details_key = self.key
|
||||
if hasattr(self, '_includes'):
|
||||
if hasattr(self, '_INCLUDES'):
|
||||
includes = {}
|
||||
for k, v in self._includes.items():
|
||||
for k, v in self._INCLUDES.items():
|
||||
value = kwargs.get(k, v)
|
||||
if value not in [False, 0, '0']:
|
||||
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
|
||||
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):
|
||||
return other not in [None, []] and self.key == other.key
|
||||
|
|
|
@ -1429,10 +1429,6 @@ class Collections(PlexPartialObject):
|
|||
|
||||
TAG = 'Directory'
|
||||
TYPE = 'collection'
|
||||
_includes = {
|
||||
'includeExternalMedia': 1,
|
||||
'includePreferences': 1
|
||||
}
|
||||
|
||||
def _loadData(self, data):
|
||||
self.ratingKey = utils.cast(int, data.attrib.get('ratingKey'))
|
||||
|
|
|
@ -28,26 +28,6 @@ class Video(PlexPartialObject):
|
|||
updatedAt (datatime): Datetime this item was updated.
|
||||
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):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
|
|
Loading…
Reference in a new issue