i fucking hate youtube
youtube-related changes: - fixed silly mistake that made all shorts download in default format instead of preferred one - made youtube module return full video (audio + video) if it's available and matches selected quality (usually 720p) - changed the order of streams in video render (now video is first) other changes: - hopefully fixed zoom in on input in safari - moved match module from sub to main modules directory
This commit is contained in:
@@ -9,50 +9,50 @@ export default async function (obj) {
|
||||
if (info) {
|
||||
info = info.formats;
|
||||
if (!info[0]["isLive"]) {
|
||||
if (obj.isAudioOnly) {
|
||||
obj.format = "webm"
|
||||
obj.quality = "max"
|
||||
}
|
||||
let selectedVideo, videoMatch = [], video = [], audio = info.filter((a) => {
|
||||
if (!a["isLive"] && !a["isHLS"] && !a["isDashMPD"] && a["hasAudio"] && !a["hasVideo"] && a["container"] == obj.format) {
|
||||
return true;
|
||||
}
|
||||
let videoMatch = [], fullVideoMatch = [], video = [], audio = info.filter((a) => {
|
||||
if (!a["isHLS"] && !a["isDashMPD"] && a["hasAudio"] && !a["hasVideo"] && a["container"] == obj.format) return true;
|
||||
}).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
|
||||
if (!obj.isAudioOnly) {
|
||||
video = info.filter((a) => {
|
||||
if (!a["isLive"] && !a["isHLS"] && !a["isDashMPD"] && !a["hasAudio"] && a["hasVideo"] && a["container"] == obj.format && a["height"] != 4320) {
|
||||
if (obj.quality != "max" && mq[obj.quality] == a["height"]) {
|
||||
videoMatch.push(a)
|
||||
if (!a["isHLS"] && !a["isDashMPD"] && a["hasVideo"] && a["container"] == obj.format && a["height"] != 4320) {
|
||||
if (obj.quality != "max") {
|
||||
if (a["hasAudio"] && mq[obj.quality] == a["height"]) {
|
||||
fullVideoMatch.push(a)
|
||||
} else if (!a["hasAudio"] && mq[obj.quality] == a["height"]) {
|
||||
videoMatch.push(a);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
|
||||
selectedVideo = video[0]
|
||||
if (obj.quality != "max") {
|
||||
if (videoMatch.length > 0) {
|
||||
selectedVideo = videoMatch[0]
|
||||
} else {
|
||||
if (videoMatch.length == 0) {
|
||||
let ss = selectQuality("youtube", obj.quality, video[0]["height"])
|
||||
selectedVideo = video.filter((a) => {
|
||||
if (a["height"] == ss) {
|
||||
return true
|
||||
}
|
||||
videoMatch = video.filter((a) => {
|
||||
if (a["height"] == ss) return true;
|
||||
})
|
||||
selectedVideo = selectedVideo[0]
|
||||
} else if (fullVideoMatch.length > 0) {
|
||||
videoMatch = [fullVideoMatch[0]]
|
||||
}
|
||||
}
|
||||
if (obj.quality == "los") {
|
||||
selectedVideo = video[video.length - 1]
|
||||
}
|
||||
} else videoMatch = [video[0]];
|
||||
if (obj.quality == "los") videoMatch = [video[video.length - 1]];
|
||||
}
|
||||
if (audio[0]["approxDurationMs"] <= maxVideoDuration) {
|
||||
if (!obj.isAudioOnly && video.length > 0) {
|
||||
let filename = `youtube_${obj.id}_${selectedVideo["width"]}x${selectedVideo["height"]}.${obj.format}`;
|
||||
if (!obj.isAudioOnly && videoMatch.length > 0) {
|
||||
if (video.length > 0 && audio.length > 0) {
|
||||
return { type: "render", urls: [selectedVideo["url"], audio[0]["url"]], time: video[0]["approxDurationMs"], filename: filename };
|
||||
if (videoMatch[0]["hasVideo"] && videoMatch[0]["hasAudio"]) {
|
||||
return { type: "bridge", urls: videoMatch[0]["url"], time: videoMatch[0]["approxDurationMs"],
|
||||
filename: `youtube_${obj.id}_${videoMatch[0]["width"]}x${videoMatch[0]["height"]}.${obj.format}` };
|
||||
} else {
|
||||
return { type: "render", urls: [videoMatch[0]["url"], audio[0]["url"]], time: videoMatch[0]["approxDurationMs"],
|
||||
filename: `youtube_${obj.id}_${videoMatch[0]["width"]}x${videoMatch[0]["height"]}.${obj.format}` };
|
||||
}
|
||||
} else {
|
||||
return { error: loc('en', 'apiError', 'youtubeBroke') };
|
||||
}
|
||||
} else if (!obj.isAudioOnly) {
|
||||
return { type: "render", urls: [video[0]["url"], audio[0]["url"]], time: video[0]["approxDurationMs"],
|
||||
filename: `youtube_${obj.id}_${video[0]["width"]}x${video[0]["height"]}.${video[0]["container"]}` };
|
||||
} else if (audio.length > 0) {
|
||||
return { type: "render", isAudioOnly: true, urls: [audio[0]["url"]], filename: `youtube_${obj.id}_${audio[0]["audioBitrate"]}kbps.opus` };
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user