From 09331516c7e96099cb9bb15646a95cb5502c5dbd Mon Sep 17 00:00:00 2001 From: RemixDev Date: Tue, 22 Sep 2020 11:32:07 +0200 Subject: [PATCH] Fixed sync lyrics timing --- deemix/__init__.py | 2 +- deemix/app/track.py | 22 ++++++++++++---------- setup.py | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/deemix/__init__.py b/deemix/__init__.py index 314405e..39c6b89 100644 --- a/deemix/__init__.py +++ b/deemix/__init__.py @@ -1,3 +1,3 @@ #!/usr/bin/env python3 -__version__ = "1.4.1" +__version__ = "1.4.2" diff --git a/deemix/app/track.py b/deemix/app/track.py index d85a423..9f4f495 100644 --- a/deemix/app/track.py +++ b/deemix/app/track.py @@ -164,18 +164,20 @@ class Track: if "LYRICS_SYNC_JSON" in trackAPI_gw["LYRICS"]: self.lyrics['sync'] = "" self.lyrics['syncID3'] = [] - lastTimestamp = "" - lastMilliseconds = 0 + timestamp = "" + milliseconds = 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"] + if trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["line"] != "": + timestamp = trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["lrc_timestamp"] + milliseconds = int(trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["milliseconds"]) 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)) + j=i+1 + while trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][j]["line"] == "": + j=j+1 + timestamp = trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][j]["lrc_timestamp"] + milliseconds = int(trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][j]["milliseconds"]) + self.lyrics['sync'] += timestamp + trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["line"] + "\r\n" + self.lyrics['syncID3'].append((trackAPI_gw["LYRICS"]["LYRICS_SYNC_JSON"][i]["line"], milliseconds)) self.mainArtist = { 'id': trackAPI_gw['ART_ID'], diff --git a/setup.py b/setup.py index 683700a..3abb25c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text() setup( name="deemix", - version="1.4.1", + version="1.4.2", description="A barebone deezer downloader library", long_description=README, long_description_content_type="text/markdown",