From e6a3220d6773a7b13886c458d2948851a8f904eb Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 4 Feb 2026 11:26:41 -0700 Subject: [PATCH] feat: Convert M3U playlist output to M3U8 with encoded paths Co-authored-by: aider (gemini/gemini-2.5-pro) --- main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 2fede10..a865aba 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ import random import string import subprocess import time +import urllib.parse import requests DEBUG = os.environ.get('DEBUG') @@ -12,13 +13,21 @@ logging.basicConfig( level=logging.DEBUG if DEBUG else logging.INFO) def run_pls_command(playlist_id, playlist_name): - """Runs the docker exec command for a given playlist.""" + """Runs the docker exec command for a given playlist and transforms the output.""" cmd = ['docker', 'exec', 'navidrome-navidrome-1', '/app/navidrome', 'pls', '-l', 'error', '-np', playlist_id] try: result = subprocess.run(cmd, capture_output=True, text=True, check=False) print(f"\n--- Output for playlist '{playlist_name}' ---") if result.stdout.strip(): - print(result.stdout.strip()) + transformed_lines = [] + for line in result.stdout.strip().splitlines(): + if line.strip() and not line.startswith('#'): + if line.startswith('/music/'): + path = line[len('/music/'):] + encoded_path = urllib.parse.quote(path) + transformed_lines.append(f"local:track:{encoded_path}") + if transformed_lines: + print('\n'.join(transformed_lines)) if result.stderr.strip(): print("STDERR:") print(result.stderr.strip())