Skip to content

Commit

Permalink
saavn api song formating fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HemantKArya committed Oct 24, 2024
1 parent a06ab27 commit 3d3b70d
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/repository/Saavn/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ Future<Map> formatSingleSongResponse(Map response) async {
// } else {
// artistNames.add(response['primary_artists']);
// }
String artists;
if (response['more_info']?['music'] != null &&
response['more_info']?['music'] != "") {
artists = response['more_info']['music'].toString().unescape();
} else if (response['more_info']?['artistMap']?["primary_artists"] !=
null) {
List<String> artistList = [];
response['more_info']?['artistMap']?["primary_artists"]
.forEach((element) {
artistList.add(element['name'].toString().unescape());
});
artists = artistList.join(', ');
} else {
artists = response['subtitle'].toString().unescape();
}

return {
'id': response['id'],
Expand Down Expand Up @@ -143,14 +158,7 @@ Future<Map> formatSingleSongResponse(Map response) async {
// 'subtitle': response['subtitle'].toString().unescape(),
'title': response['song']?.toString().unescape() ??
response['title']?.toString().unescape(),
'artist': response['primary_artists']?.toString().unescape() ??
(response['more_info']?['artistMap']?['artists'] as List)
.map(
(e) => e['name'],
)
.toList()
.join(', ')
.unescape(),
'artist': artists,
// 'album_artist': response['more_info'],
'image': getImageUrl(response['image'].toString()),
'perma_url': response['perma_url'],
Expand Down

0 comments on commit 3d3b70d

Please sign in to comment.