mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-15 03:33:01 +00:00
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from src.fw_api import get_tracks, get_audio_file
|
|
from src.fw_tags import list_tags
|
|
from src.mpv_control import player, player_menu, track_url_to_uuid, play_track
|
|
from pyfzf.pyfzf import FzfPrompt
|
|
from loguru import logger
|
|
|
|
fzf = FzfPrompt()
|
|
|
|
@logger.catch
|
|
def list_tracks(pg=None, search=None, tag=None):
|
|
tracks = get_tracks(q=search, pg=pg, tag=tag)
|
|
tracks_next = tracks.get('next')
|
|
tracks_prev = tracks.get('previous')
|
|
tracks_results = tracks.get('results')
|
|
view = ['Search', 'Tags', 'Play this page']
|
|
if tracks_next:
|
|
view.append('Next page')
|
|
if tracks_prev:
|
|
view.append('Prev page')
|
|
|
|
for i in tracks_results:
|
|
index = tracks_results.index(i)
|
|
track_name = i.get('title')
|
|
view.append(f'{index}.{track_name}')
|
|
select = fzf.prompt(view)[0].split('.', 1)[0]
|
|
if select == 'Next page':
|
|
list_tracks(pg=tracks_next)
|
|
elif select == 'Prev page':
|
|
list_tracks(pg=tracks_prev)
|
|
elif select == 'Search':
|
|
print('Search by track:')
|
|
list_tracks(search=input())
|
|
elif select == 'Tags':
|
|
select_tag = list_tags()
|
|
list_tracks(tag=select_tag)
|
|
elif select == 'Play this page':
|
|
for i in tracks_results:
|
|
play_track(track=i, multi=True)
|
|
else:
|
|
play_track(track=tracks_results[int(select)])
|
|
|