From 4e5e828d9642b128c4048da9d726618a394fc4b4 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Mon, 29 Sep 2025 18:05:39 +0200 Subject: [PATCH] since the player now parses the main files, we don't need to add every file one by one --- convert_folder.py | 26 ++++++++++++++++++++++++++ radioPlaylist.py | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 convert_folder.py diff --git a/convert_folder.py b/convert_folder.py new file mode 100644 index 0000000..10516f1 --- /dev/null +++ b/convert_folder.py @@ -0,0 +1,26 @@ +import os +import glob + +# Base directory where your playlists live +BASE_DIR = os.path.expanduser("~/playlists") +FORMATS = ('.mp3', '.m4a', '.flac', '.wav') + +# Collect all playlist files (recursively all subfolders) +playlist_files = glob.glob(os.path.join(BASE_DIR, "*", "*")) + +for plist in playlist_files: + with open(plist, "r") as f: + lines = [line.strip() for line in f if line.strip()] + + dirs = [] + files = [] + for line in lines: + dir = os.path.basename(os.path.dirname(line)) + if dir not in dirs and dir != "mixes": dirs.append(dir) + if dir == "mixes": files.append(line) + with open(plist, "w") as f: + f.writelines(files) + for dir in dirs: + base = f"/home/user/mixes/{dir}/*." + for format in FORMATS: + f.write(base + format) \ No newline at end of file diff --git a/radioPlaylist.py b/radioPlaylist.py index 49a1da7..f0c2914 100644 --- a/radioPlaylist.py +++ b/radioPlaylist.py @@ -92,9 +92,11 @@ class FileManager: if file.lower().endswith(FORMATS): audio_files.append(file) except (PermissionError, FileNotFoundError): continue + fake_files = [f"*.{i}" for i in FORMATS] + if audio_files: # Folder contains audio files - items.append(FileItem(name=entry, is_folder=True, files=sorted(audio_files))) + items.append(FileItem(name=entry, is_folder=True, files=fake_files)) return items except FileNotFoundError: