Batch download songs for artist

This commit is contained in:
Sumner Evans
2019-08-31 10:09:29 -06:00
parent 3687d9b0b0
commit 57f232bcb6
4 changed files with 15 additions and 5 deletions

View File

@@ -278,6 +278,7 @@ class LibremsonicApp(Gtk.Application):
self.state.save()
self.reset_cache_manager()
self.update_window()
def reset_cache_manager(self):
CacheManager.reset(

View File

@@ -308,10 +308,20 @@ class ArtistDetailPanel(Gtk.Box):
self.update_artist_view(self.artist_id, force=True)
def on_download_all_click(self, btn):
print('download all')
songs_for_download = []
artist = CacheManager.get_artist(self.artist_id).result()
for album in artist.album:
print(album)
for album in (artist.get('album', artist.get('child', []))):
album_songs = CacheManager.get_album(album.id).result()
album_songs = album_songs.get('child', album_songs.get('song', []))
for song in album_songs:
songs_for_download.append(song.id)
CacheManager.batch_download_songs(
songs_for_download,
before_download=lambda: self.update_artist_view(self.artist_id),
on_song_download_complete=lambda i: self.update_artist_view(
self.artist_id),
)
# Helper Methods
# =========================================================================

View File

@@ -212,7 +212,7 @@ class AlbumWithSongs(Gtk.Box):
util.esc(song.title),
util.format_song_duration(song.duration),
song.id,
] for song in album.get('child', album.get('song', []))]
] for song in (album.get('child') or album.get('song') or [])]
util.diff_store(self.album_song_store, new_store)
self.loading_indicator.hide()

View File

@@ -131,7 +131,6 @@ class CoverArtGrid(Gtk.ScrolledWindow):
force_reload_from_master=(old_len != new_len or force))
stop_loading()
print('update grid')
future = self.get_model_list_future(
before_download=start_loading,
force=force,