|
|
|
@ -3,6 +3,7 @@ import 'dart:io'; |
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:funkblubber/funkentity.dart'; |
|
|
|
|
import 'package:funkblubber/console.dart' as console; |
|
|
|
|
import 'package:funkblubber/string_utils.dart' as utils; |
|
|
|
|
|
|
|
|
|
Future<bool> download({ |
|
|
|
|
required final FunkObject object, |
|
|
|
@ -40,7 +41,7 @@ Future<bool> _downloadArtist( |
|
|
|
|
'refresh=false', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
final String pathAppend = response.data['name']; |
|
|
|
|
final String pathAppend = utils.sanitizePath(response.data['name']); |
|
|
|
|
bool folderCreated = true; |
|
|
|
|
try { |
|
|
|
|
await Directory('$path/$pathAppend').create(); |
|
|
|
@ -87,7 +88,9 @@ Future<bool> _downloadAlbum( |
|
|
|
|
'page=1&page_size=16&scope=all', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
final String pathAppend = response.data['results'][0]['album']['title']; |
|
|
|
|
final String pathAppend = utils.sanitizePath( |
|
|
|
|
response.data['results'][0]['album']['title'], |
|
|
|
|
); |
|
|
|
|
bool folderCreated = true; |
|
|
|
|
try { |
|
|
|
|
await Directory('$path/$pathAppend').create(); |
|
|
|
@ -102,7 +105,7 @@ Future<bool> _downloadAlbum( |
|
|
|
|
|
|
|
|
|
final List<Future<bool>> results = []; |
|
|
|
|
for (final songResponse in response.data['results']) { |
|
|
|
|
final String songTitle = songResponse['title']; |
|
|
|
|
final String songTitle = utils.sanitizePath(songResponse['title']); |
|
|
|
|
final String ext = songResponse['uploads'][0]['extension']; |
|
|
|
|
final result = _downloadTrackObject( |
|
|
|
|
FunkObject( |
|
|
|
@ -128,7 +131,7 @@ Future<bool> _downloadTrack( |
|
|
|
|
'https://${object.domain}/api/v1/tracks/${object.id}/?refresh=false', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
final String songTitle = response.data['title']; |
|
|
|
|
final String songTitle = utils.sanitizePath(response.data['title']); |
|
|
|
|
final String ext = response.data['uploads'][0]['extension']; |
|
|
|
|
return _downloadTrackObject( |
|
|
|
|
FunkObject( |
|
|
|
|