editable lyrics USLT tag working
This commit is contained in:
parent
268c6a9289
commit
1391385493
@ -87,7 +87,11 @@ class MusicTable(QTableView):
|
||||
add_to_playlist_action = QAction("Add to playlist", self)
|
||||
add_to_playlist_action.triggered.connect(self.add_selected_files_to_playlist)
|
||||
menu.addAction(add_to_playlist_action)
|
||||
# lyrics
|
||||
# edit metadata
|
||||
edit_metadata_action = QAction("Edit metadata", self)
|
||||
edit_metadata_action.triggered.connect(self.edit_selected_files_metadata)
|
||||
menu.addAction(edit_metadata_action)
|
||||
# edit lyrics
|
||||
lyrics_menu = QAction("Lyrics (View/Edit)", self)
|
||||
lyrics_menu.triggered.connect(self.show_lyrics_menu)
|
||||
menu.addAction(lyrics_menu)
|
||||
@ -120,7 +124,10 @@ class MusicTable(QTableView):
|
||||
with DBA.DBAccess() as db:
|
||||
db.execute("DELETE FROM song WHERE filepath = ?", (file,))
|
||||
for index in selected_indices:
|
||||
model.removeRow(index)
|
||||
try:
|
||||
model.removeRow(index)
|
||||
except Exception as e:
|
||||
logging.info(f"MusicTable.py delete_songs() failed | {e}")
|
||||
self.fetch_library()
|
||||
|
||||
def open_directory(self):
|
||||
@ -139,6 +146,9 @@ class MusicTable(QTableView):
|
||||
path = "/".join(filepath)
|
||||
Popen(["xdg-open", path])
|
||||
|
||||
def edit_selected_files_metadata(self):
|
||||
files = self.get_selected_songs_filepaths()
|
||||
|
||||
def add_selected_files_to_playlist(self):
|
||||
"""Opens a playlist choice menu and adds the currently selected files to the chosen playlist"""
|
||||
playlist_dict = {}
|
||||
@ -157,6 +167,7 @@ class MusicTable(QTableView):
|
||||
current_song = self.get_selected_song_metadata()
|
||||
# print(f"MusicTable.py | show_lyrics_menu | current song: {current_song}")
|
||||
try:
|
||||
# Have to use USLT::XXX to retrieve
|
||||
lyrics = current_song["USLT::XXX"].text
|
||||
except Exception as e:
|
||||
print(f"MusicTable.py | show_lyrics_menu | could not retrieve lyrics | {e}")
|
||||
|
||||
4
main.py
4
main.py
@ -1,8 +1,10 @@
|
||||
import os
|
||||
import configparser
|
||||
import sys
|
||||
import logging
|
||||
from subprocess import run
|
||||
import qdarktheme
|
||||
|
||||
from pyqtgraph import mkBrush
|
||||
from mutagen.id3 import ID3
|
||||
from mutagen.id3._frames import APIC
|
||||
@ -413,6 +415,8 @@ if __name__ == "__main__":
|
||||
for statement in lines.split(";"):
|
||||
print(f"executing [{statement}]")
|
||||
db.execute(statement, ())
|
||||
# logging setup
|
||||
logging.basicConfig(filename="musicpom.log", encoding="utf-8", level=logging.DEBUG)
|
||||
# Allow for dynamic imports of my custom classes and utilities
|
||||
project_root = os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.append(project_root)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from components.ErrorDialog import ErrorDialog
|
||||
from utils.handle_year_and_date_id3_tag import handle_year_and_date_id3_tag
|
||||
from mutagen.id3 import ID3
|
||||
@ -102,10 +103,13 @@ def set_id3_tag(filepath: str, tag_name: str, value: str):
|
||||
if tdat_tag:
|
||||
# update TDAT if we have it
|
||||
audio_file.add(tdat_tag)
|
||||
elif tag_name == "lyrics":
|
||||
elif tag_name == "lyrics" or tag_name == "USLT":
|
||||
try:
|
||||
audio = ID3(filepath)
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug(
|
||||
f"set_id3_tag.py set_id3_tag() ran into an exception: {e}"
|
||||
)
|
||||
audio = ID3()
|
||||
audio.delall("USLT")
|
||||
frame = USLT(encoding=3, text=value)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user