Skip to content

Commit

Permalink
Merge pull request Harsh-23#2 from cyberboysumanjay/master
Browse files Browse the repository at this point in the history
Optimise Lyrics Fetching
  • Loading branch information
cyberboysumanjay authored Aug 11, 2020
2 parents 88f875f + bef38de commit c454dac
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions lib/API/saavn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,30 @@ Future fetchSongDetails(songId) async {
.split("(")[0]
.replaceAll("&", "&");
image = (getMain[songId]["image"]);
artist =
(getMain[songId]["more_info"]["artistMap"]["primary_artists"][0]["name"]);
artist = (getMain[songId]["more_info"]["artistMap"]["primary_artists"][0]
["name"])
.toString()
.replaceAll(""", "\"")
.replaceAll("&", "&");
album = (getMain[songId]["more_info"]["album"])
.toString()
.replaceAll(""", "\"")
.replaceAll("&", "&");

String lyricsUrl =
"https://www.jiosaavn.com/api.php?__call=lyrics.getLyrics&lyrics_id=" +
songId +
"&ctx=web6dot0&api_version=4&_format=json";
var lyricsRes =
await http.get(lyricsUrl, headers: {"Accept": "application/json"});
var lyricsEdited = (lyricsRes.body).split("-->");
var fetchedLyrics = json.decode(lyricsEdited[1]);
if (getMain[songId]["more_info"]["has_lyrics"] == "true") {
String lyricsUrl =
"https://www.jiosaavn.com/api.php?__call=lyrics.getLyrics&lyrics_id=" +
songId +
"&ctx=web6dot0&api_version=4&_format=json";
var lyricsRes =
await http.get(lyricsUrl, headers: {"Accept": "application/json"});
var lyricsEdited = (lyricsRes.body).split("-->");
var fetchedLyrics = json.decode(lyricsEdited[1]);

lyrics = fetchedLyrics["lyrics"].toString().replaceAll("<br>", "\n");
lyrics = fetchedLyrics["lyrics"].toString().replaceAll("<br>", "\n");
} else {
lyrics = "null";
}

kUrl = await DesPlugin.decrypt(
key, getMain[songId]["more_info"]["encrypted_media_url"]);
Expand Down

0 comments on commit c454dac

Please sign in to comment.