api/youtube: add support for pinning client/itag

This commit is contained in:
jj 2025-01-20 14:46:55 +00:00
parent 035825bc05
commit 7767a5f5bb
No known key found for this signature in database

View file

@ -149,7 +149,7 @@ export default async function (o) {
useHLS = false;
}
let innertubeClient = "ANDROID";
let innertubeClient = o.innertubeClient || "ANDROID";
if (cookie) {
useHLS = false;
@ -245,7 +245,7 @@ export default async function (o) {
}
let video, audio, dubbedLanguage,
codec = o.format || "h264";
codec = o.format || "h264", itag = o.itag;
if (useHLS) {
const hlsManifest = info.streaming_data.hls_manifest_url;
@ -351,17 +351,21 @@ export default async function (o) {
Number(b.bitrate) - Number(a.bitrate)
).forEach(format => {
Object.keys(codecList).forEach(yCodec => {
const matchingItag = slot => !itag || itag[slot] === format.itag;
const sorted = sorted_formats[yCodec];
const goodFormat = checkFormat(format, yCodec);
if (!goodFormat) return;
if (format.has_video) {
if (format.has_video && matchingItag('video')) {
sorted.video.push(format);
if (!sorted.bestVideo) sorted.bestVideo = format;
if (!sorted.bestVideo)
sorted.bestVideo = format;
}
if (format.has_audio) {
if (format.has_audio && matchingItag('audio')) {
sorted.audio.push(format);
if (!sorted.bestAudio) sorted.bestAudio = format;
if (!sorted.bestAudio)
sorted.bestAudio = format;
}
})
});