mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2025-07-11 04:04:14 +00:00
Add view artists and their albums
This commit is contained in:
parent
a1765500ed
commit
a654768958
4 changed files with 143 additions and 9 deletions
42
src/fw_artists.py
Normal file
42
src/fw_artists.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from src.fw_api import get_artists, get_tracks, concatinate_endpoint
|
||||
from src.fw_albums import list_albums
|
||||
from src.mpv_control import player, player_menu
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
|
||||
fzf = FzfPrompt()
|
||||
|
||||
@logger.catch
|
||||
def list_artists(pg=None):
|
||||
artists = get_artists(pg=pg)
|
||||
artists_next = artists.get('next')
|
||||
artists_prev = artists.get('previous')
|
||||
artists_results = artists.get('results')
|
||||
view = []
|
||||
if artists_next:
|
||||
view.append('Next page')
|
||||
if artists_prev:
|
||||
view.append('Prev page')
|
||||
|
||||
for i in artists_results:
|
||||
index = artists_results.index(i)
|
||||
artist_name = i.get('name')
|
||||
view.append(f'{index}.{artist_name}')
|
||||
select = fzf.prompt(view)[0].split('.', 1)[0]
|
||||
if select == 'Next page':
|
||||
list_artists(pg=artists_next)
|
||||
elif select == 'Prev page':
|
||||
list_artists(pg=artists_prev)
|
||||
else:
|
||||
list_albums(albums=artists_results[int(select)].get('albums'))
|
||||
|
||||
|
||||
def play_artist(artist_id):
|
||||
tracks = get_tracks(artist=artist_id)
|
||||
tracks_results = tracks.get('results')
|
||||
storage = {}
|
||||
for i in tracks_results:
|
||||
listen_url = concatinate_endpoint(i.get('listen_url'))
|
||||
storage[listen_url] = i
|
||||
player.loadfile(listen_url, 'append-play')
|
||||
player_menu("Artist playing...", storage)
|
Loading…
Add table
Add a link
Reference in a new issue