feat: Add simple info log messages

This commit is contained in:
NaiJi ✨ 2023-01-31 11:37:32 +04:00
parent f88268caf7
commit 23dcc4b74a
1 changed files with 5 additions and 0 deletions

View File

@ -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);