mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-30 20:24:25 +00:00
Pretty Code + Music property added in YouTube Video
This commit is contained in:
@@ -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 ?? []));
|
||||
|
||||
Reference in New Issue
Block a user