Commits

Adam Lindsay  committed 795c4cb

Added Resolver.lookup and brought in internal convenience methods

  • Participants
  • Parent commits 44f421e

Comments (0)

Files changed (1)

File spotimeta/resolver.py

         self.score(track, res['result'])
         return res
     
+    def lookup(self, uri, detail=0):
+        return self._md.lookup(uri, detail=detail)
+    
     def multiquery(self, artist=None, album=None, track=None):
         """
         Given a combination of artist, album, and/or track, tries
         """
         candlist = list()
         if artist:
-            candidates = self._md.search_artist(artist)
-            candlist.extend(self.score(artist, candidates['result']))
+            candlist = self.search_artist(artist)['result']
         if album:
             if candlist:
                 clist = list()
                 for art in candlist[:self.candidates]:
-                    r = self._md.lookup(art['href'], detail=1)['result']['albums']
+                    r = self.lookup(art['href'], detail=1)['result']['albums']
                     for a in r:
                         a['score'] = art['score']
                     clist.extend(r)
                 candlist = self.score(album, clist)
             else:
-                candidates = self._md.search_album(album)
-                candlist = self.score(album, candidates['result'])
+                candlist = self.search_album(album)['result']
         if track:
             if candlist and album:
                 clist = list()
                 for alb in candlist[:self.candidates]:
-                    r = self._md.lookup(alb['href'], detail=1)['result']['tracks']
+                    r = self.lookup(alb['href'], detail=1)['result']['tracks']
                     for t in r:
                         t['score'] = alb['score']
                     clist.extend(r)
                 candlist = self.score(track, clist)
             else:
-                candidates = self._md.search_track(track)
-                candlist = self.score(track, candidates['result'])
+                candlist = self.search_track(track)['result']
                 if artist:
                     candlist = self.score(artist, candlist, accessor='artist')   
         return candlist