From d76bd67311b40d492b747499bdec6a718b378b5c Mon Sep 17 00:00:00 2001 From: "billy@pom" Date: Sun, 1 Mar 2026 21:56:42 -0500 Subject: [PATCH] yea --- components/LyricsWindow.py | 2 +- components/MetadataWindow.py | 4 +++- utils/set_tag.py | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/components/LyricsWindow.py b/components/LyricsWindow.py index 979d9e3..0065c1f 100644 --- a/components/LyricsWindow.py +++ b/components/LyricsWindow.py @@ -42,7 +42,7 @@ class LyricsWindow(QDialog): """Saves the current lyrics text to the USLT/lyrics ID3 tag""" success = set_tag( filepath=self.song_filepath, - tag_name="lyrics", + db_column="lyrics", value=self.input_field.toPlainText(), ) if success: diff --git a/components/MetadataWindow.py b/components/MetadataWindow.py index 18fd7ee..0b03bfa 100644 --- a/components/MetadataWindow.py +++ b/components/MetadataWindow.py @@ -130,7 +130,9 @@ class MetadataWindow(QDialog): # Update the ID3 tag if the tag is not blank, # and has been edited success = set_tag( - filepath=song[0], db_column=tag, value=field.text() + filepath=song[0], + db_column=self.headers.frame_id[tag].db, + value=field.text(), ) if success: update_song_in_database( diff --git a/utils/set_tag.py b/utils/set_tag.py index ebfe230..bf64392 100644 --- a/utils/set_tag.py +++ b/utils/set_tag.py @@ -5,20 +5,21 @@ from mutagen.id3 import ID3 from mutagen.id3._util import ID3NoHeaderError from mutagen.id3._frames import USLT, Frame -def set_tag(filepath: str, tag_name: str, value: str): + +def set_tag(filepath: str, db_column: str, value: str): """ - Sets the ID3 tag for a file given a filepath, tag_name, and a value for the tag + Sets the ID3 tag for a file given a filepath, db_column, and a value for the tag Args: filepath: path to the mp3 file - tag_name: db column name of the ID3 tag + db_column: db column name of the ID3 tag value: value to set for the tag Returns: True / False """ headers = HeaderTags2() - debug(f"filepath: {filepath} | tag_name: {tag_name} | value: {value}") + debug(f"filepath: {filepath} | db_column: {db_column} | value: {value}") try: try: # Load existing tags @@ -26,7 +27,7 @@ def set_tag(filepath: str, tag_name: str, value: str): except ID3NoHeaderError: # Create new tags if none exist audio_file = ID3() # Lyrics get handled differently - if tag_name == "lyrics": + if db_column == "lyrics": try: audio = ID3(filepath) except Exception as e: @@ -38,14 +39,14 @@ def set_tag(filepath: str, tag_name: str, value: str): audio.save() return True # DB Tag into Mutagen Frame Class - if tag_name in headers.db: - frame_class = headers.db[tag_name].frame_class - assert frame_class is not None # ooo scary + if db_column in headers.db: + frame_class = headers.db[db_column].frame_class + assert frame_class is not None # ooo scary if issubclass(frame_class, Frame): frame = frame_class(encoding=3, text=[value]) audio_file.add(frame) else: - warning(f'Tag "{tag_name}" not found - ID3 tag update skipped') + warning(f'Tag "{db_column}" not found - ID3 tag update skipped') audio_file.save(filepath) return True except Exception as e: