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):
tracks = get_tracks(artist=artist_id, include_channels=True)
tracks_results = tracks.get('results')
tracks = get_tracks(artist=artist_id, include_channels=True, pg=None)
tracks_next = tracks.get('next')
tracks_count = tracks.get('count')
storage = {}
for i in tracks_results:
listen_url = concatinate_endpoint(i.get('listen_url'))
storage[listen_url] = i
player.loadfile(listen_url, 'append-play')
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:
listen_url = concatinate_endpoint(i.get('listen_url'))
storage[listen_url] = i
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)