api/stream/types: convert metadata in one place

also sanitize values & throw an error if tag isn't supported
This commit is contained in:
wukko
2024-11-24 18:13:22 +06:00
parent 6770738116
commit 1cbffc2d75
2 changed files with 23 additions and 20 deletions

View File

@@ -1,22 +1,3 @@
export function convertMetadataToFFmpeg(obj) {
const keys = Object.keys(obj);
const tags = [
"album",
"copyright",
"title",
"artist",
"track",
"date"
]
let commands = []
for (const i in keys) {
if (tags.includes(keys[i]))
commands.push('-metadata', `${keys[i]}=${obj[keys[i]]}`)
}
return commands;
}
export function getRedirectingURL(url) {
return fetch(url, { redirect: 'manual' }).then((r) => {
if ([301, 302, 303].includes(r.status) && r.headers.has('location'))