feat: Implement single tracks downloading
parent
578e3709f8
commit
963fd4bc1a
@ -1,51 +0,0 @@
|
|||||||
import 'package:funkblubber/funkentity.dart';
|
|
||||||
import 'package:funkblubber/console.dart' as console;
|
|
||||||
|
|
||||||
FunkObject extract(final List<String> args) {
|
|
||||||
FunkObject result = FunkObject(
|
|
||||||
kind: FunkEntity.error,
|
|
||||||
id: '',
|
|
||||||
domain: '',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (args.isEmpty) {
|
|
||||||
console.error('no arguments provided');
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
final Uri uri = Uri.parse(args[0]);
|
|
||||||
|
|
||||||
final segments = uri.pathSegments;
|
|
||||||
for (int i = 0; i < segments.length; ++i) {
|
|
||||||
switch (segments[i]) {
|
|
||||||
case 'artists':
|
|
||||||
result = FunkObject(
|
|
||||||
kind: FunkEntity.artist,
|
|
||||||
id: segments[i + 1],
|
|
||||||
domain: uri.host,
|
|
||||||
);
|
|
||||||
++i;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'albums':
|
|
||||||
result = FunkObject(
|
|
||||||
kind: FunkEntity.album,
|
|
||||||
id: segments[i + 1],
|
|
||||||
domain: uri.host,
|
|
||||||
);
|
|
||||||
++i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e.toString());
|
|
||||||
result = FunkObject(
|
|
||||||
kind: FunkEntity.error,
|
|
||||||
id: '',
|
|
||||||
domain: '',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
Loading…
Reference in New Issue