Loading all artist tracks in cycle

This commit is contained in:
localhost_frssoft 2022-11-09 14:47:38 +03:00
parent b945793689
commit a4bf0f69c0

View file

@ -35,11 +35,21 @@ def list_artists(pg=None, search=None):
def play_artist(artist_id): def play_artist(artist_id):
tracks = get_tracks(artist=artist_id, include_channels=True) tracks = get_tracks(artist=artist_id, include_channels=True, pg=None)
tracks_results = tracks.get('results') tracks_next = tracks.get('next')
tracks_count = tracks.get('count')
storage = {} storage = {}
if tracks_count > 50:
print(f'Loading {tracks_count} tracks...')
while True:
tracks_results = tracks.get('results')
tracks_next = tracks.get('next')
for i in tracks_results: for i in tracks_results:
listen_url = concatinate_endpoint(i.get('listen_url')) listen_url = concatinate_endpoint(i.get('listen_url'))
storage[listen_url] = i storage[listen_url] = i
player.loadfile(listen_url, 'append-play') player.loadfile(listen_url, 'append-play')
if tracks_next:
tracks = get_tracks(artist=artist_id, include_channels=True, pg=tracks_next)
else:
break
player_menu("Artist playing...", storage) player_menu("Artist playing...", storage)