def do_search(self, line): if not line: if self.results is False: print "No search is in progress" elif self.results is None: print "Searching is in progress" else: print "Artists:" for a in self.results.artists(): print " ", Link.from_artist(a), a.name() print "Albums:" for a in self.results.albums(): print " ", Link.from_album(a), a.name() print "Tracks:" for a in self.results.tracks(): print " ", Link.from_track(a, 0), a.name() print "%d tracks not shown" % (self.results.total_tracks() - len(self.results.tracks())) else: line = line.decode('utf-8') self.results = None def search_finished(results, userdata): print "\nSearch results received" self.results = results self.print_search_results() self.jukebox.search(line, search_finished)
def to_mopidy_artist(cls, spotify_artist): if not spotify_artist.is_loaded(): return Artist(name=u'[loading...]') return Artist( uri=str(Link.from_artist(spotify_artist)), name=spotify_artist.name() )
def to_mopidy_artist(spotify_artist): if spotify_artist is None: return uri = str(Link.from_artist(spotify_artist)) if not spotify_artist.is_loaded(): return Artist(uri=uri, name='[loading...]') return Artist(uri=uri, name=spotify_artist.name())
def do_search(self, line): if not line: if self.results is False: print "No search is in progress" elif self.results is None: print "Searching is in progress" else: print "Artists:" for a in self.results.artists(): print " ", Link.from_artist(a), a.name() print "Albums:" for a in self.results.albums(): print " ", Link.from_album(a), a.name() print "Tracks:" for a in self.results.tracks(): print " ", Link.from_track(a, 0), a.name() print self.results.total_tracks() - \ len(self.results.tracks()), "Tracks not shown" else: line = line.decode('utf-8') self.results = None def search_finished(results, userdata): print "\nSearch results received" self.results = results self.print_search_results() self.jukebox.search(line, search_finished)
def add_artist_to_directory(self, artist, directory): artist_uri = str(Link.from_artist(artist)) directory.add( DirectoryObject(key=Callback(self.get_artist_albums, uri=artist_uri), title=artist.name().decode("utf-8"), thumb=R("placeholder-artist.png")))
def add_artist_link(self, artist, source): """ Add an artist link to the queue. """ link = str(Link.from_artist(artist)) if not self._items: self._items = [ ] with open('queue.json', 'r') as fp: self._items = json.load(fp) found = False for item in self._items: if item['link'] == link: found = True break if not found: while not artist.is_loaded(): time.sleep(0.1) print 'Adding %s' % artist.name() self._items.append({ 'name': artist.name(), 'link': link, 'source': source, }) with open('queue.json', 'w') as fp: json.dump(self._items, fp, indent=2) return True
def action_search(self, line): if not line: if self.results is False: print "No search is in progress" return False elif self.results is None: print "Searching is in progress" else: print "Artists:" for a in self.results.artists(): print " ", Link.from_artist(a), a.name() print "Albums:" for a in self.results.albums(): print " ", Link.from_album(a), a.name() print "Tracks:" for a in self.results.tracks(): print " ", Link.from_track(a, 0), a.name() print self.results.total_tracks() - len( self.results.tracks()), "Tracks not shown" self.results = False else: self.results = None def _(results, userdata): print "\nSearch results received" self.results = results self.search(line, _)
def action_search(self, line): if not line: if self.results is False: print "No search is in progress" return False elif self.results is None: print "Searching is in progress" else: print "Artists:" for a in self.results.artists(): print " ", Link.from_artist(a), a.name() print "Albums:" for a in self.results.albums(): print " ", Link.from_album(a), a.name() print "Tracks:" for a in self.results.tracks(): print " ", Link.from_track(a, 0), a.name() print self.results.total_tracks() - len(self.results.tracks()), "Tracks not shown" self.results = False else: self.results = None def _(results, userdata): print "\nSearch results received" self.results = results self.search(line, _)
def add_artist_to_directory(self, artist, directory): artist_uri = str(Link.from_artist(artist)) directory.add( DirectoryObject( key = Callback(self.get_artist_albums, uri = artist_uri), title = artist.name().decode("utf-8"), thumb = R("placeholder-artist.png") ) )
def to_mopidy_artist(spotify_artist): if spotify_artist is None: return uri = str(Link.from_artist(spotify_artist)) if uri in artist_cache: return artist_cache[uri] if not spotify_artist.is_loaded(): return Artist(uri=uri, name='[loading...]') artist_cache[uri] = Artist(uri=uri, name=spotify_artist.name()) return artist_cache[uri]
def print_search_results(self): print "Artists:" for a in self.results.artists(): print " ", Link.from_artist(a), a.name() print "Albums:" for a in self.results.albums(): print " ", Link.from_album(a), a.name() print "Tracks:" for a in self.results.tracks(): print " ", Link.from_track(a, 0), a.name() print self.results.total_tracks() - len(self.results.tracks()), \ "Tracks not shown"
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
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): self.log("Artist browse complete: %s" % Link.from_artist(artist)) callback(browser) self.log("Browse artist: %s" % link) browser = self.session.browse_artist(artist, callback_wrapper) return browser
def callback_wrapper(browser, userdata): self.log("Artist browse complete: %s" % Link.from_artist(artist)) callback(browser)
def callback_wrapper(browser): self.log("Artist browse complete: %s" % Link.from_artist(artist)) callback(browser)
def _to_mopidy_artist(self, spotify_artist): return Artist( uri=str(Link.from_artist(spotify_artist)), name=spotify_artist.name().decode(ENCODING), )