feat: Implement artist downloading in Dart

This commit is contained in:
NaiJi ✨ 2023-01-30 02:46:11 +04:00
parent f52fee6506
commit bfe08dc6fa
1 changed files with 26 additions and 0 deletions

View File

@ -13,11 +13,37 @@ Future<void> download({
await _downloadAlbum(object, path);
return;
case FunkEntity.artist:
await _downloadArtist(object, path);
return;
default:
return;
}
}
Future<void> _downloadArtist(
final FunkObject object,
final String path,
) async {
final response = await Dio().get(
'https://${object.domain}/api/v1/albums/?'
'artist=${object.id}&ordering=creation_date&'
'page=1&page_size=16&scope=all',
);
for (final albumResponse in response.data['results']) {
_downloadAlbum(
FunkObject(
domain: object.domain,
id: albumResponse['id'].toString(),
kind: FunkEntity.album,
),
path,
);
}
}
Future<void> _downloadAlbum(
final FunkObject object,
final String path,