Added support for embedded sync lyrics on MP3 with the SYLT tag
This commit is contained in:
parent
4de567dfcf
commit
e81adde17d
|
@ -1,3 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
__version__ = "1.2.21"
|
||||
__version__ = "1.2.22"
|
||||
|
|
|
@ -84,6 +84,7 @@ class Settings:
|
|||
"replayGain": False,
|
||||
"label": True,
|
||||
"lyrics": False,
|
||||
"syncedLyrics": False,
|
||||
"copyright": False,
|
||||
"composer": False,
|
||||
"involvedPeople": False,
|
||||
|
|
|
@ -154,7 +154,8 @@ class Track:
|
|||
self.lyrics = {
|
||||
'id': trackAPI_gw.get('LYRICS_ID'),
|
||||
'unsync': None,
|
||||
'sync': None
|
||||
'sync': None,
|
||||
'syncID3': None
|
||||
}
|
||||
if not "LYRICS" in trackAPI_gw and int(self.lyrics['id']) != 0:
|
||||
logger.info(f"[{trackAPI_gw['ART_NAME']} - {self.title}] Getting lyrics")
|
||||
|
@ -163,14 +164,19 @@ class Track:
|
|||
self.lyrics['unsync'] = trackAPI_gw["LYRICS"].get("LYRICS_TEXT")
|
||||
if "LYRICS_SYNC_JSON" in trackAPI_gw["LYRICS"]:
|
||||
self.lyrics['sync'] = ""
|
||||
self.lyrics['syncID3'] = []
|
||||
lastTimestamp = ""
|
||||
lastMilliseconds = 0
|
||||
for i in range(len(trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"])):
|
||||
if "lrc_timestamp" in trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]:
|
||||
self.lyrics['sync'] += trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["lrc_timestamp"]
|
||||
lastTimestamp = trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["lrc_timestamp"]
|
||||
else:
|
||||
self.lyrics['sync'] += lastTimestamp
|
||||
if "milliseconds" in trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]:
|
||||
lastMilliseconds = int(trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["milliseconds"])
|
||||
self.lyrics['sync'] += trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["line"] + "\r\n"
|
||||
self.lyrics['syncID3'].append((trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["line"], lastMilliseconds))
|
||||
|
||||
self.mainArtist = {
|
||||
'id': trackAPI_gw['ART_ID'],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
from mutagen.flac import FLAC, Picture
|
||||
from mutagen.id3 import ID3, ID3NoHeaderError, TXXX, TIT2, TPE1, TALB, TPE2, TRCK, TPOS, TCON, TYER, TDAT, TLEN, TBPM, \
|
||||
TPUB, TSRC, USLT, APIC, IPLS, TCOM, TCOP, TCMP
|
||||
TPUB, TSRC, USLT, SYLT, APIC, IPLS, TCOM, TCOP, TCMP
|
||||
|
||||
# Adds tags to a MP3 file
|
||||
def tagID3(stream, track, save):
|
||||
|
@ -62,6 +62,8 @@ def tagID3(stream, track, save):
|
|||
tag.add(TXXX(desc="REPLAYGAIN_TRACK_GAIN", text=track.replayGain))
|
||||
if track.lyrics['unsync'] and save['lyrics']:
|
||||
tag.add(USLT(text=track.lyrics['unsync']))
|
||||
if track.lyrics['syncID3'] and save['syncedLyrics']:
|
||||
tag.add(SYLT(3, format=2, type=1, text=track.lyrics['syncID3']))
|
||||
|
||||
involved_people = []
|
||||
for role in track.contributors:
|
||||
|
|
Loading…
Reference in New Issue