fix video filenames

This commit is contained in:
hyperdefined 2024-07-18 10:48:13 -04:00
parent 82a1f6ce45
commit d7b4ee6c06
No known key found for this signature in database
GPG Key ID: EB0B55B31E88AB03
2 changed files with 19 additions and 3 deletions

View File

@ -99,7 +99,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
case "video":
switch (host) {
case "bilibili":
case "bilibili":
params = { type: "render" };
break;
case "youtube":

View File

@ -20,10 +20,26 @@ export default async function(obj) {
json = JSON.parse(req);
} catch { return { error: 'ErrorEmptyDownload' }; }
const highestQuality = Object.keys(json.sources)[0];
const video = json.sources[highestQuality][0].src
const video = json.sources[highestQuality][0].src;
if (!json.sources[highestQuality][0].type.includes('mp4')) {
return { error: 'ErrorEmptyDownload' };
}
let fileMetadata = {
title: cleanString(decodeURIComponent(json.title)),
artist: cleanString(decodeURIComponent(json.author)),
}
return {
urls: video
urls: video,
filenameAttributes: {
service: "newgrounds",
id: obj.id,
title: fileMetadata.title,
author: fileMetadata.artist,
extension: 'mp4'
},
fileMetadata,
}
}