From eaf293e519a8f2534094f5a8820d5e326ac8e1c6 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Tue, 11 Jul 2023 01:16:58 +0300 Subject: [PATCH] Add "Play all pages" in tracks menu --- src/fw_tracks.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/fw_tracks.py b/src/fw_tracks.py index e94e2e4..090804f 100644 --- a/src/fw_tracks.py +++ b/src/fw_tracks.py @@ -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)])