lyrics
This commit is contained in:
parent
a78b5c1a51
commit
fb2a512401
@ -15,7 +15,7 @@ class LyricsWindow(QDialog):
|
|||||||
self.setWindowTitle("Lyrics")
|
self.setWindowTitle("Lyrics")
|
||||||
self.lyrics = lyrics
|
self.lyrics = lyrics
|
||||||
self.song_filepath = song_filepath
|
self.song_filepath = song_filepath
|
||||||
self.input_field = ""
|
self.input_field = "empty"
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
# label = QLabel("Lyrics")
|
# label = QLabel("Lyrics")
|
||||||
# layout.addWidget(label)
|
# layout.addWidget(label)
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
import logging
|
|
||||||
from components.ErrorDialog import ErrorDialog
|
from components.ErrorDialog import ErrorDialog
|
||||||
from utils.get_id3_tags import get_id3_tags
|
from utils.get_id3_tags import get_id3_tags
|
||||||
from utils.handle_year_and_date_id3_tag import handle_year_and_date_id3_tag
|
from utils.handle_year_and_date_id3_tag import handle_year_and_date_id3_tag
|
||||||
from mutagen.id3 import ID3, ID3NoHeaderError, Frame
|
from mutagen.id3 import ID3
|
||||||
|
from mutagen.id3._util import ID3NoHeaderError
|
||||||
from mutagen.mp3 import MP3
|
from mutagen.mp3 import MP3
|
||||||
from mutagen.easyid3 import EasyID3
|
from mutagen.easyid3 import EasyID3
|
||||||
from mutagen.id3 import (
|
from mutagen.id3._frames import (
|
||||||
|
Frame,
|
||||||
TIT2,
|
TIT2,
|
||||||
TPE1,
|
TPE1,
|
||||||
TALB,
|
TALB,
|
||||||
TRCK,
|
TRCK,
|
||||||
TYER,
|
# TYER,
|
||||||
TCON,
|
TCON,
|
||||||
TPOS,
|
TPOS,
|
||||||
COMM,
|
COMM,
|
||||||
@ -25,7 +26,7 @@ from mutagen.id3 import (
|
|||||||
TENC,
|
TENC,
|
||||||
TBPM,
|
TBPM,
|
||||||
TKEY,
|
TKEY,
|
||||||
TDAT,
|
# TDAT,
|
||||||
TIME,
|
TIME,
|
||||||
TSSE,
|
TSSE,
|
||||||
TOPE,
|
TOPE,
|
||||||
@ -106,8 +107,10 @@ def set_id3_tag(filepath: str, tag_name: str, value: str):
|
|||||||
# update TDAT if we have it
|
# update TDAT if we have it
|
||||||
audio_file.tags.add(tdat_tag)
|
audio_file.tags.add(tdat_tag)
|
||||||
elif tag_name == "lyrics":
|
elif tag_name == "lyrics":
|
||||||
print("lyrics..........")
|
audio = ID3(filepath)
|
||||||
audio_file.tags.add(USLT(encoding=3, lang="eng", desc="desc", text=value))
|
frame = USLT(encoding=3, lang="eng", desc="desc", text=value)
|
||||||
|
audio.add(frame)
|
||||||
|
audio.save()
|
||||||
elif tag_name in id3_tag_mapping: # Tag accounted for
|
elif tag_name in id3_tag_mapping: # Tag accounted for
|
||||||
tag_class = id3_tag_mapping[tag_name]
|
tag_class = id3_tag_mapping[tag_name]
|
||||||
print(f"set_id3_tag.py | tag_class: {tag_class}")
|
print(f"set_id3_tag.py | tag_class: {tag_class}")
|
||||||
@ -121,17 +124,15 @@ def set_id3_tag(filepath: str, tag_name: str, value: str):
|
|||||||
# return False
|
# return False
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# dialog = ErrorDialog(f'Invalid ID3 tag. Tag: {tag_name}, Value:{value}')
|
# dialog = ErrorDialog(f"Invalid ID3 tag. Tag: {tag_name}, Value:{value}")
|
||||||
# dialog.exec_()
|
# dialog.exec_()
|
||||||
# return False
|
# return False
|
||||||
pass
|
pass
|
||||||
|
audio_file.save(v2_version=3)
|
||||||
audio_file.save()
|
|
||||||
print("set_id3_tag.py | ID3 tags updated:")
|
print("set_id3_tag.py | ID3 tags updated:")
|
||||||
print(get_id3_tags(filepath))
|
print(get_id3_tags(filepath))
|
||||||
print("set_id3_tag.py | -----")
|
print("set_id3_tag.py | -----")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
dialog = ErrorDialog(f"An unhandled exception occurred:\n{e}")
|
dialog = ErrorDialog(f"An unhandled exception occurred:\n{e}")
|
||||||
dialog.exec_()
|
dialog.exec_()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user