mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-17 17:35:16 +00:00
Compare commits
1 Commits
fc9e9f8f4c
...
9c502c013d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9c502c013d |
@ -215,12 +215,16 @@ class ServerPlaybackRoutes {
|
|||||||
? activeSourcedTrack?.source
|
? activeSourcedTrack?.source
|
||||||
: await ref.read(
|
: await ref.read(
|
||||||
trackSourcesProvider(
|
trackSourcesProvider(
|
||||||
//! Use [Request.requestedUri] as it contains full https url.
|
TrackSourceQuery.parseUri(request.url.toString()),
|
||||||
//! [Request.url] will exclude and starts relatively. (streams/<trackId>... basically)
|
|
||||||
TrackSourceQuery.parseUri(request.requestedUri.toString()),
|
|
||||||
).future,
|
).future,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// This will be automatically updated by the notifier.
|
||||||
|
// if (playlist.activeTrack?.id == sourcedTrack?.query.id &&
|
||||||
|
// sourcedTrack != null) {
|
||||||
|
// ref.read(activeTrackSourcesProvider.notifier).update(sourcedTrack);
|
||||||
|
// }
|
||||||
|
|
||||||
final (bytes: audioBytes, response: res) =
|
final (bytes: audioBytes, response: res) =
|
||||||
await streamTrack(sourcedTrack!, request.headers);
|
await streamTrack(sourcedTrack!, request.headers);
|
||||||
|
|
||||||
|
@ -84,8 +84,6 @@ abstract class SourcedTrack extends BasicSourcedTrack {
|
|||||||
onlyCleanArtist: true,
|
onlyCleanArtist: true,
|
||||||
).trim();
|
).trim();
|
||||||
|
|
||||||
assert(title.trim().isNotEmpty, "Title should not be empty");
|
|
||||||
|
|
||||||
return "$title - ${track.artists.join(", ")}";
|
return "$title - ${track.artists.join(", ")}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,10 +201,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
final searchedVideos =
|
final searchedVideos =
|
||||||
await ref.read(youtubeEngineProvider).searchVideos(isrc.toString());
|
await ref.read(youtubeEngineProvider).searchVideos(isrc.toString());
|
||||||
if (searchedVideos.isNotEmpty) {
|
if (searchedVideos.isNotEmpty) {
|
||||||
AppLogger.log
|
isrcResults.addAll(searchedVideos
|
||||||
.d("${track.title} ISRC $isrc Total ${searchedVideos.length}");
|
|
||||||
|
|
||||||
final filteredMatches = searchedVideos
|
|
||||||
.map<YoutubeVideoInfo>(YoutubeVideoInfo.fromVideo)
|
.map<YoutubeVideoInfo>(YoutubeVideoInfo.fromVideo)
|
||||||
.map((YoutubeVideoInfo videoInfo) {
|
.map((YoutubeVideoInfo videoInfo) {
|
||||||
final ytWords = videoInfo.title
|
final ytWords = videoInfo.title
|
||||||
@ -228,16 +225,8 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.nonNulls
|
.whereType<YoutubeVideoInfo>()
|
||||||
.toList();
|
.toList());
|
||||||
|
|
||||||
for (final match in filteredMatches) {
|
|
||||||
AppLogger.log.d(
|
|
||||||
"ISRC MATCH: ${match.id} ${match.title} by ${match.channelName} ${match.duration}",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
isrcResults.addAll(filteredMatches);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isrcResults;
|
return isrcResults;
|
||||||
@ -258,14 +247,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
videoResults.addAll(isrcResults);
|
videoResults.addAll(isrcResults);
|
||||||
|
|
||||||
if (isrcResults.isEmpty) {
|
if (isrcResults.isEmpty) {
|
||||||
AppLogger.log.w("No ISRC results found, falling back to SongLink");
|
|
||||||
|
|
||||||
final links = await SongLinkService.links(query.id);
|
final links = await SongLinkService.links(query.id);
|
||||||
|
|
||||||
for (final link in links) {
|
|
||||||
AppLogger.log.d("SongLink ${query.id} ${link.platform} ${link.url}");
|
|
||||||
}
|
|
||||||
|
|
||||||
final ytLink = links.firstWhereOrNull(
|
final ytLink = links.firstWhereOrNull(
|
||||||
(link) => link.platform == "youtube",
|
(link) => link.platform == "youtube",
|
||||||
);
|
);
|
||||||
@ -280,8 +262,6 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
// Ignore this error and continue with the search
|
// Ignore this error and continue with the search
|
||||||
AppLogger.reportError(e, stack);
|
AppLogger.reportError(e, stack);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
AppLogger.log.w("No YouTube link found in SongLink results");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
import 'package:spotube/services/dio/dio.dart';
|
|
||||||
import 'package:spotube/services/logger/logger.dart';
|
|
||||||
import 'package:spotube/services/youtube_engine/youtube_engine.dart';
|
import 'package:spotube/services/youtube_engine/youtube_engine.dart';
|
||||||
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
|
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
|
||||||
|
|
||||||
@ -155,30 +152,9 @@ class YouTubeExplodeEngine implements YouTubeEngine {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final accessibleStreams = <AudioOnlyStreamInfo>[];
|
return StreamManifest(
|
||||||
|
streamManifest.audioOnly.map((stream) {
|
||||||
for (final stream in streamManifest.audioOnly) {
|
return AudioOnlyStreamInfo(
|
||||||
// Call dio head request to check if the stream is accessible
|
|
||||||
final response = await globalDio.headUri(
|
|
||||||
stream.url,
|
|
||||||
options: Options(
|
|
||||||
followRedirects: true,
|
|
||||||
validateStatus: (status) {
|
|
||||||
return status != null && status < 500;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
AppLogger.log.d(
|
|
||||||
"Stream $videoId Status ${response.statusCode} Codec ${stream.audioCodec} "
|
|
||||||
"Bitrate ${stream.bitrate} Container ${stream.container}",
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode != null &&
|
|
||||||
response.statusCode! >= 200 &&
|
|
||||||
response.statusCode! < 400) {
|
|
||||||
accessibleStreams.add(
|
|
||||||
AudioOnlyStreamInfo(
|
|
||||||
stream.videoId,
|
stream.videoId,
|
||||||
stream.tag,
|
stream.tag,
|
||||||
stream.url,
|
stream.url,
|
||||||
@ -194,12 +170,9 @@ class YouTubeExplodeEngine implements YouTubeEngine {
|
|||||||
stream.fragments,
|
stream.fragments,
|
||||||
stream.codec,
|
stream.codec,
|
||||||
stream.audioTrack,
|
stream.audioTrack,
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}),
|
||||||
}
|
);
|
||||||
|
|
||||||
return StreamManifest(accessibleStreams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Loading…
Reference in New Issue
Block a user