From 84e152cbb94fcb61d4808b31e2fe861d66a18063 Mon Sep 17 00:00:00 2001 From: KubaPro010 <132459354+KubaPro010@users.noreply.github.com> Date: Sat, 8 Nov 2025 15:09:33 +0100 Subject: [PATCH] move skip to playview and dump progrss to file --- modules/{cli_progress.py => progress.py} | 10 ++++------ modules/write_playlists.py | 6 +++++- 2 files changed, 9 insertions(+), 7 deletions(-) rename modules/{cli_progress.py => progress.py} (54%) diff --git a/modules/cli_progress.py b/modules/progress.py similarity index 54% rename from modules/cli_progress.py rename to modules/progress.py index 36bf400..716fd55 100644 --- a/modules/cli_progress.py +++ b/modules/progress.py @@ -1,5 +1,4 @@ -from . import PlayerModule, Track -import os +from . import PlayerModule, Track, Path def format_time(seconds) -> str: hours = int(seconds // 3600) @@ -10,9 +9,8 @@ def format_time(seconds) -> str: class Module(PlayerModule): def progress(self, index: int, track: Track, elapsed: float, total: float, real_total: float) -> None: if track.official: - print(f"{track.path.name}: {format_time(elapsed)} / {format_time(total)}", end="\r", flush=True) - if os.path.exists("/tmp/radioPlayer_skip"): - self._imc.send(self, "procman", {"op": 2}) - os.remove("/tmp/radioPlayer_skip") + data = f"{track.path.name}: {format_time(elapsed)} / {format_time(total)}" + # print(data, end="\r", flush=True) + Path("/tmp/radioPlayer_progress").write_text(data) module = Module() \ No newline at end of file diff --git a/modules/write_playlists.py b/modules/write_playlists.py index 7d6ff20..1447bde 100644 --- a/modules/write_playlists.py +++ b/modules/write_playlists.py @@ -1,4 +1,5 @@ -from . import PlayerModule, log95, Track, Path +from . import PlayerModule, log95, Track +import os logger = log95.log95("PlayView") @@ -8,6 +9,9 @@ class Module(PlayerModule): def on_new_playlist(self, playlist: list[Track]): self.playlist = [str(t.path.absolute()) for t in playlist] def on_new_track(self, index: int, track: Track, next_track: Track | None): + if os.path.exists("/tmp/radioPlayer_skip"): + self._imc.send(self, "procman", {"op": 2}) + os.remove("/tmp/radioPlayer_skip") if next_track: logger.info("Next up:", next_track.path.name) if str(track.path) != self.playlist[index]: # discrepancy, which means that the playing file was modified by the active modifier