From 8850dbb982545e900d93c8264d7b9d7798612598 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Thu, 2 Oct 2025 13:26:59 +0200 Subject: [PATCH] you can now import playlists into playlists --- radioPlayer.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/radioPlayer.py b/radioPlayer.py index 9bc4af6..608fc06 100644 --- a/radioPlayer.py +++ b/radioPlayer.py @@ -237,13 +237,26 @@ def play_playlist(playlist_path, custom_playlist: bool=False, do_shuffle=True): time.sleep(15) return + def check_for_imports(lines: list[str], seen=None) -> list[str]: + if seen is None: seen = set() + out = [] + for line in lines: + if line.startswith("@"): + target = line.removeprefix("@") + if target not in seen: + seen.add(target) + sub_lines = load_filelines(target) + out.extend(check_for_imports(sub_lines, seen)) + else: out.append(line) + return out + lines = check_for_imports(lines) + glob_lines = [] for line in lines: if line.startswith(";") or not line.strip(): continue glob_lines.extend([f for f in glob.glob(line) if os.path.isfile(f)]) - if do_shuffle: - random.shuffle(glob_lines) + if do_shuffle: random.shuffle(glob_lines) playlist: list[tuple[str, bool, bool, bool]] = [] # name, fade in, fade out, official last_jingiel = True