@@ -458,15 +458,34 @@ def unmatch(self):
458458 key = '/library/metadata/%s/unmatch' % self .ratingKey
459459 self ._server .query (key , method = self ._server ._session .put )
460460
461- def matches (self ):
462- """ Return list of show metadata matches from library agent. """
463- results = []
461+ def matches (self , auto = True , agent = None , title = None , year = None , lang = None ):
462+ """ Return list of show metadata matches from library agent"""
464463 key = '/library/metadata/%s/matches' % self .ratingKey
465- data = self ._server .query (key , method = self ._server ._session .get )
464+ if not auto :
465+ key += '?manual=%s' % 1
466+ if title :
467+ key += '&title=%s' % quote (title )
468+ if agent :
469+ agents = {ag .shortIdentifier : ag for ag in self ._server .agents ()}
470+ if agents .get (agent ):
471+ agent = agents .get (agent )
472+ key += '&agent=%s' % agent .identifier
473+ else :
474+ raise NotFound ('Couldnt find "%s" in agents list (%s)' %
475+ (agent , ',' .join (agents .keys ())))
476+ else :
477+ sectionAgent = self .section ().agent
478+ key += '&agent=%s' % sectionAgent
479+ if year :
480+ key += '&year=%s' % year
481+ if lang :
482+ key += '&language=%s' % lang
483+ else :
484+ sectionLang = self .section ().language
485+ key += '&language=%s' % sectionLang
466486
467- for elem in data :
468- results .append (media .SearchResult (data = elem , server = self ._server ))
469- return results
487+ data = self ._server .query (key , method = self ._server ._session .get )
488+ return self .findItems (data )
470489
471490 def fixMatch (self , searchResult ):
472491 """ Use match result to update show metadata. """
0 commit comments