From ffee49b9fb82058d1e67d4fe73ef04eccfd20cb7 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Fri, 8 Apr 2022 15:16:17 +0200 Subject: [PATCH] Fix extracting music metadata with locales other than english --- play-dl/YouTube/utils/extractor.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/play-dl/YouTube/utils/extractor.ts b/play-dl/YouTube/utils/extractor.ts index 4a0d90c..0d0a4dd 100644 --- a/play-dl/YouTube/utils/extractor.ts +++ b/play-dl/YouTube/utils/extractor.ts @@ -218,15 +218,16 @@ export async function video_basic_info(url: string, options: InfoOptions = {}): if (musicInfo) { musicInfo.forEach((x: any) => { if (!x.metadataRowRenderer) return; - const title = x.metadataRowRenderer.title.simpleText ?? x.metadataRowRenderer.title.runs[0].text; - if (title.toLowerCase() === 'song') { - music.push({}); - music[music.length - 1].song = - x.metadataRowRenderer.contents[0].simpleText ?? x.metadataRowRenderer.contents[0]?.runs?.[0]?.text; - } else if (music.length === 0) return; - else - music[music.length - 1][title.toLowerCase()] = - x.metadataRowRenderer.contents[0].simpleText ?? x.metadataRowRenderer.contents[0]?.runs?.[0]?.text; + const row = x.metadataRowRenderer; + + const title = row.title.simpleText ?? row.title.runs[0].text; + const contents = row.contents[0].simpleText ?? row.contents[0]?.runs?.[0]?.text; + + if (music.length === 0) music.push({}); + + music[music.length - 1][title.toLowerCase()] = contents; + + if (row.hasDividerLine) music.push({}); }); } const rawChapters =