🐛 Bug fixes on cross source track fetching
This commit is contained in:
parent
d860936010
commit
1913a7e909
@ -82,6 +82,21 @@ abstract class SourcedTrack extends Track {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<SourcedTrack?> reRoutineFetchFromTrack(
|
||||||
|
Track track, SourceMatchTableData cachedSource) {
|
||||||
|
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
||||||
|
final ytOrPiped = preferences.audioSource == AudioSource.piped
|
||||||
|
? PipedSourcedTrack.fetchFromTrack
|
||||||
|
: YoutubeSourcedTrack.fetchFromTrack;
|
||||||
|
final sourceInfoTrackMap = {
|
||||||
|
SourceType.youtube: ytOrPiped,
|
||||||
|
SourceType.youtubeMusic: ytOrPiped,
|
||||||
|
SourceType.netease: NeteaseSourcedTrack.fetchFromTrack,
|
||||||
|
SourceType.kugou: KugouSourcedTrack.fetchFromTrack,
|
||||||
|
};
|
||||||
|
return sourceInfoTrackMap[cachedSource.sourceType]!(track: track);
|
||||||
|
}
|
||||||
|
|
||||||
Future<SourcedTrack?> reRoutineSwapSiblings(SourceInfo info) {
|
Future<SourcedTrack?> reRoutineSwapSiblings(SourceInfo info) {
|
||||||
final sourceInfoTrackMap = {
|
final sourceInfoTrackMap = {
|
||||||
YoutubeSourceInfo: YoutubeSourcedTrack.fetchFromTrack,
|
YoutubeSourceInfo: YoutubeSourcedTrack.fetchFromTrack,
|
||||||
|
@ -51,7 +51,7 @@ class KugouSourcedTrack extends SourcedTrack {
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<KugouSourcedTrack> fetchFromTrack({
|
static Future<SourcedTrack> fetchFromTrack({
|
||||||
required Track track,
|
required Track track,
|
||||||
}) async {
|
}) async {
|
||||||
final DatabaseProvider db = Get.find();
|
final DatabaseProvider db = Get.find();
|
||||||
@ -86,6 +86,11 @@ class KugouSourcedTrack extends SourcedTrack {
|
|||||||
sourceInfo: siblings.first.info,
|
sourceInfo: siblings.first.info,
|
||||||
track: track,
|
track: track,
|
||||||
);
|
);
|
||||||
|
} else if (cachedSource.sourceType != SourceType.kugou) {
|
||||||
|
final out =
|
||||||
|
await SourcedTrack.reRoutineFetchFromTrack(track, cachedSource);
|
||||||
|
if (out == null) throw TrackNotFoundError(track);
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return KugouSourcedTrack(
|
return KugouSourcedTrack(
|
||||||
|
@ -73,7 +73,7 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
return _lookedUpRealIp!;
|
return _lookedUpRealIp!;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<NeteaseSourcedTrack> fetchFromTrack({
|
static Future<SourcedTrack> fetchFromTrack({
|
||||||
required Track track,
|
required Track track,
|
||||||
}) async {
|
}) async {
|
||||||
final DatabaseProvider db = Get.find();
|
final DatabaseProvider db = Get.find();
|
||||||
@ -114,10 +114,16 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
sourceInfo: siblings.first.info,
|
sourceInfo: siblings.first.info,
|
||||||
track: track,
|
track: track,
|
||||||
);
|
);
|
||||||
|
} else if (cachedSource.sourceType != SourceType.netease) {
|
||||||
|
final out =
|
||||||
|
await SourcedTrack.reRoutineFetchFromTrack(track, cachedSource);
|
||||||
|
if (out == null) throw TrackNotFoundError(track);
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
final client = getClient();
|
final client = getClient();
|
||||||
final resp = await client.get('/song/detail?ids=${cachedSource.sourceId}');
|
final resp = await client.get('/song/detail?ids=${cachedSource.sourceId}');
|
||||||
|
if (resp.body?['songs'] == null) throw TrackNotFoundError(track);
|
||||||
final item = (resp.body['songs'] as List<dynamic>).firstOrNull;
|
final item = (resp.body['songs'] as List<dynamic>).firstOrNull;
|
||||||
|
|
||||||
if (item == null) throw TrackNotFoundError(track);
|
if (item == null) throw TrackNotFoundError(track);
|
||||||
|
@ -57,6 +57,14 @@ class PipedSourcedTrack extends SourcedTrack {
|
|||||||
|
|
||||||
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
||||||
|
|
||||||
|
if (cachedSource?.sourceType != SourceType.youtube &&
|
||||||
|
cachedSource?.sourceType != SourceType.youtubeMusic) {
|
||||||
|
final out =
|
||||||
|
await SourcedTrack.reRoutineFetchFromTrack(track, cachedSource!);
|
||||||
|
if (out == null) throw TrackNotFoundError(track);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
if (cachedSource == null) {
|
if (cachedSource == null) {
|
||||||
final siblings = await fetchSiblings(track: track);
|
final siblings = await fetchSiblings(track: track);
|
||||||
if (siblings.isEmpty) {
|
if (siblings.isEmpty) {
|
||||||
|
@ -43,7 +43,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
required super.track,
|
required super.track,
|
||||||
});
|
});
|
||||||
|
|
||||||
static Future<YoutubeSourcedTrack> fetchFromTrack({
|
static Future<SourcedTrack> fetchFromTrack({
|
||||||
required Track track,
|
required Track track,
|
||||||
}) async {
|
}) async {
|
||||||
final DatabaseProvider db = Get.find();
|
final DatabaseProvider db = Get.find();
|
||||||
@ -78,6 +78,11 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
sourceInfo: siblings.first.info,
|
sourceInfo: siblings.first.info,
|
||||||
track: track,
|
track: track,
|
||||||
);
|
);
|
||||||
|
} else if (cachedSource.sourceType != SourceType.youtube) {
|
||||||
|
final out =
|
||||||
|
await SourcedTrack.reRoutineFetchFromTrack(track, cachedSource);
|
||||||
|
if (out == null) throw TrackNotFoundError(track);
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
final item = await youtubeClient.videos.get(cachedSource.sourceId);
|
final item = await youtubeClient.videos.get(cachedSource.sourceId);
|
||||||
|
@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.0.0+17
|
version: 1.0.0+18
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.5.0
|
sdk: ^3.5.0
|
||||||
|
Loading…
Reference in New Issue
Block a user