Ejemplo n.º 1
0
 def browse(self, link, callback):
     if link.type() == link.LINK_ALBUM:
         browser = self.session.browse_album(link.as_album(), callback)
         while not browser.is_loaded():
             time.sleep(0.1)
         for track in browser:
             print track.name()
     if link.type() == link.LINK_ARTIST:
         browser = ArtistBrowser(link.as_artist())
         while not browser.is_loaded():
             time.sleep(0.1)
         for album in browser:
             print album.name()
Ejemplo n.º 2
0
    def browse_artist(self, artist, callback):
        ''' Browse an artist, invoking the callback when done

        :param artist:         An artist instance to browse.
        :param callback:       A callback to invoke when the album is loaded.
                               Should take the browser as a single parameter.
        '''
        link = Link.from_artist(artist)

        def callback_wrapper(browser, userdata):
            self.log("Artist browse complete: %s" % Link.from_artist(artist))
            callback(browser)

        self.log("Browse artist: %s" % link)
        browser = ArtistBrowser(artist, "no_tracks", callback_wrapper)
        return browser