Strip playlist_index placeholder for single files

When building the output template for single-file downloads, remove any playlist-specific preamble (e.g. '%(playlist_index)s - ') from filename_part. Adds a regex-based substitution to clean up leftover playlist_index placeholders so single downloads don't get playlist-style prefixes in their filenames.
This commit is contained in:
oop7
2026-05-01 16:29:28 +03:00
parent abec69fb84
commit abef0d8a6d
+3
View File
@@ -330,6 +330,9 @@ class DownloadThread(QThread):
# Create output template with playlist subfolder
output_template: str = f"{base_path}/%(playlist_title)s/{filename_part}"
else:
# For single files, automatically ignore/remove playlist-specific preamble (like "%(playlist_index)s - ")
import re
filename_part = re.sub(r'%\(playlist_index[^)]*\)[a-zA-Z0-9]*\s*(?:[-_]\s*)?', '', filename_part)
output_template: str = f"{base_path}/{filename_part}"
cmd.extend(["-o", str(output_template)])