mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: track loading when not found in Youtube
This commit is contained in:
parent
badd52223a
commit
e964f61d38
@ -1,5 +1,6 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
import 'package:spotube/models/source_match.dart';
|
import 'package:spotube/models/source_match.dart';
|
||||||
import 'package:spotube/services/sourced_track/enums.dart';
|
import 'package:spotube/services/sourced_track/enums.dart';
|
||||||
@ -70,9 +71,14 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
final item = await youtubeClient.videos.get(cachedSource.sourceId);
|
final item = await youtubeClient.videos.get(cachedSource.sourceId);
|
||||||
final manifest = await youtubeClient.videos.streamsClient.getManifest(
|
final manifest = await youtubeClient.videos.streamsClient
|
||||||
cachedSource.sourceId,
|
.getManifest(
|
||||||
);
|
cachedSource.sourceId,
|
||||||
|
)
|
||||||
|
.timeout(
|
||||||
|
const Duration(seconds: 5),
|
||||||
|
onTimeout: () => throw ClientException("Timeout"),
|
||||||
|
);
|
||||||
return YoutubeSourcedTrack(
|
return YoutubeSourcedTrack(
|
||||||
ref: ref,
|
ref: ref,
|
||||||
siblings: [],
|
siblings: [],
|
||||||
@ -125,7 +131,10 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
SourceMap? sourceMap;
|
SourceMap? sourceMap;
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
final manifest =
|
final manifest =
|
||||||
await youtubeClient.videos.streamsClient.getManifest(item.id);
|
await youtubeClient.videos.streamsClient.getManifest(item.id).timeout(
|
||||||
|
const Duration(seconds: 5),
|
||||||
|
onTimeout: () => throw ClientException("Timeout"),
|
||||||
|
);
|
||||||
sourceMap = toSourceMap(manifest);
|
sourceMap = toSourceMap(manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +252,12 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
final newSiblings = siblings.where((s) => s.id != sibling.id).toList()
|
final newSiblings = siblings.where((s) => s.id != sibling.id).toList()
|
||||||
..insert(0, sourceInfo);
|
..insert(0, sourceInfo);
|
||||||
|
|
||||||
final manifest =
|
final manifest = await youtubeClient.videos.streamsClient
|
||||||
await youtubeClient.videos.streamsClient.getManifest(newSourceInfo.id);
|
.getManifest(newSourceInfo.id)
|
||||||
|
.timeout(
|
||||||
|
const Duration(seconds: 5),
|
||||||
|
onTimeout: () => throw ClientException("Timeout"),
|
||||||
|
);
|
||||||
|
|
||||||
await SourceMatch.box.put(
|
await SourceMatch.box.put(
|
||||||
id!,
|
id!,
|
||||||
|
Loading…
Reference in New Issue
Block a user