feat: enhance ID3 tagging by adding support for additional frames and improving cover art handling
This commit is contained in:
1 parent
806f2c6f85
commit
56bf8aa3d1
1 file changed
+16
-17
@@ -21,7 +21,7 @@ if sys.stderr is None:
|
||||
|
||||
try:
|
||||
from mutagen.easyid3 import EasyID3
|
||||
from mutagen.id3 import ID3, APIC
|
||||
from mutagen.id3 import ID3, APIC, TIT2, TPE1, TPE2, TALB, TRCK, TDRC
|
||||
except ImportError:
|
||||
messagebox.showerror("Fehler", "Die Bibliothek 'mutagen' ist nicht installiert. Bitte installieren Sie sie mit 'pip install mutagen'.")
|
||||
exit()
|
||||
@@ -573,25 +573,24 @@ def convert_file(entry, index, export_dir, meta, use_subdirs, ffmpeg_path, ffpro
|
||||
if process.returncode != 0:
|
||||
raise subprocess.CalledProcessError(process.returncode, cmd)
|
||||
|
||||
audiofile = EasyID3(mp3_path)
|
||||
audiofile["title"] = title
|
||||
audiofile["artist"] = meta.get("artist") or "Unbekannt"
|
||||
audiofile["albumartist"] = meta.get("artist") or "Unbekannt"
|
||||
audiofile["album"] = meta.get("album") or "Unbekanntes Album"
|
||||
audiofile["tracknumber"] = str(index + 1)
|
||||
audiofile["date"] = meta.get("year", "")
|
||||
audiofile.save()
|
||||
artist = meta.get("artist") or "Unbekannt"
|
||||
album = meta.get("album") or "Unbekanntes Album"
|
||||
audiofile = ID3(mp3_path)
|
||||
audiofile["TIT2"] = TIT2(encoding=3, text=[title])
|
||||
audiofile["TPE1"] = TPE1(encoding=3, text=[artist])
|
||||
audiofile["TPE2"] = TPE2(encoding=3, text=[artist])
|
||||
audiofile["TALB"] = TALB(encoding=3, text=[album])
|
||||
audiofile["TRCK"] = TRCK(encoding=3, text=[str(index + 1)])
|
||||
audiofile["TDRC"] = TDRC(encoding=3, text=[meta.get("year", "")])
|
||||
|
||||
cover_path = meta.get("cover")
|
||||
if cover_path and os.path.isfile(cover_path):
|
||||
try:
|
||||
mime = "image/png" if cover_path.lower().endswith(".png") else "image/jpeg"
|
||||
audiofile = ID3(mp3_path)
|
||||
with open(cover_path, "rb") as img:
|
||||
audiofile.add(APIC(encoding=3, mime=mime, type=3, desc="Cover", data=img.read()))
|
||||
audiofile.save()
|
||||
except Exception as e:
|
||||
print(f"Warnung: Cover konnte nicht eingebunden werden: {e}")
|
||||
mime = "image/png" if cover_path.lower().endswith(".png") else "image/jpeg"
|
||||
with open(cover_path, "rb") as img:
|
||||
audiofile.delall("APIC")
|
||||
audiofile.add(APIC(encoding=3, mime=mime, type=3, desc="Cover", data=img.read()))
|
||||
|
||||
audiofile.save(mp3_path, v2_version=3)
|
||||
|
||||
return (index, out_filename, None)
|
||||
except subprocess.CalledProcessError as e:
|
||||
|
||||
Reference in new issue
Block a user