@@ -265,15 +265,34 @@ def unmatch(self):
265265 key = '/library/metadata/%s/unmatch' % self .ratingKey
266266 return self ._server .query (key , method = self ._server ._session .put )
267267
268- def matches (self ):
268+ def matches (self , auto = True , agent = None , title = None , year = None , lang = None ):
269269 """ Return list of movie metadata matches from library agent"""
270- results = []
271270 key = '/library/metadata/%s/matches' % self .ratingKey
272- data = self ._server .query (key , method = self ._server ._session .get )
271+ if not auto :
272+ key += '?manual=%s' % 1
273+ if title :
274+ key += '&title=%s' % quote (title )
275+ if agent :
276+ agents = {ag .shortIdentifier : ag for ag in self ._server .agents ()}
277+ if agents .get (agent ):
278+ agent = agents .get (agent )
279+ key += '&agent=%s' % agent .identifier
280+ else :
281+ raise NotFound ('Couldnt find "%s" in agents list (%s)' %
282+ (agent , ',' .join (agents .keys ())))
283+ else :
284+ sectionAgent = self .section ().agent
285+ key += '&agent=%s' % sectionAgent
286+ if year :
287+ key += '&year=%s' % year
288+ if lang :
289+ key += '&language=%s' % lang
290+ else :
291+ sectionLang = self .section ().language
292+ key += '&language=%s' % sectionLang
273293
274- for elem in data :
275- results .append (media .SearchResult (data = elem , server = self ._server ))
276- return results
294+ data = self ._server .query (key , method = self ._server ._session .get )
295+ return self .findItems (data )
277296
278297 def fixMatch (self , searchResult ):
279298 """ Use match result to update movie metadata. """
0 commit comments