From d0291e90a161c0a4a37d0e82a08a3cb5e7e954ca Mon Sep 17 00:00:00 2001 From: NaiJi Date: Mon, 30 Jan 2023 02:55:35 +0400 Subject: [PATCH] feat: Implement folder for artist --- lib/funkblubber.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/funkblubber.dart b/lib/funkblubber.dart index 24a9514..028b862 100644 --- a/lib/funkblubber.dart +++ b/lib/funkblubber.dart @@ -26,7 +26,15 @@ Future _downloadArtist( final FunkObject object, final String path, ) async { - final response = await Dio().get( + Response response = await Dio().get( + 'https://${object.domain}/api/v1/artists/${object.id}/?' + 'refresh=false', + ); + + final String pathAppend = response.data['name']; + await Directory('$path/$pathAppend').create(); + + response = await Dio().get( 'https://${object.domain}/api/v1/albums/?' 'artist=${object.id}&ordering=creation_date&' 'page=1&page_size=16&scope=all', @@ -39,7 +47,7 @@ Future _downloadArtist( id: albumResponse['id'].toString(), kind: FunkEntity.album, ), - path, + '$path/$pathAppend', ); } } @@ -55,7 +63,7 @@ Future _downloadAlbum( ); final String pathAppend = response.data['results'][0]['album']['title']; - await Directory(pathAppend).create(); + await Directory('$path/$pathAppend').create(); for (final songResponse in response.data['results']) { final String songTitle = songResponse['title'];