feat: enhance duplicate prevention to support FLAC, M4A, WAV, OPUS, OGG, and strip track numbers
Build and Push Docker Images / build (api) (push) Successful in 2m10s
Details
Build and Push Docker Images / build (musicseerr) (push) Successful in 9m45s
Details
Build and Push Docker Images / build (web) (push) Successful in 4m1s
Details
Build and Push Docker Images / build (nextgen) (push) Successful in 16m1s
Details
Build and Push Docker Images / build (worker) (push) Successful in 13m6s
Details
Build and Push Docker Images / deploy (push) Successful in 51s
Details
Build and Push Docker Images / build (api) (push) Successful in 2m10s
Details
Build and Push Docker Images / build (musicseerr) (push) Successful in 9m45s
Details
Build and Push Docker Images / build (web) (push) Successful in 4m1s
Details
Build and Push Docker Images / build (nextgen) (push) Successful in 16m1s
Details
Build and Push Docker Images / build (worker) (push) Successful in 13m6s
Details
Build and Push Docker Images / deploy (push) Successful in 51s
Details
This commit is contained in:
parent
4e42ad4705
commit
00c7498859
|
|
@ -229,8 +229,8 @@ def send_telegram_notification(chat_id: int, text: str):
|
||||||
|
|
||||||
def symlink_existing_tracks(temp_dir: str):
|
def symlink_existing_tracks(temp_dir: str):
|
||||||
"""
|
"""
|
||||||
Finds all MP3 files recursively in /remote-music/music and creates symlinks to them
|
Finds all audio files recursively in /remote-music/music, extracts artist and title,
|
||||||
in the temp_dir so spotDL and yt-dlp skip downloading duplicates.
|
and creates symlinks named "Artist - Title.mp3" in temp_dir so spotDL skips them.
|
||||||
"""
|
"""
|
||||||
remote_base = "/remote-music/music"
|
remote_base = "/remote-music/music"
|
||||||
if not os.path.isdir(remote_base):
|
if not os.path.isdir(remote_base):
|
||||||
|
|
@ -240,15 +240,39 @@ def symlink_existing_tracks(temp_dir: str):
|
||||||
count = 0
|
count = 0
|
||||||
for root, dirs, files in os.walk(remote_base):
|
for root, dirs, files in os.walk(remote_base):
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith(".mp3"):
|
if file.lower().endswith((".mp3", ".flac", ".m4a", ".ogg", ".wav", ".opus")):
|
||||||
src_path = os.path.join(root, file)
|
# Try to clean/extract artist and title
|
||||||
dest_path = os.path.join(temp_dir, file)
|
base_name = os.path.splitext(file)[0]
|
||||||
|
|
||||||
|
# Strip leading numbers like "01. ", "01 - ", etc.
|
||||||
|
cleaned = re.sub(r'^\d+[\s.-]+', '', base_name).strip()
|
||||||
|
|
||||||
|
# We expect the file to have a " - " separator
|
||||||
|
if " - " in cleaned:
|
||||||
|
parts = cleaned.split(" - ", 1)
|
||||||
|
artist = parts[0].strip()
|
||||||
|
title = parts[1].strip()
|
||||||
|
|
||||||
|
# Target filename that spotDL expects
|
||||||
|
target_name = f"{artist} - {title}.mp3"
|
||||||
|
else:
|
||||||
|
# Fallback to direct name with .mp3 extension
|
||||||
|
target_name = f"{cleaned}.mp3"
|
||||||
|
|
||||||
|
# Replaces invalid chars
|
||||||
|
target_name = "".join([c for c in target_name if c.isalnum() or c in " .-_()"]).strip()
|
||||||
|
if not target_name.endswith(".mp3"):
|
||||||
|
target_name += ".mp3"
|
||||||
|
|
||||||
|
dest_path = os.path.join(temp_dir, target_name)
|
||||||
if not os.path.exists(dest_path):
|
if not os.path.exists(dest_path):
|
||||||
try:
|
try:
|
||||||
|
src_path = os.path.join(root, file)
|
||||||
os.symlink(src_path, dest_path)
|
os.symlink(src_path, dest_path)
|
||||||
count += 1
|
count += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to create symlink for {file}: {e}")
|
logger.warning(f"Failed to create symlink for {file} -> {target_name}: {e}")
|
||||||
|
|
||||||
logger.info(f"Created {count} symlinks for existing tracks.")
|
logger.info(f"Created {count} symlinks for existing tracks.")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue