Skip to content

Commit 39bb93f

Browse files
committed
add unmatch, matches, and fixMatches methods for shows
matches will need additional work for manual matches
1 parent 4c9aef2 commit 39bb93f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

plexapi/video.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,30 @@ def unwatched(self):
434434
""" Returns list of unwatched :class:`~plexapi.video.Episode` objects. """
435435
return self.episodes(viewCount=0)
436436

437+
def unmatch(self):
438+
""" Unmatches show object. """
439+
key = '/library/metadata/%s/unmatch' % self.ratingKey
440+
self._server.query(key, method=self._server._session.put)
441+
442+
def matches(self):
443+
""" Return list of show metadata matches from library agent. """
444+
results = []
445+
key = '/library/metadata/%s/matches' % self.ratingKey
446+
data = self._server.query(key, method=self._server._session.get)
447+
448+
for elem in data:
449+
results.append(media.SearchResult(data=elem, server=self._server))
450+
return results
451+
452+
def fixMatch(self, searchResult):
453+
""" Use match result to update show metadata. """
454+
key = '/library/metadata/%s/match' % self.ratingKey
455+
params = {'guid': searchResult.guid,
456+
'name': searchResult.name}
457+
458+
data = key + '?' + urlencode(params)
459+
self._server.query(data, method=self._server._session.put)
460+
437461
def get(self, title=None, season=None, episode=None):
438462
""" Alias to :func:`~plexapi.video.Show.episode()`. """
439463
return self.episode(title, season, episode)

0 commit comments

Comments
 (0)