Skip to content

Commit db6a670

Browse files
authored
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
1 parent 810b469 commit db6a670

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

plexapi/video.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ def rate(self, rate):
8888
def _defaultSyncTitle(self):
8989
""" Returns str, default title for a new syncItem. """
9090
return self.title
91+
92+
def exists(self):
93+
"""" Returns exists, accessible, and file"""
94+
exist_path = []
95+
data = self._server.query(self.key + self._include)
96+
for elem in data:
97+
for media in elem:
98+
for part in media:
99+
exists = utils.cast(bool, part.attrib.get('exists'))
100+
accessible = utils.cast(bool, part.attrib.get('accessible'))
101+
part_file = part.attrib.get('file')
102+
if exists is None and accessible is None and part_file is None:
103+
pass
104+
else:
105+
exist_path.append((exists, accessible, part_file))
106+
107+
return exist_path
91108

92109
def sync(self, videoQuality, client=None, clientId=None, limit=None, unwatched=False, title=None):
93110
""" Add current video (movie, tv-show, season or episode) as sync item for specified device.

0 commit comments

Comments
 (0)