|
|
|
@ -8,6 +8,7 @@ Future<void> download({
|
|
|
|
|
required final FunkObject object,
|
|
|
|
|
final String path = '.',
|
|
|
|
|
}) async {
|
|
|
|
|
console.info('Downloading');
|
|
|
|
|
switch (object.kind) {
|
|
|
|
|
case FunkEntity.album:
|
|
|
|
|
await _downloadAlbum(object, path);
|
|
|
|
@ -18,6 +19,7 @@ Future<void> download({
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
console.info(' nothing...');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -33,6 +35,7 @@ Future<void> _downloadArtist(
|
|
|
|
|
|
|
|
|
|
final String pathAppend = response.data['name'];
|
|
|
|
|
await Directory('$path/$pathAppend').create();
|
|
|
|
|
console.info('Artist: $pathAppend');
|
|
|
|
|
|
|
|
|
|
response = await Dio().get(
|
|
|
|
|
'https://${object.domain}/api/v1/albums/?'
|
|
|
|
@ -64,6 +67,7 @@ Future<void> _downloadAlbum(
|
|
|
|
|
|
|
|
|
|
final String pathAppend = response.data['results'][0]['album']['title'];
|
|
|
|
|
await Directory('$path/$pathAppend').create();
|
|
|
|
|
console.info('Album: $pathAppend');
|
|
|
|
|
|
|
|
|
|
for (final songResponse in response.data['results']) {
|
|
|
|
|
final String songTitle = songResponse['title'];
|
|
|
|
@ -90,6 +94,7 @@ Future<void> _downloadSongObject(
|
|
|
|
|
followRedirects: false,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
console.info('- $path');
|
|
|
|
|
final File file = File(path);
|
|
|
|
|
final accessFile = file.openSync(mode: FileMode.write);
|
|
|
|
|
accessFile.writeFromSync(response.data);
|
|
|
|
|