mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
fix: yt-dlp playback not working and add partial support for HLS streaming
This commit is contained in:
parent
6940e92142
commit
469a76dbd6
@ -117,6 +117,24 @@ class ServerPlaybackRoutes {
|
|||||||
return dio.head(url, options: options);
|
return dio.head(url, options: options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Redirect to m3u8 link directly as it handles range requests internally
|
||||||
|
if (contentLengthRes?.headers.value("content-type") ==
|
||||||
|
"application/vnd.apple.mpegurl") {
|
||||||
|
return (
|
||||||
|
response: dio_lib.Response<Uint8List>(
|
||||||
|
statusCode: 301,
|
||||||
|
statusMessage: "M3U8 Redirect",
|
||||||
|
headers: Headers.fromMap({
|
||||||
|
"location": [url],
|
||||||
|
"content-type": ["application/vnd.apple.mpegurl"],
|
||||||
|
}),
|
||||||
|
requestOptions: RequestOptions(path: request.requestedUri.toString()),
|
||||||
|
isRedirect: true,
|
||||||
|
),
|
||||||
|
bytes: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final contentLength = contentLengthRes?.headers.value("content-length");
|
final contentLength = contentLengthRes?.headers.value("content-length");
|
||||||
|
|
||||||
/// Forcing partial content range as mpv sometimes greedily wants
|
/// Forcing partial content range as mpv sometimes greedily wants
|
||||||
|
@ -11,9 +11,7 @@ import 'package:http_parser/http_parser.dart';
|
|||||||
class YtDlpEngine implements YouTubeEngine {
|
class YtDlpEngine implements YouTubeEngine {
|
||||||
StreamManifest _parseFormats(List formats, videoId) {
|
StreamManifest _parseFormats(List formats, videoId) {
|
||||||
final audioOnlyStreams = formats
|
final audioOnlyStreams = formats
|
||||||
.where(
|
.where((f) => f["resolution"] == "audio only")
|
||||||
(f) => f["resolution"] == "audio only" && f["manifest_url"] == null,
|
|
||||||
)
|
|
||||||
.sorted((a, b) => a["quality"] > b["quality"] ? 1 : -1)
|
.sorted((a, b) => a["quality"] > b["quality"] ? 1 : -1)
|
||||||
.map((f) {
|
.map((f) {
|
||||||
final filesize = f["filesize"] ?? f["filesize_approx"];
|
final filesize = f["filesize"] ?? f["filesize_approx"];
|
||||||
@ -22,13 +20,14 @@ class YtDlpEngine implements YouTubeEngine {
|
|||||||
0,
|
0,
|
||||||
Uri.parse(f["url"]),
|
Uri.parse(f["url"]),
|
||||||
StreamContainer.parse(
|
StreamContainer.parse(
|
||||||
f["container"]?.replaceAll("_dash", "").replaceAll("m4a", "mp4"),
|
f["container"]?.replaceAll("_dash", "").replaceAll("m4a", "mp4") ??
|
||||||
|
(f["protocol"] == "m3u8_native" ? "m3u8" : "mp4"),
|
||||||
),
|
),
|
||||||
filesize != null ? FileSize(filesize) : FileSize.unknown,
|
filesize != null ? FileSize(filesize) : FileSize.unknown,
|
||||||
Bitrate(
|
Bitrate(
|
||||||
(((f["abr"] ?? f["tbr"] ?? 0) * 1000) as num).toInt(),
|
(((f["abr"] ?? f["tbr"] ?? 0) * 1000) as num).toInt(),
|
||||||
),
|
),
|
||||||
f["acodec"] ?? "webm",
|
f["acodec"] ?? "aac",
|
||||||
f["format_note"],
|
f["format_note"],
|
||||||
[],
|
[],
|
||||||
MediaType.parse(
|
MediaType.parse(
|
||||||
|
@ -2881,8 +2881,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: e2d82305fab18566408d6f8758361017d1640c3d
|
ref: "4e5310e14af74bdbb51e2a4766e66d6c6a2562a8"
|
||||||
resolved-ref: e2d82305fab18566408d6f8758361017d1640c3d
|
resolved-ref: "4e5310e14af74bdbb51e2a4766e66d6c6a2562a8"
|
||||||
url: "https://github.com/KRTirtho/yt_dlp_dart.git"
|
url: "https://github.com/KRTirtho/yt_dlp_dart.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
|
@ -132,7 +132,7 @@ dependencies:
|
|||||||
yt_dlp_dart:
|
yt_dlp_dart:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/KRTirtho/yt_dlp_dart.git
|
url: https://github.com/KRTirtho/yt_dlp_dart.git
|
||||||
ref: e2d82305fab18566408d6f8758361017d1640c3d
|
ref: 4e5310e14af74bdbb51e2a4766e66d6c6a2562a8
|
||||||
flutter_new_pipe_extractor:
|
flutter_new_pipe_extractor:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/KRTirtho/flutter_new_pipe_extractor.git
|
url: https://github.com/KRTirtho/flutter_new_pipe_extractor.git
|
||||||
|
Loading…
Reference in New Issue
Block a user