vimeo: remove progressive parsing

it's no longer returned by the api
This commit is contained in:
wukko 2024-06-23 23:15:05 +06:00
parent 0432232ea4
commit cc4abbb3e2
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -16,16 +16,6 @@ const resolutionMatch = {
"426": "240" "426": "240"
} }
const qualityMatch = {
"2160": "4K",
"1440": "2K",
"480": "540",
"4K": "2160",
"2K": "1440",
"540": "480"
}
export default async function(obj) { export default async function(obj) {
let quality = obj.quality === "max" ? "9000" : obj.quality; let quality = obj.quality === "max" ? "9000" : obj.quality;
if (!quality || obj.isAudioOnly) quality = "9000"; if (!quality || obj.isAudioOnly) quality = "9000";
@ -40,40 +30,11 @@ export default async function(obj) {
.catch(() => {}); .catch(() => {});
if (!api) return { error: 'ErrorCouldntFetch' }; if (!api) return { error: 'ErrorCouldntFetch' };
let downloadType = "dash";
if (!obj.isAudioOnly && JSON.stringify(api).includes('"progressive":[{'))
downloadType = "progressive";
const fileMetadata = { const fileMetadata = {
title: cleanString(api.video.title.trim()), title: cleanString(api.video.title.trim()),
artist: cleanString(api.video.owner.name.trim()), artist: cleanString(api.video.owner.name.trim()),
} }
if (downloadType !== "dash") {
if (qualityMatch[quality]) quality = qualityMatch[quality];
const all = api.request.files.progressive.sort((a, b) => Number(b.width) - Number(a.width));
let best = all[0];
let bestQuality = all[0].quality.split('p')[0];
if (qualityMatch[bestQuality]) {
bestQuality = qualityMatch[bestQuality]
}
if (Number(quality) < Number(bestQuality)) {
best = all.find(v => v.quality.split('p')[0] === quality);
}
if (!best) return { error: 'ErrorEmptyDownload' };
return {
urls: best.url,
audioFilename: `vimeo_${obj.id}_audio`,
filename: `vimeo_${obj.id}_${best.width}x${best.height}.mp4`
}
}
if (api.video.duration > env.durationLimit) if (api.video.duration > env.durationLimit)
return { error: ['ErrorLengthLimit', env.durationLimit / 60] }; return { error: ['ErrorLengthLimit', env.durationLimit / 60] };