2021-01-31 16:59:15 +00:00
|
|
|
class Lyrics:
|
2021-04-10 09:53:52 +00:00
|
|
|
def __init__(self, lyr_id="0"):
|
|
|
|
self.id = lyr_id
|
2021-03-13 10:54:01 +00:00
|
|
|
self.sync = ""
|
|
|
|
self.unsync = ""
|
|
|
|
self.syncID3 = []
|
2021-01-31 16:59:15 +00:00
|
|
|
|
|
|
|
def parseLyrics(self, lyricsAPI):
|
|
|
|
self.unsync = lyricsAPI.get("LYRICS_TEXT")
|
|
|
|
if "LYRICS_SYNC_JSON" in lyricsAPI:
|
|
|
|
syncLyricsJson = lyricsAPI["LYRICS_SYNC_JSON"]
|
|
|
|
timestamp = ""
|
|
|
|
milliseconds = 0
|
2021-04-10 09:53:52 +00:00
|
|
|
for line in enumerate(syncLyricsJson):
|
2021-01-31 16:59:15 +00:00
|
|
|
if syncLyricsJson[line]["line"] != "":
|
|
|
|
timestamp = syncLyricsJson[line]["lrc_timestamp"]
|
|
|
|
milliseconds = int(syncLyricsJson[line]["milliseconds"])
|
|
|
|
self.syncID3.append((syncLyricsJson[line]["line"], milliseconds))
|
|
|
|
else:
|
|
|
|
notEmptyLine = line + 1
|
|
|
|
while syncLyricsJson[notEmptyLine]["line"] == "":
|
|
|
|
notEmptyLine = notEmptyLine + 1
|
|
|
|
timestamp = syncLyricsJson[notEmptyLine]["lrc_timestamp"]
|
|
|
|
self.sync += timestamp + syncLyricsJson[line]["line"] + "\r\n"
|