defaultIcon and music fix
This commit is contained in:
parent
5583d99ab4
commit
fc6007b472
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "1.9.5",
|
"version": "1.9.6",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "1.9.5",
|
"version": "1.9.6",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"play-audio": "^0.5.2"
|
"play-audio": "^0.5.2"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "1.9.5",
|
"version": "1.9.6",
|
||||||
"description": "YouTube, SoundCloud, Spotify, Deezer searching and streaming for discord-js bots",
|
"description": "YouTube, SoundCloud, Spotify, Deezer searching and streaming for discord-js bots",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
|||||||
@ -212,24 +212,22 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
const microformat = player_response.microformat.playerMicroformatRenderer;
|
const microformat = player_response.microformat.playerMicroformatRenderer;
|
||||||
const musicInfo =
|
const musicInfo = initial_response.engagementPanels.find((item: any) => item?.engagementPanelSectionListRenderer?.panelIdentifier == 'engagement-panel-structured-description')?.engagementPanelSectionListRenderer.content.structuredDescriptionContentRenderer.items
|
||||||
initial_response.contents.twoColumnWatchNextResults.results.results.contents?.[1]?.videoSecondaryInfoRenderer
|
.find((el: any) => el.videoDescriptionMusicSectionRenderer)?.videoDescriptionMusicSectionRenderer.carouselLockups;
|
||||||
?.metadataRowContainer?.metadataRowContainerRenderer?.rows;
|
|
||||||
const music: any[] = [];
|
const music: any[] = [];
|
||||||
if (musicInfo) {
|
if (musicInfo) {
|
||||||
musicInfo.forEach((x: any) => {
|
musicInfo.forEach((x: any) => {
|
||||||
if (!x.metadataRowRenderer) return;
|
if (!x.carouselLockupRenderer) return;
|
||||||
const row = x.metadataRowRenderer;
|
const row = x.carouselLockupRenderer;
|
||||||
|
|
||||||
const title = row.title.simpleText ?? row.title.runs[0].text;
|
const song = row.videoLockup?.compactVideoRenderer.title.simpleText ?? row.videoLockup?.compactVideoRenderer.title.runs?.find((x:any) => x.text)?.text;
|
||||||
const contents = row.contents[0].simpleText ?? row.contents[0]?.runs?.[0]?.text;
|
const metadata = row.infoRows?.map((info: any) => [info.infoRowRenderer.title.simpleText.toLowerCase(), ((info.infoRowRenderer.expandedMetadata ?? info.infoRowRenderer.defaultMetadata)?.runs?.map((i:any) => i.text).join("")) ?? info.infoRowRenderer.defaultMetadata?.simpleText ?? info.infoRowRenderer.expandedMetadata?.simpleText ?? ""]);
|
||||||
const url = row.contents[0]?.runs?.[0]?.navigationEndpoint?.commandMetadata?.webCommandMetadata.url;
|
const contents = Object.fromEntries(metadata ?? {});
|
||||||
|
const id = row.videoLockup?.compactVideoRenderer.navigationEndpoint?.watchEndpoint.videoId
|
||||||
|
?? row.infoRows?.find((x: any) => x.infoRowRenderer.title.simpleText.toLowerCase() == "song")?.infoRowRenderer.defaultMetadata.runs?.find((x: any) => x.navigationEndpoint)?.navigationEndpoint.watchEndpoint?.videoId;
|
||||||
|
|
||||||
if (music.length === 0) music.push({});
|
music.push({song, url: id ? `https://www.youtube.com/watch?v=${id}` : null, ...contents})
|
||||||
|
|
||||||
music[music.length - 1][title.toLowerCase()] = url ? {text: contents, url: `https://www.youtube.com${url}`} : contents;
|
|
||||||
|
|
||||||
if (row.hasDividerLine) music.push({});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const rawChapters =
|
const rawChapters =
|
||||||
@ -258,6 +256,13 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
|||||||
upcomingDate = new Date(parseInt(timestamp) * 1000);
|
upcomingDate = new Date(parseInt(timestamp) * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const likeRenderer = initial_response.contents.twoColumnWatchNextResults.results.results.contents
|
||||||
|
.find((content: any) => content.videoPrimaryInfoRenderer)
|
||||||
|
?.videoPrimaryInfoRenderer.videoActions.menuRenderer.topLevelButtons?.find(
|
||||||
|
(button: any) => button.toggleButtonRenderer?.defaultIcon.iconType === 'LIKE' || button.segmentedLikeDislikeButtonRenderer?.likeButton.toggleButtonRenderer?.defaultIcon.iconType === 'LIKE'
|
||||||
|
)
|
||||||
|
|
||||||
const video_details = new YouTubeVideo({
|
const video_details = new YouTubeVideo({
|
||||||
id: vid.videoId,
|
id: vid.videoId,
|
||||||
title: vid.title,
|
title: vid.title,
|
||||||
@ -279,12 +284,8 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
|||||||
views: vid.viewCount,
|
views: vid.viewCount,
|
||||||
tags: vid.keywords,
|
tags: vid.keywords,
|
||||||
likes: parseInt(
|
likes: parseInt(
|
||||||
initial_response.contents.twoColumnWatchNextResults.results.results.contents
|
likeRenderer?.toggleButtonRenderer?.defaultText.accessibility?.accessibilityData.label.replace(/\D+/g, '') ??
|
||||||
.find((content: any) => content.videoPrimaryInfoRenderer)
|
likeRenderer?.segmentedLikeDislikeButtonRenderer?.likeButton.toggleButtonRenderer?.defaultText.accessibility?.accessibilityData.label.replace(/\D+/g, '') ?? 0
|
||||||
?.videoPrimaryInfoRenderer.videoActions.menuRenderer.topLevelButtons?.find(
|
|
||||||
(button: any) => button.toggleButtonRenderer.defaultIcon.iconType === 'LIKE'
|
|
||||||
)
|
|
||||||
?.toggleButtonRenderer.defaultText.accessibility?.accessibilityData.label.replace(/\D+/g, '') ?? 0
|
|
||||||
),
|
),
|
||||||
live: vid.isLiveContent,
|
live: vid.isLiveContent,
|
||||||
private: vid.isPrivate,
|
private: vid.isPrivate,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user