mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-22 14:31:41 +00:00
api/youtube: add support for pinning client/itag
This commit is contained in:
parent
035825bc05
commit
7767a5f5bb
|
@ -149,7 +149,7 @@ export default async function (o) {
|
||||||
useHLS = false;
|
useHLS = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let innertubeClient = "ANDROID";
|
let innertubeClient = o.innertubeClient || "ANDROID";
|
||||||
|
|
||||||
if (cookie) {
|
if (cookie) {
|
||||||
useHLS = false;
|
useHLS = false;
|
||||||
|
@ -245,7 +245,7 @@ export default async function (o) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let video, audio, dubbedLanguage,
|
let video, audio, dubbedLanguage,
|
||||||
codec = o.format || "h264";
|
codec = o.format || "h264", itag = o.itag;
|
||||||
|
|
||||||
if (useHLS) {
|
if (useHLS) {
|
||||||
const hlsManifest = info.streaming_data.hls_manifest_url;
|
const hlsManifest = info.streaming_data.hls_manifest_url;
|
||||||
|
@ -351,17 +351,21 @@ export default async function (o) {
|
||||||
Number(b.bitrate) - Number(a.bitrate)
|
Number(b.bitrate) - Number(a.bitrate)
|
||||||
).forEach(format => {
|
).forEach(format => {
|
||||||
Object.keys(codecList).forEach(yCodec => {
|
Object.keys(codecList).forEach(yCodec => {
|
||||||
|
const matchingItag = slot => !itag || itag[slot] === format.itag;
|
||||||
const sorted = sorted_formats[yCodec];
|
const sorted = sorted_formats[yCodec];
|
||||||
const goodFormat = checkFormat(format, yCodec);
|
const goodFormat = checkFormat(format, yCodec);
|
||||||
if (!goodFormat) return;
|
if (!goodFormat) return;
|
||||||
|
|
||||||
if (format.has_video) {
|
if (format.has_video && matchingItag('video')) {
|
||||||
sorted.video.push(format);
|
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);
|
sorted.audio.push(format);
|
||||||
if (!sorted.bestAudio) sorted.bestAudio = format;
|
if (!sorted.bestAudio)
|
||||||
|
sorted.bestAudio = format;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue