🐛 Fixes

This commit is contained in:
2024-09-06 13:26:20 +08:00
parent 2cee7ee958
commit 463cb9870f
4 changed files with 11 additions and 13 deletions

View File

@ -1,5 +1,6 @@
import 'package:collection/collection.dart';
import 'package:get/get.dart';
import 'package:rhythm_box/providers/error_notifier.dart';
import 'package:rhythm_box/providers/user_preferences.dart';
import 'package:rhythm_box/services/database/database.dart';
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
@ -107,7 +108,9 @@ abstract class SourcedTrack extends Track {
await PipedSourcedTrack.fetchFromTrack(track: track),
_ => await YoutubeSourcedTrack.fetchFromTrack(track: track),
};
} on TrackNotFoundError catch (_) {
} on TrackNotFoundError catch (err) {
Get.find<ErrorNotifier>()
.showError('${err.toString()} via ${preferences.audioSource.label}');
return switch (preferences.audioSource) {
AudioSource.piped ||
AudioSource.youtube =>

View File

@ -47,7 +47,7 @@ class NeteaseSourcedTrack extends SourcedTrack {
client.baseUrl = getBaseUrl();
client.httpClient.addRequestModifier((Request request) async {
final AuthenticationProvider auth = Get.find();
if (auth.auth.value!.neteaseCookie != null) {
if (auth.auth.value?.neteaseCookie != null) {
final cookie =
'MUSIC_U=${auth.auth.value!.getNeteaseCookie('MUSIC_U')}';
if (request.headers['Cookie'] == null) {
@ -87,17 +87,12 @@ class NeteaseSourcedTrack extends SourcedTrack {
.get()
.then((s) => s.firstOrNull);
if (cachedSource == null) {
if (cachedSource == null || cachedSource.sourceType != SourceType.netease) {
final siblings = await fetchSiblings(track: track);
if (siblings.isEmpty) {
throw TrackNotFoundError(track);
}
final client = getClient();
final checkResp =
await client.get('/check/music?id=${siblings.first.info.id}');
if (checkResp.body['success'] != true) throw TrackNotFoundError(track);
await db.database.into(db.database.sourceMatchTable).insert(
SourceMatchTableCompanion.insert(
trackId: track.id!,
@ -116,6 +111,7 @@ class NeteaseSourcedTrack extends SourcedTrack {
final client = getClient();
final resp = await client.get('/song/detail?ids=${cachedSource.sourceId}');
print(resp.body);
final item = resp.body['songs'][0];
return NeteaseSourcedTrack(