Skip to content

Commit

Permalink
lookup: Get all album browsers first, then use them
Browse files Browse the repository at this point in the history
Reduces lookup time for worst case scenario artists with 9/10.

Related to #30, #31.
  • Loading branch information
jodal committed Jan 25, 2015
1 parent 0b698a2 commit b314b77
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mopidy_spotify/library.py
Expand Up @@ -184,14 +184,18 @@ def _lookup_artist(self, sp_link):
type=spotify.ArtistBrowserType.NO_TRACKS)
sp_artist_browser.load()

# Get all album browsers we need first, so they can start retrieving
# data in the background.
sp_album_browsers = []
for sp_album in sp_artist_browser.albums:
sp_album.load()
if sp_album.type is spotify.AlbumType.COMPILATION:
continue
if sp_album.artist.link.uri in VARIOUS_ARTISTS_URIS:
continue
sp_album_browsers.append(sp_album.browse())

sp_album_browser = sp_album.browse()
for sp_album_browser in sp_album_browsers:
sp_album_browser.load()
for sp_track in sp_album_browser.tracks:
track = translator.to_track(
Expand Down

0 comments on commit b314b77

Please sign in to comment.