fix: no one uses artist/album/track.ext layout
This commit is contained in:
@@ -60,22 +60,35 @@ class FileNameEnricher(BaseEnricher):
|
|||||||
# Left was only a track number → right is the title
|
# Left was only a track number → right is the title
|
||||||
if not track.title:
|
if not track.title:
|
||||||
updates["title"] = right
|
updates["title"] = right
|
||||||
|
|
||||||
|
# Try "Artist-Title" split (no spaces)
|
||||||
|
elif "-" in stem:
|
||||||
|
left, right = stem.split("-", 1)
|
||||||
|
left = _TRACK_NUM_RE.sub("", left).strip()
|
||||||
|
right = right.strip()
|
||||||
|
|
||||||
|
if left and right:
|
||||||
|
if not track.artist:
|
||||||
|
updates["artist"] = left
|
||||||
|
if not track.title:
|
||||||
|
updates["title"] = right
|
||||||
|
elif right:
|
||||||
|
if not track.title:
|
||||||
|
updates["title"] = right
|
||||||
|
|
||||||
|
# No separator: strip track number, remainder is title
|
||||||
else:
|
else:
|
||||||
# No separator: strip track number, remainder is title
|
|
||||||
title_guess = _TRACK_NUM_RE.sub("", stem).strip()
|
title_guess = _TRACK_NUM_RE.sub("", stem).strip()
|
||||||
if title_guess and not track.title:
|
if title_guess and not track.title:
|
||||||
updates["title"] = title_guess
|
updates["title"] = title_guess
|
||||||
|
|
||||||
# Use parent directory as artist fallback
|
# Use parent directory as album fallback
|
||||||
# Typical layout: /Music/Artist/Album/01 - Track.flac
|
if not track.album and "album" not in updates:
|
||||||
if not track.artist and "artist" not in updates:
|
|
||||||
parents = audio_path.parents
|
parents = audio_path.parents
|
||||||
if len(parents) >= 2:
|
if len(parents) >= 1:
|
||||||
album_dir = parents[0].name
|
album_dir = parents[0].name
|
||||||
artist_dir = parents[1].name
|
if album_dir and album_dir not in (".", "/"):
|
||||||
if artist_dir and artist_dir not in (".", "/"):
|
if not track.album:
|
||||||
updates["artist"] = artist_dir
|
|
||||||
if not track.album and album_dir and album_dir != artist_dir:
|
|
||||||
updates["album"] = album_dir
|
updates["album"] = album_dir
|
||||||
|
|
||||||
if updates:
|
if updates:
|
||||||
|
|||||||
Reference in New Issue
Block a user