Fix enhanced view reorganize not moving sidecars, add template debug logging
Enhanced album reorganize now moves LRC, cover.jpg, folder.jpg and other sidecar files alongside audio files. Added debug log to library reorganize repair job showing which template is loaded from config vs default.
This commit is contained in:
parent
f247841665
commit
01b0b70515
2 changed files with 28 additions and 0 deletions
|
|
@ -284,6 +284,7 @@ class LibraryReorganizeJob(RepairJob):
|
|||
album_template = templates.get('album_path', '$albumartist/$albumartist - $album/$track - $title')
|
||||
single_template = templates.get('single_path', '$artist/$artist - $title/$title')
|
||||
disc_label = cm.get('file_organization.disc_label', 'Disc')
|
||||
logger.info(f"Library Reorganize templates — album: '{album_template}', single: '{single_template}' (raw config: {templates})")
|
||||
|
||||
dry_run = self._get_setting(context, 'dry_run', True)
|
||||
move_sidecars = self._get_setting(context, 'move_sidecars', True)
|
||||
|
|
|
|||
|
|
@ -11213,6 +11213,33 @@ def reorganize_album_files(album_id):
|
|||
# Move file
|
||||
_safe_move_file(resolved, new_full)
|
||||
|
||||
# Move sidecar files (LRC, cover.jpg, etc.)
|
||||
src_dir = os.path.dirname(resolved)
|
||||
dest_dir = os.path.dirname(new_full)
|
||||
src_stem = os.path.splitext(os.path.basename(resolved))[0]
|
||||
new_stem = os.path.splitext(os.path.basename(new_full))[0]
|
||||
|
||||
# Track-level sidecars (same filename stem as audio)
|
||||
for sidecar_ext in ('.lrc', '.nfo', '.txt', '.cue'):
|
||||
sidecar_src = os.path.join(src_dir, src_stem + sidecar_ext)
|
||||
if os.path.isfile(sidecar_src):
|
||||
sidecar_dst = os.path.join(dest_dir, new_stem + sidecar_ext)
|
||||
try:
|
||||
shutil.move(sidecar_src, sidecar_dst)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Album-level sidecars (cover art, folder images)
|
||||
for album_sidecar in ('cover.jpg', 'cover.jpeg', 'cover.png', 'folder.jpg', 'folder.png', 'front.jpg', 'front.png', 'album.jpg', 'album.png'):
|
||||
sidecar_src = os.path.join(src_dir, album_sidecar)
|
||||
if os.path.isfile(sidecar_src):
|
||||
sidecar_dst = os.path.join(dest_dir, album_sidecar)
|
||||
if not os.path.exists(sidecar_dst):
|
||||
try:
|
||||
shutil.move(sidecar_src, sidecar_dst)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Update DB file_path
|
||||
bg_cursor = bg_conn.cursor()
|
||||
bg_cursor.execute(
|
||||
|
|
|
|||
Loading…
Reference in a new issue