Skip to content

Commit bb55a00

Browse files
committed
really need to sanity check on this one..
1 parent 9d364e4 commit bb55a00

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

plexapi/base.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ def listAttrs(self, data, attr, **kwargs):
182182

183183
def reload(self, key=None):
184184
""" Reload the data for this object from self.key. """
185-
key = key or self.key
185+
if key is None:
186+
if hasattr(self, '_details_key'):
187+
key = self._details_key
188+
else:
189+
key = self.key
190+
186191
if not key:
187192
raise Unsupported('Cannot reload an object not built from a URL.')
188193
self._initpath = key
@@ -275,7 +280,7 @@ def __getattribute__(self, attr):
275280
if attr == 'key' or attr.startswith('_'): return value
276281
if value not in (None, []): return value
277282
if self.isFullObject(): return value
278-
# Log warning that were reloading the object
283+
# Log the reload.
279284
clsname = self.__class__.__name__
280285
title = self.__dict__.get('title', self.__dict__.get('name'))
281286
objname = "%s '%s'" % (clsname, title) if title else clsname
@@ -310,6 +315,8 @@ def isFullObject(self):
310315
search result for a movie often only contain a portion of the attributes a full
311316
object (main url) for that movie contain.
312317
"""
318+
#print(self._details_key == self._initpath)
319+
#return self._details_key == self._initpath or not self.key or self.key == self._initpath
313320
return not self.key or self.key == self._initpath
314321

315322
def isPartialObject(self):
@@ -448,6 +455,14 @@ def _loadData(self, data):
448455
self.viewedAt = utils.toDatetime(data.attrib.get('viewedAt')) # history
449456
self.playlistItemID = utils.cast(int, data.attrib.get('playlistItemID')) # playlist
450457

458+
def isFullObject(self):
459+
""" Retruns True if this is already a full object. A full object means all attributes
460+
were populated from the api path representing only this item. For example, the
461+
search result for a movie often only contain a portion of the attributes a full
462+
object (main url) for that movie contain.
463+
"""
464+
return self._details_key == self._initpath or not self.key
465+
451466
def getStreamURL(self, **params):
452467
""" Returns a stream url that may be used by external applications such as VLC.
453468

plexapi/video.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def markUnwatched(self):
7979

8080

8181
@utils.registerPlexObject
82-
class Movie(Video, Playable):
82+
class Movie(Playable, Video):
8383
""" Represents a single Movie.
8484
8585
Attributes:
@@ -115,14 +115,18 @@ class Movie(Video, Playable):
115115
"""
116116
TAG = 'Video'
117117
TYPE = 'movie'
118-
_include = '?checkFiles=1&includeExtras=1&includeRelated=1&includeRelatedCount=5&includeOnDeck=1&includeChapters=1&includePopularLeaves=1&includeConcerts=1&includePreferences=1'
118+
_include = ('?checkFiles=1&includeExtras=1&includeRelated=1'
119+
'&includeOnDeck=1&includeChapters=1&includePopularLeaves=1'
120+
'&includeConcerts=1&includePreferences=1')
121+
119122

120123
def _loadData(self, data):
121124
""" Load attribute values from Plex XML response. """
122125
Video._loadData(self, data)
123126
Playable._loadData(self, data)
124127

125-
self.key = data.attrib.get('key') + self._include
128+
self.key = data.attrib.get('key')
129+
self._details_key = self.key + self._include
126130
self.art = data.attrib.get('art')
127131
self.audienceRating = utils.cast(float, data.attrib.get('audienceRating'))
128132
self.audienceRatingImage = data.attrib.get('audienceRatingImage')
@@ -442,7 +446,7 @@ def download(self, savepath=None, keep_orginal_name=False, **kwargs):
442446

443447

444448
@utils.registerPlexObject
445-
class Episode(Video, Playable):
449+
class Episode(Playable, Video):
446450
""" Represents a single Shows Episode.
447451
448452
Attributes:
@@ -476,11 +480,15 @@ class Episode(Video, Playable):
476480
"""
477481
TAG = 'Video'
478482
TYPE = 'episode'
483+
_include = ('?checkFiles=1&includeExtras=1&includeRelated=1'
484+
'&includeOnDeck=1&includeChapters=1&includePopularLeaves=1'
485+
'&includeConcerts=1&includePreferences=1')
479486

480487
def _loadData(self, data):
481488
""" Load attribute values from Plex XML response. """
482489
Video._loadData(self, data)
483490
Playable._loadData(self, data)
491+
self._details_key = self.key + self._include
484492
self._seasonNumber = None # cached season number
485493
self.art = data.attrib.get('art')
486494
self.chapterSource = data.attrib.get('chapterSource')
@@ -509,6 +517,7 @@ def _loadData(self, data):
509517
self.writers = self.findItems(data, media.Writer)
510518
self.labels = self.findItems(data, media.Label)
511519
self.collections = self.findItems(data, media.Collection)
520+
self.chapters = self.findItems(data, media.Chapter)
512521

513522
def __repr__(self):
514523
return '<%s>' % ':'.join([p for p in [

0 commit comments

Comments
 (0)