filename pattern customization

- added metadata for rutube and vimeo.
- added a picker for preferred filename pattern.
- fixed content disposition header.
- mute and audio dub tags don't appear together in a file name anymore.
- youtube: dub file name tag doesn't appear anymore if audio track is default.
This commit is contained in:
wukko
2023-10-12 23:14:54 +06:00
parent a57ee53b21
commit 16f74094b9
18 changed files with 249 additions and 59 deletions

View File

@@ -1,6 +1,6 @@
import { maxVideoDuration } from "../../config.js";
import { cleanString } from '../../sub/utils.js';
// vimeo you're fucked in the head for this
const resolutionMatch = {
"3840": "2160",
"2732": "1440",
@@ -33,6 +33,11 @@ export default async function(obj) {
let downloadType = "dash";
if (!obj.forceDash && JSON.stringify(api).includes('"progressive":[{')) downloadType = "progressive";
let fileMetadata = {
title: cleanString(api.video.title.replace(/\p{Emoji}/gu, '').trim()),
artist: cleanString(api.video.owner.name.replace(/\p{Emoji}/gu, '').trim()),
}
if (downloadType !== "dash") {
if (qualityMatch[quality]) quality = qualityMatch[quality];
let all = api["request"]["files"]["progressive"].sort((a, b) => Number(b.width) - Number(a.width));
@@ -43,7 +48,11 @@ export default async function(obj) {
if (Number(quality) < Number(bestQuality)) best = all.find(i => i["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` }
return {
urls: best["url"],
audioFilename: `vimeo_${obj.id}_audio`,
filename: `vimeo_${obj.id}_${best["width"]}x${best["height"]}.mp4`
}
}
if (api.video.duration > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
@@ -77,8 +86,16 @@ export default async function(obj) {
return {
urls: audioUrl ? [videoUrl, audioUrl] : videoUrl,
isM3U8: audioUrl ? false : true,
audioFilename: `vimeo_${obj.id}_audio`,
filename: `vimeo_${obj.id}_${bestVideo["width"]}x${bestVideo["height"]}.mp4`
fileMetadata: fileMetadata,
filenameAttributes: {
service: "vimeo",
id: obj.id,
title: fileMetadata.title,
author: fileMetadata.artist,
resolution: `${bestVideo["width"]}x${bestVideo["height"]}`,
qualityLabel: `${bestVideo["height"]}p`,
extension: "mp4"
}
}
}
return { error: 'ErrorEmptyDownload' }