mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-26 13:40:22 +00:00
adding unmatch/match methods from video:Movie and video:Show classes to base:PlexPartialObject
minor improvements to matches method thanks to @JonnyWong16 matching can be done for artists, albums, shows, movies all other media types safely return an empty list []
This commit is contained in:
parent
c2c13fbfe2
commit
38b0fee6c9
1 changed files with 37 additions and 0 deletions
|
@ -429,6 +429,43 @@ class PlexPartialObject(PlexObject):
|
||||||
"""
|
"""
|
||||||
return self._server.history(maxresults=maxresults, mindate=mindate, ratingKey=self.ratingKey)
|
return self._server.history(maxresults=maxresults, mindate=mindate, ratingKey=self.ratingKey)
|
||||||
|
|
||||||
|
def unmatch(self):
|
||||||
|
""" Unmatches show object. """
|
||||||
|
key = '/library/metadata/%s/unmatch' % self.ratingKey
|
||||||
|
self._server.query(key, method=self._server._session.put)
|
||||||
|
|
||||||
|
def matches(self, auto=True, agent=None, title=None, year=None, language=None):
|
||||||
|
""" Return list of show metadata matches from library agent. """
|
||||||
|
key = '/library/metadata/%s/matches' % self.ratingKey
|
||||||
|
if not auto:
|
||||||
|
params = {'manual': 1,
|
||||||
|
'title': title or self.title,
|
||||||
|
'year': year or self.year if self.section().type != 'artist' else '',
|
||||||
|
'language': language or self.section().language}
|
||||||
|
if agent:
|
||||||
|
agents = self._server.agents()
|
||||||
|
match_agent = next((ag for ag in agents if ag.shortIdentifier == agent), None)
|
||||||
|
if match_agent:
|
||||||
|
params['agent'] = match_agent.identifier
|
||||||
|
else:
|
||||||
|
raise NotFound('Couldnt find "%s" in agents list (%s)' %
|
||||||
|
(agent, ','.join(agents.keys())))
|
||||||
|
else:
|
||||||
|
params['agent'] = self.section().agent
|
||||||
|
|
||||||
|
key = key + '?' + urlencode(params)
|
||||||
|
data = self._server.query(key, method=self._server._session.get)
|
||||||
|
return self.findItems(data)
|
||||||
|
|
||||||
|
def fixMatch(self, searchResult):
|
||||||
|
""" Use match result to update show metadata. """
|
||||||
|
key = '/library/metadata/%s/match' % self.ratingKey
|
||||||
|
params = {'guid': searchResult.guid,
|
||||||
|
'name': searchResult.name}
|
||||||
|
|
||||||
|
data = key + '?' + urlencode(params)
|
||||||
|
self._server.query(data, method=self._server._session.put)
|
||||||
|
|
||||||
# The photo tag cant be built atm. TODO
|
# The photo tag cant be built atm. TODO
|
||||||
# def arts(self):
|
# def arts(self):
|
||||||
# part = '%s/arts' % self.key
|
# part = '%s/arts' % self.key
|
||||||
|
|
Loading…
Reference in a new issue