Fix extracting music metadata with locales other than english

This commit is contained in:
absidue 2022-04-08 15:16:17 +02:00
parent bfed78d3d1
commit ffee49b9fb

View File

@ -218,15 +218,16 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
if (musicInfo) { if (musicInfo) {
musicInfo.forEach((x: any) => { musicInfo.forEach((x: any) => {
if (!x.metadataRowRenderer) return; if (!x.metadataRowRenderer) return;
const title = x.metadataRowRenderer.title.simpleText ?? x.metadataRowRenderer.title.runs[0].text; const row = x.metadataRowRenderer;
if (title.toLowerCase() === 'song') {
music.push({}); const title = row.title.simpleText ?? row.title.runs[0].text;
music[music.length - 1].song = const contents = row.contents[0].simpleText ?? row.contents[0]?.runs?.[0]?.text;
x.metadataRowRenderer.contents[0].simpleText ?? x.metadataRowRenderer.contents[0]?.runs?.[0]?.text;
} else if (music.length === 0) return; if (music.length === 0) music.push({});
else
music[music.length - 1][title.toLowerCase()] = music[music.length - 1][title.toLowerCase()] = contents;
x.metadataRowRenderer.contents[0].simpleText ?? x.metadataRowRenderer.contents[0]?.runs?.[0]?.text;
if (row.hasDividerLine) music.push({});
}); });
} }
const rawChapters = const rawChapters =