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); await _downloadAlbum(object, path);
return; return;
case FunkEntity.artist:
await _downloadArtist(object, path);
return;
default: default:
return; 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( Future<void> _downloadAlbum(
final FunkObject object, final FunkObject object,
final String path, final String path,