Skip to content

Commit

Permalink
Fix music info extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue committed Jan 8, 2022
1 parent bdafb9b commit bf98146
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions play-dl/YouTube/utils/extractor.ts
Expand Up @@ -212,13 +212,14 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
if (musicInfo) {
musicInfo.forEach((x: any) => {
if (!x.metadataRowRenderer) return;
if (x.metadataRowRenderer.title.simpleText.toLowerCase() === 'song') {
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][x.metadataRowRenderer.title.simpleText.toLowerCase()] =
music[music.length - 1][title.toLowerCase()] =
x.metadataRowRenderer.contents[0].simpleText ?? x.metadataRowRenderer.contents[0]?.runs?.[0]?.text;
});
}
Expand Down

0 comments on commit bf98146

Please sign in to comment.