mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-12 11:52:12 +01:00
youtube: clean up
This commit is contained in:
parent
946bec68c1
commit
e85b2ace14
1 changed files with 10 additions and 8 deletions
|
@ -40,22 +40,22 @@ export default async function(o) {
|
||||||
if (info.basic_info.is_live) return { error: 'ErrorLiveVideo' };
|
if (info.basic_info.is_live) return { error: 'ErrorLiveVideo' };
|
||||||
|
|
||||||
let bestQuality, hasAudio, adaptive_formats = info.streaming_data.adaptive_formats.filter(e =>
|
let bestQuality, hasAudio, adaptive_formats = info.streaming_data.adaptive_formats.filter(e =>
|
||||||
e["mime_type"].includes(c[o.format].codec) || e["mime_type"].includes(c[o.format].aCodec)
|
e.mime_type.includes(c[o.format].codec) || e.mime_type.includes(c[o.format].aCodec)
|
||||||
).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
|
).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
|
||||||
|
|
||||||
bestQuality = adaptive_formats.find(i => i["has_video"]);
|
bestQuality = adaptive_formats.find(i => i.has_video);
|
||||||
hasAudio = adaptive_formats.find(i => i["has_audio"]);
|
hasAudio = adaptive_formats.find(i => i.has_audio);
|
||||||
|
|
||||||
if (bestQuality) bestQuality = qual(bestQuality);
|
if (bestQuality) bestQuality = qual(bestQuality);
|
||||||
if (!bestQuality && !o.isAudioOnly || !hasAudio) return { error: 'ErrorYTTryOtherCodec' };
|
if (!bestQuality && !o.isAudioOnly || !hasAudio) return { error: 'ErrorYTTryOtherCodec' };
|
||||||
if (info.basic_info.duration > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
|
if (info.basic_info.duration > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
|
||||||
|
|
||||||
let checkBestAudio = (i) => (i["has_audio"] && !i["has_video"]),
|
let checkBestAudio = (i) => (i.has_audio && !i.has_video),
|
||||||
audio = adaptive_formats.find(i => checkBestAudio(i) && !i["is_dubbed"]);
|
audio = adaptive_formats.find(i => checkBestAudio(i) && !i.is_dubbed);
|
||||||
|
|
||||||
if (o.dubLang) {
|
if (o.dubLang) {
|
||||||
let dubbedAudio = adaptive_formats.find(i =>
|
let dubbedAudio = adaptive_formats.find(i =>
|
||||||
checkBestAudio(i) && i["language"] === o.dubLang && i["audio_track"] && !i["audio_track"].audio_is_default
|
checkBestAudio(i) && i.language === o.dubLang && i.audio_track && !i.audio_track.audio_is_default
|
||||||
);
|
);
|
||||||
if (dubbedAudio) {
|
if (dubbedAudio) {
|
||||||
audio = dubbedAudio;
|
audio = dubbedAudio;
|
||||||
|
@ -114,8 +114,10 @@ export default async function(o) {
|
||||||
filenameAttributes.extension = c[o.format].container;
|
filenameAttributes.extension = c[o.format].container;
|
||||||
filenameAttributes.youtubeFormat = o.format;
|
filenameAttributes.youtubeFormat = o.format;
|
||||||
return {
|
return {
|
||||||
type, urls,
|
type,
|
||||||
filenameAttributes, fileMetadata
|
urls,
|
||||||
|
filenameAttributes,
|
||||||
|
fileMetadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue