Compare commits

...

2 Commits

Author SHA1 Message Date
billypom on debian
47ec08ec15 a 2025-04-08 08:42:04 -04:00
billypom on debian
304e770c69 i forgor 2025-04-08 08:40:55 -04:00
4 changed files with 25 additions and 4 deletions

View File

@ -2,6 +2,7 @@ from PyQt5.QtWidgets import (
QDialog,
QFrame,
QHBoxLayout,
QMessageBox,
QVBoxLayout,
QLabel,
QLineEdit,
@ -65,6 +66,15 @@ class MetadataWindow(QDialog):
# e.g., { "TIT2": ["song_title1", "song_title2"], ... }
for song in self.songs:
song_data = get_id3_tags(song[0])
if not song_data:
QMessageBox.error(
self,
"Error",
f"Could not retrieve ID3 tags for {song[0]}",
QMessageBox.Ok,
QMessageBox.Ok,
)
return
for tag in self.id3_tag_mapping:
try:
_ = tag_sets[tag]

View File

@ -118,7 +118,6 @@ class MusicTable(QTableView):
"TDRC",
None,
]
# db names of headers
self.database_columns = str(self.config["table"]["columns"]).split(",")
self.vertical_scroll_position = 0
@ -500,7 +499,7 @@ class MusicTable(QTableView):
try:
self.model2.removeRow(index)
except Exception as e:
debug(f" delete_songs() failed | {e}")
debug(f"delete_selected_row_indices() failed | {e}")
self.connect_data_changed()
self.load_music_table()

View File

@ -1,3 +1,4 @@
from PyQt5.QtWidgets import QMessageBox
import DBA
from logging import debug
from utils import get_id3_tags, convert_id3_timestamp_to_datetime
@ -31,6 +32,14 @@ def add_files_to_database(files, progress_callback=None):
progress_callback.emit(filepath)
filename = filepath.split("/")[-1]
audio = get_id3_tags(filepath)
if not audio:
QMessageBox.error(
"Error",
f"Could not retrieve ID3 tags for {filepath}",
QMessageBox.Ok,
QMessageBox.Ok,
)
return
try:
title = audio["TIT2"].text[0]

View File

@ -5,9 +5,12 @@ from mutagen.id3._frames import TIT2
from mutagen.id3._util import ID3NoHeaderError
def get_id3_tags(filename):
def get_id3_tags(filename: str):
"""Get the ID3 tags for an audio file"""
debug(filename)
# debug(filename)
if filename.endswith(".flac"):
return
try:
# Open the MP3 file and read its content