mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 19:53:17 +00:00
Add is_watched property; Fix python3 bug in examples
This commit is contained in:
parent
1c27b9afb6
commit
430fb25658
4 changed files with 12 additions and 2 deletions
|
@ -227,6 +227,14 @@ def test_015_list_devices(plex, user=None):
|
|||
# item.mark_as_done(part.sync_id)
|
||||
|
||||
|
||||
def test_017_is_watched(plex, user=None):
|
||||
show = plex.library.section(SHOW_SECTION).get(SHOW_TITLE)
|
||||
episode = show.get(SHOW_EPISODE)
|
||||
log(2, '%s is_watched: %s' % (episode.title, episode.is_watched))
|
||||
movie = plex.library.section(MOVIE_SECTION).get(MOVIE_TITLE)
|
||||
log(2, '%s is_watched: %s' % (movie.title, movie.is_watched))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Run PlexAPI tests.')
|
||||
parser.add_argument('-r', '--resource', help='Name of the Plex resource (requires user/pass).')
|
||||
|
|
|
@ -34,7 +34,7 @@ def iter_tests(module, args):
|
|||
check_test = lambda name: name.startswith('test_') or name.startswith('example_')
|
||||
check_name = lambda name: not args.name or args.name in name
|
||||
module = sys.modules[module]
|
||||
for func in sorted(module.__dict__.values()):
|
||||
for _, func in sorted(module.__dict__.items()): # .values():
|
||||
if inspect.isfunction(func) and inspect.getmodule(func) == module:
|
||||
if check_test(func.__name__) and check_name(func.__name__):
|
||||
yield func
|
||||
|
|
|
@ -26,7 +26,7 @@ class PlexPartialObject(object):
|
|||
def __getattr__(self, attr):
|
||||
if self.isPartialObject():
|
||||
self.reload()
|
||||
return self.__dict__.get(attr)
|
||||
return self.__dict__[attr]
|
||||
|
||||
def __setattr__(self, attr, value):
|
||||
if value != NA:
|
||||
|
|
|
@ -138,6 +138,7 @@ class Movie(Video):
|
|||
self.duration = cast(int, data.attrib.get('duration', NA))
|
||||
self.originallyAvailableAt = toDatetime(data.attrib.get('originallyAvailableAt', NA), '%Y-%m-%d')
|
||||
self.primaryExtraKey = data.attrib.get('primaryExtraKey', NA)
|
||||
self.is_watched = bool(self.viewCount > 0) # custom attr
|
||||
|
||||
|
||||
class Show(Video):
|
||||
|
@ -246,6 +247,7 @@ class Episode(Video):
|
|||
self.year = cast(int, data.attrib.get('year', NA))
|
||||
self.duration = cast(int, data.attrib.get('duration', NA))
|
||||
self.originallyAvailableAt = toDatetime(data.attrib.get('originallyAvailableAt', NA), '%Y-%m-%d')
|
||||
self.is_watched = bool(self.viewCount > 0) # custom attr
|
||||
|
||||
@property
|
||||
def thumbUrl(self):
|
||||
|
|
Loading…
Reference in a new issue