-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Nebulino/tag_extension
Add capability of applying TagMethods in Tag.
- Loading branch information
Showing
5 changed files
with
151 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Scrobblenaut - A deadly simple Last.FM API Wrapper for Dart. | ||
* Copyright (c) 2020 Nebulino | ||
*/ | ||
|
||
import 'package:scrobblenaut/lastfm.dart'; | ||
import 'package:scrobblenaut/scrobblenaut.dart'; | ||
|
||
import '../api_values.dart'; | ||
|
||
// Just an example of use. | ||
void main() async { | ||
print('####################################################################'); | ||
|
||
final lastFMAuth = await LastFM.authenticate( | ||
apiKey: APIValues.API, | ||
apiSecret: APIValues.secret, | ||
username: APIValues.username, | ||
password: APIValues.password, | ||
sessionKey: APIValues.sessionKey, | ||
); | ||
|
||
final scrobblenaut = Scrobblenaut(lastFM: lastFMAuth); | ||
|
||
final tagInstance = (await scrobblenaut.tag.getInfo(tag: 'anime')); | ||
|
||
print('############################tag.getInfo#############################'); | ||
|
||
// tag.getInfo | ||
final tagGetInfo = (await tagInstance.getInfo()); | ||
print('Tag Name: ${tagGetInfo.name} | Tag total: ${tagGetInfo.total}'); | ||
|
||
print('############################tag.getSimilar##########################'); | ||
|
||
// tag.getSimilar | ||
(await tagInstance.getSimilar())?.forEach((Tag tag) { | ||
print('Similar Tag Name: ${tag.name}'); | ||
}); | ||
|
||
print('##########################tag.getTopAlbums##########################'); | ||
|
||
// tag.getTopAlbums | ||
(await tagInstance.getTopAlbums())?.forEach((Album album) { | ||
print('Top Album Name: ${album.name}'); | ||
}); | ||
|
||
print('########################tag.getTopArtists###########################'); | ||
|
||
// tag.getTopArtists | ||
(await tagInstance.getTopArtists())?.forEach((Artist artist) { | ||
print('Top Artist Name: ${artist.name}'); | ||
}); | ||
|
||
print('########################tag.getTopTracks############################'); | ||
|
||
// tag.getTopTracks | ||
(await tagInstance.getTopTracks())?.forEach((Track track) { | ||
print('Top Track Name: ${track.name} | Top Track URL: ${track.url}'); | ||
}); | ||
|
||
print('#######################tag.getWeeklyChartList#######################'); | ||
|
||
// tag.getWeeklyChartList | ||
(await tagInstance.getWeeklyChartList())?.forEach((Chart chart) { | ||
print('Chart FromDate: ${chart.fromDate} | Chart ToDate: ${chart.toDate}'); | ||
}); | ||
|
||
print('####################################################################'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Scrobblenaut - A deadly simple Last.FM API Wrapper for Dart. | ||
* Copyright (c) 2020 Nebulino | ||
*/ | ||
|
||
import 'package:scrobblenaut/lastfm.dart'; | ||
import 'package:scrobblenaut/lastfm_methods.dart'; | ||
import 'package:scrobblenaut/scrobblenaut.dart'; | ||
|
||
/// Give the ability of applying [TagMethods] on [Tag]. | ||
extension TagExtension on Tag { | ||
TagMethods get _tagMethods => Scrobblenaut.instance.tag; | ||
|
||
/// [TagMethods.getInfo] | ||
Future<Tag> getInfo({ | ||
Language language = Language.en, | ||
}) async { | ||
return await _tagMethods.getInfo( | ||
tag: name, | ||
language: language, | ||
); | ||
} | ||
|
||
/// [TagMethods.getSimilar] | ||
Future<List<Tag>> getSimilar() async { | ||
return await _tagMethods.getSimilar( | ||
tag: name, | ||
); | ||
} | ||
|
||
/// [TagMethods.getTopAlbums] | ||
Future<List<Album>> getTopAlbums({ | ||
int page = 1, | ||
int limit = 50, | ||
}) async { | ||
return await _tagMethods.getTopAlbums( | ||
tag: name, | ||
page: page, | ||
limit: limit, | ||
); | ||
} | ||
|
||
/// [TagMethods.getTopArtists] | ||
Future<List<Artist>> getTopArtists({ | ||
int page = 1, | ||
int limit = 50, | ||
}) async { | ||
return await _tagMethods.getTopArtists( | ||
tag: name, | ||
page: page, | ||
limit: limit, | ||
); | ||
} | ||
|
||
/// [TagMethods.getTopTracks] | ||
Future<List<Track>> getTopTracks({ | ||
int page = 1, | ||
int limit = 50, | ||
}) async { | ||
return await _tagMethods.getTopTracks( | ||
tag: name, | ||
page: page, | ||
limit: limit, | ||
); | ||
} | ||
|
||
/// [TagMethods.getWeeklyChartList] | ||
Future<List<Chart>> getWeeklyChartList() async { | ||
return await _tagMethods.getWeeklyChartList( | ||
tag: name, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters