Pretty Code + Music property added in YouTube Video

This commit is contained in:
killer069
2022-01-03 15:59:32 +05:30
parent 433ec4976b
commit ffbe882037
9 changed files with 78 additions and 39 deletions

View File

@@ -200,6 +200,25 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
}
);
const microformat = player_response.microformat.playerMicroformatRenderer;
const musicInfo =
initial_response.contents.twoColumnWatchNextResults.results.results.contents?.[1]?.videoSecondaryInfoRenderer
?.metadataRowContainer?.metadataRowContainerRenderer?.rows;
const music: any[] = [];
if (musicInfo) {
let incompleteInfo: any = {};
musicInfo.forEach((x: any) => {
if (!x.metadataRowRenderer) return;
if (x.metadataRowRenderer.title.simpleText.toLowerCase() === 'song') {
music.push(incompleteInfo);
incompleteInfo = {};
incompleteInfo.song =
x.metadataRowRenderer.contents[0].simpleText ?? x.metadataRowRenderer.contents[0]?.runs?.[0]?.text;
} else
incompleteInfo[x.metadataRowRenderer.title.simpleText.toLowerCase()] =
x.metadataRowRenderer.contents[0].simpleText ?? x.metadataRowRenderer.contents[0]?.runs?.[0]?.text;
});
}
music.shift();
const video_details = new YouTubeVideo({
id: vid.videoId,
title: vid.title,
@@ -228,7 +247,8 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
),
live: vid.isLiveContent,
private: vid.isPrivate,
discretionAdvised
discretionAdvised,
music
});
const format = player_response.streamingData.formats ?? [];
format.push(...(player_response.streamingData.adaptiveFormats ?? []));