Compare commits
2 Commits
08dec4d5ed
...
47ec08ec15
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47ec08ec15 | ||
|
|
304e770c69 |
@ -2,6 +2,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QDialog,
|
QDialog,
|
||||||
QFrame,
|
QFrame,
|
||||||
QHBoxLayout,
|
QHBoxLayout,
|
||||||
|
QMessageBox,
|
||||||
QVBoxLayout,
|
QVBoxLayout,
|
||||||
QLabel,
|
QLabel,
|
||||||
QLineEdit,
|
QLineEdit,
|
||||||
@ -65,6 +66,15 @@ class MetadataWindow(QDialog):
|
|||||||
# e.g., { "TIT2": ["song_title1", "song_title2"], ... }
|
# e.g., { "TIT2": ["song_title1", "song_title2"], ... }
|
||||||
for song in self.songs:
|
for song in self.songs:
|
||||||
song_data = get_id3_tags(song[0])
|
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:
|
for tag in self.id3_tag_mapping:
|
||||||
try:
|
try:
|
||||||
_ = tag_sets[tag]
|
_ = tag_sets[tag]
|
||||||
|
|||||||
@ -118,7 +118,6 @@ class MusicTable(QTableView):
|
|||||||
"TDRC",
|
"TDRC",
|
||||||
None,
|
None,
|
||||||
]
|
]
|
||||||
|
|
||||||
# db names of headers
|
# db names of headers
|
||||||
self.database_columns = str(self.config["table"]["columns"]).split(",")
|
self.database_columns = str(self.config["table"]["columns"]).split(",")
|
||||||
self.vertical_scroll_position = 0
|
self.vertical_scroll_position = 0
|
||||||
@ -500,7 +499,7 @@ class MusicTable(QTableView):
|
|||||||
try:
|
try:
|
||||||
self.model2.removeRow(index)
|
self.model2.removeRow(index)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug(f" delete_songs() failed | {e}")
|
debug(f"delete_selected_row_indices() failed | {e}")
|
||||||
self.connect_data_changed()
|
self.connect_data_changed()
|
||||||
self.load_music_table()
|
self.load_music_table()
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
from PyQt5.QtWidgets import QMessageBox
|
||||||
import DBA
|
import DBA
|
||||||
from logging import debug
|
from logging import debug
|
||||||
from utils import get_id3_tags, convert_id3_timestamp_to_datetime
|
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)
|
progress_callback.emit(filepath)
|
||||||
filename = filepath.split("/")[-1]
|
filename = filepath.split("/")[-1]
|
||||||
audio = get_id3_tags(filepath)
|
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:
|
try:
|
||||||
title = audio["TIT2"].text[0]
|
title = audio["TIT2"].text[0]
|
||||||
|
|||||||
@ -5,9 +5,12 @@ from mutagen.id3._frames import TIT2
|
|||||||
from mutagen.id3._util import ID3NoHeaderError
|
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"""
|
"""Get the ID3 tags for an audio file"""
|
||||||
debug(filename)
|
# debug(filename)
|
||||||
|
|
||||||
|
if filename.endswith(".flac"):
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Open the MP3 file and read its content
|
# Open the MP3 file and read its content
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user