Skip to content

Commit

Permalink
get description from lastFM api
Browse files Browse the repository at this point in the history
  • Loading branch information
apoleon33 committed Jan 14, 2024
1 parent 21f461c commit 7f60c9e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/api/lastfm_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ import 'package:cradle/env/env.dart';
class LastFmApi extends Api {
LastFmApi()
: super(
baseUrl:
'https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=$LASTFM_KEY');
baseUrl:
'https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=$LASTFM_KEY');

Future<Map> getAlbum(Album album) async =>
await callApi(
'&artist=${album.artist}&album=${album.name}&format=json',
);

Future getCover(Album album) async {
Map result = await callApi(
'&artist=${album.artist}&album=${album.name}&format=json');
Map result = await getAlbum(album);
var image = result['album']['image'];

return (image != null)
? (image.last['#text'] != "")
? image.last['#text']
: null
? image.last['#text']
: null
: null;
}
}

0 comments on commit 7f60c9e

Please sign in to comment.