Add "Play all pages" in tracks menu

This commit is contained in:
localhost_frssoft 2023-07-11 01:16:58 +03:00
parent 984d14515a
commit eaf293e519

View File

@ -4,6 +4,7 @@ from src.fw_libraries import libraries
from src.mpv_control import play_track
from pyfzf.pyfzf import FzfPrompt
from loguru import logger
import time
fzf = FzfPrompt()
@ -17,6 +18,7 @@ def list_tracks(pg=None, search=None, tag=None, library=None):
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')
@ -46,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)])