i forgor
This commit is contained in:
parent
b533b39f0c
commit
304e770c69
@ -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]
|
||||
|
||||
@ -120,7 +120,7 @@ class MusicTable(QTableView):
|
||||
]
|
||||
#
|
||||
# hide the id column
|
||||
self.hideColumn(0)
|
||||
# self.hideColumn(0)
|
||||
# db names of headers
|
||||
self.database_columns = str(self.config["table"]["columns"]).split(",")
|
||||
self.vertical_scroll_position = 0
|
||||
@ -508,7 +508,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()
|
||||
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user