add exists function

instead of modifying media.py and base.py, create a function to check if the video exists, is accessible, and which file if multiples exist(ed). For #385
This commit is contained in:
blacktwin 2019-09-30 11:43:57 -04:00 committed by GitHub
parent 810b469add
commit db6a670a4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,6 +89,23 @@ class Video(PlexPartialObject):
""" Returns str, default title for a new syncItem. """
return self.title
def exists(self):
"""" Returns exists, accessible, and file"""
exist_path = []
data = self._server.query(self.key + self._include)
for elem in data:
for media in elem:
for part in media:
exists = utils.cast(bool, part.attrib.get('exists'))
accessible = utils.cast(bool, part.attrib.get('accessible'))
part_file = part.attrib.get('file')
if exists is None and accessible is None and part_file is None:
pass
else:
exist_path.append((exists, accessible, part_file))
return exist_path
def sync(self, videoQuality, client=None, clientId=None, limit=None, unwatched=False, title=None):
""" Add current video (movie, tv-show, season or episode) as sync item for specified device.
See :func:`plexapi.myplex.MyPlexAccount.sync()` for possible exceptions.