0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-27 06:03:52 +01:00

fix write_playlist

This commit is contained in:
Kuba
2025-10-13 20:12:00 +02:00
parent 544020b6d2
commit d2ae3fdb40

View File

@@ -10,7 +10,11 @@ class Module(PlayerModule):
def on_new_playlist(self, playlist: list[tuple[str, bool, bool, bool, dict]]): def on_new_playlist(self, playlist: list[tuple[str, bool, bool, bool, dict]]):
self.playlist = [t[0] for t in playlist] self.playlist = [t[0] for t in playlist]
def on_new_track(self, index: int, track: str, to_fade_in: bool, to_fade_out: bool, official: bool): def on_new_track(self, index: int, track: str, to_fade_in: bool, to_fade_out: bool, official: bool):
lines = self.playlist[:index] + [f"> {self.playlist[index]}"] + self.playlist[index+1:] if track != self.playlist[index]:
# discrepancy, which means that the playing file was modified by the active modifier
# we are playing a file that was not determined in the playlist, that means it was chosen by the active modifier and made up on the fly
lines = self.playlist[:index] + [self.playlist[index]] + [f"> {track}"] + self.playlist[index+1:]
else: lines = self.playlist[:index] + [f"> {self.playlist[index]}"] + self.playlist[index+1:]
with open("/tmp/radioPlayer_playlist", "w") as f: with open("/tmp/radioPlayer_playlist", "w") as f:
for line in lines: for line in lines:
try: f.write(line + "\n") try: f.write(line + "\n")