mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-23 23:19:21 +02:00
Compare commits
2 Commits
1d6e63e9e9
...
eaf293e519
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | eaf293e519 | ||
localhost_frssoft | 984d14515a |
|
@ -1,9 +1,10 @@
|
|||
from src.fw_api import get_tracks, get_audio_file
|
||||
from src.fw_api import get_tracks
|
||||
from src.fw_tags import list_tags
|
||||
from src.fw_libraries import libraries
|
||||
from src.mpv_control import player, player_menu, track_url_to_uuid, play_track
|
||||
from src.mpv_control import play_track
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
import time
|
||||
|
||||
fzf = FzfPrompt()
|
||||
|
||||
|
@ -11,11 +12,13 @@ fzf = FzfPrompt()
|
|||
@logger.catch
|
||||
def list_tracks(pg=None, search=None, tag=None, library=None):
|
||||
tracks = get_tracks(q=search, pg=pg, tag=tag, library=library)
|
||||
tracks_count = tracks.get('count')
|
||||
tracks_next = tracks.get('next')
|
||||
tracks_prev = tracks.get('previous')
|
||||
tracks_results = tracks.get('results')
|
||||
view = ['Search', 'Tags', 'Library', 'Play this page']
|
||||
if tracks_next:
|
||||
view.append('Play all pages')
|
||||
view.append('Next page')
|
||||
if tracks_prev:
|
||||
view.append('Prev page')
|
||||
|
@ -24,7 +27,7 @@ def list_tracks(pg=None, search=None, tag=None, library=None):
|
|||
index = tracks_results.index(i)
|
||||
track_name = i.get('title')
|
||||
view.append(f'{index}.{track_name}')
|
||||
select = fzf.prompt(view)
|
||||
select = fzf.prompt(view, f'--header=\'Found {tracks_count} tracks\'')
|
||||
if select == []:
|
||||
return
|
||||
else:
|
||||
|
@ -45,5 +48,19 @@ def list_tracks(pg=None, search=None, tag=None, library=None):
|
|||
elif select == 'Play this page':
|
||||
for i in tracks_results:
|
||||
play_track(track=i, multi=True)
|
||||
elif select == 'Play all pages':
|
||||
if tracks_count > 1000:
|
||||
yn = input('WARNING: you really want add more than 1000 tracks? (y/[n])\n').lower()
|
||||
if yn in ('', 'n'):
|
||||
return
|
||||
count_loaded = 0
|
||||
while tracks_count > count_loaded:
|
||||
for i in tracks_results:
|
||||
play_track(track=i, multi=True)
|
||||
count_loaded += 1
|
||||
time.sleep(0.2)
|
||||
tracks = get_tracks(pg=tracks_next)
|
||||
tracks_next = tracks.get('next')
|
||||
tracks_results = tracks.get('results')
|
||||
else:
|
||||
play_track(track=tracks_results[int(select)])
|
||||
|
|
Loading…
Reference in New Issue