mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-12 20:25:06 +01:00
youtube: slight cleanup & deduplication
This commit is contained in:
parent
a4c7cc0d35
commit
946bec68c1
1 changed files with 17 additions and 22 deletions
|
@ -92,35 +92,30 @@ export default async function(o) {
|
||||||
}
|
}
|
||||||
const matchingQuality = Number(quality) > Number(bestQuality) ? bestQuality : quality,
|
const matchingQuality = Number(quality) > Number(bestQuality) ? bestQuality : quality,
|
||||||
checkSingle = i => qual(i) === matchingQuality && i.mime_type.includes(c[o.format].codec),
|
checkSingle = i => qual(i) === matchingQuality && i.mime_type.includes(c[o.format].codec),
|
||||||
checkRender = i => i.has_video && !i.has_audio && qual(i) === matchingQuality;
|
checkRender = i => qual(i) === matchingQuality && i.has_video && !i.has_audio;
|
||||||
|
|
||||||
|
let match, type, urls;
|
||||||
if (!o.isAudioOnly && !o.isAudioMuted && o.format === 'h264') {
|
if (!o.isAudioOnly && !o.isAudioMuted && o.format === 'h264') {
|
||||||
let single = info.streaming_data.formats.find(checkSingle);
|
match = info.streaming_data.formats.find(checkSingle);
|
||||||
if (single) {
|
type = "bridge";
|
||||||
filenameAttributes.qualityLabel = single.quality_label;
|
urls = match?.url;
|
||||||
filenameAttributes.resolution = `${single.width}x${single.height}`;
|
|
||||||
filenameAttributes.extension = c[o.format].container;
|
|
||||||
filenameAttributes.youtubeFormat = o.format;
|
|
||||||
return {
|
|
||||||
type: "bridge",
|
|
||||||
urls: single.url,
|
|
||||||
filenameAttributes: filenameAttributes,
|
|
||||||
fileMetadata: fileMetadata
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let video = adaptive_formats.find(checkRender);
|
const video = adaptive_formats.find(checkRender);
|
||||||
if (video && audio) {
|
if (!match && video) {
|
||||||
filenameAttributes.qualityLabel = video.quality_label;
|
match = video;
|
||||||
filenameAttributes.resolution = `${video.width}x${video.height}`;
|
type = "render";
|
||||||
|
urls = [video.url, audio.url];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
filenameAttributes.qualityLabel = match.quality_label;
|
||||||
|
filenameAttributes.resolution = `${match.width}x${match.height}`;
|
||||||
filenameAttributes.extension = c[o.format].container;
|
filenameAttributes.extension = c[o.format].container;
|
||||||
filenameAttributes.youtubeFormat = o.format;
|
filenameAttributes.youtubeFormat = o.format;
|
||||||
return {
|
return {
|
||||||
type: "render",
|
type, urls,
|
||||||
urls: [video.url, audio.url],
|
filenameAttributes, fileMetadata
|
||||||
filenameAttributes: filenameAttributes,
|
|
||||||
fileMetadata: fileMetadata
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue