Skip to content

Commit

Permalink
Lyrics handling & Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
DJDoubleD committed Jul 24, 2024
1 parent 3a29640 commit 14a6e94
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
3 changes: 1 addition & 2 deletions android/app/src/main/java/r/r/refreezer/Deezer.java
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,7 @@ public static String generateLRC(Lyrics lyricsData, JSONObject publicTrack) thro
}
}
}

if (counter == 0) throw new Exception("Empty Lyrics!");

return output.toString();
}

Expand Down
47 changes: 26 additions & 21 deletions android/app/src/main/java/r/r/refreezer/DownloadService.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,24 +310,6 @@ public void run() {
try {
trackJson = deezer.callPublicAPI("track", download.trackId);
albumJson = deezer.callPublicAPI("album", Integer.toString(trackJson.getJSONObject("album").getInt("id")));

try {
lyricsData = deezer.getlyricsNew(download.trackId);

if (lyricsData.getErrorMessage() != null || !lyricsData.isLoaded()) {
logger.error("Unable the get lyrics from Pipe API: " + lyricsData.getErrorMessage());
logger.warn("Using classic API for lyrics");

JSONObject privateRaw = deezer.callGWAPI("deezer.pageTrack", "{\"sng_id\": \"" + download.trackId + "\"}");
privateJson = privateRaw.getJSONObject("results").getJSONObject("DATA");
if (privateRaw.getJSONObject("results").has("LYRICS")) {
lyricsData = new LyricsClassic(privateRaw.getJSONObject("results").getJSONObject("LYRICS"));
}
}
} catch (Exception e) {
logger.error("Unable to fetch lyrics data! " + e, download);
e.printStackTrace();
}
} catch (Exception e) {
logger.error("Unable to fetch track and album metadata! " + e, download);
e.printStackTrace();
Expand Down Expand Up @@ -552,9 +534,32 @@ public void run() {
e.printStackTrace();
}

//Lyrics
if (lyricsData != null) {
if (settings.downloadLyrics) {
//Lyrics (fetch only when requested)
if (settings.downloadLyrics || settings.tags.lyrics) {
try {
lyricsData = deezer.getlyricsNew(download.trackId);

if (!lyricsData.isLoaded()) {
if (lyricsData.getErrorMessage() != null) {
logger.error("Error getting lyrics from Pipe API: " + lyricsData.getErrorMessage(), download);
logger.warn("Trying classic API for lyrics");
}

JSONObject privateRaw = deezer.callGWAPI("deezer.pageTrack", "{\"sng_id\": \"" + download.trackId + "\"}");
privateJson = privateRaw.getJSONObject("results").getJSONObject("DATA");
if (privateRaw.getJSONObject("results").has("LYRICS")) {
lyricsData = new LyricsClassic(privateRaw.getJSONObject("results").getJSONObject("LYRICS"));
}
}
} catch (Exception e) {
logger.error("Unable to fetch lyrics data! " + e, download);
}
}

if (settings.downloadLyrics) {
if (lyricsData == null || !lyricsData.isSynced()){
logger.warn("No synched lyrics for track, skipping lyrics file" , download);
} else {
try {
String lrcData = Deezer.generateLRC(lyricsData, trackJson);
//Create file
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.7.11
version: 0.7.12

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down Expand Up @@ -110,7 +110,7 @@ dependencies:
#restart_app:
# git:
# url: https://github.com/Argaros/restart_app.git
rxdart: ^0.27.7
rxdart: ^0.28.0
scrobblenaut:
path: ./scrobblenaut
share_plus: ^9.0.0
Expand Down

0 comments on commit 14a6e94

Please sign in to comment.