Added URL support for the Video Music properties with typings
This commit is contained in:
parent
9b9c68ef13
commit
b523c4f394
@ -2,13 +2,18 @@ import { YouTubeChannel } from './Channel';
|
|||||||
import { YouTubeThumbnail } from './Thumbnail';
|
import { YouTubeThumbnail } from './Thumbnail';
|
||||||
|
|
||||||
interface VideoMusic {
|
interface VideoMusic {
|
||||||
song?: string;
|
song?: MusicEntry;
|
||||||
artist?: string;
|
artist?: string | MusicEntry;
|
||||||
album?: string;
|
album?: string;
|
||||||
writers?: string;
|
writers?: string;
|
||||||
license?: string;
|
license?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MusicEntry {
|
||||||
|
text?: string;
|
||||||
|
url?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
interface VideoOptions {
|
interface VideoOptions {
|
||||||
/**
|
/**
|
||||||
* YouTube Video ID
|
* YouTube Video ID
|
||||||
|
|||||||
@ -223,7 +223,7 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
|||||||
let url = x.metadataRowRenderer.contents[0]?.runs?.[0]?.navigationEndpoint?.commandMetadata?.webCommandMetadata.url;
|
let url = x.metadataRowRenderer.contents[0]?.runs?.[0]?.navigationEndpoint?.commandMetadata?.webCommandMetadata.url;
|
||||||
if (title.toLowerCase() === 'song') {
|
if (title.toLowerCase() === 'song') {
|
||||||
music.push({});
|
music.push({});
|
||||||
music[music.length - 1].song = url ? {text, url: `https://www.youtube.com${url}`} : text;
|
music[music.length - 1].song = {text, url: url ? `https://www.youtube.com${url}` : undefined};
|
||||||
} else if (music.length === 0) return;
|
} else if (music.length === 0) return;
|
||||||
else {
|
else {
|
||||||
music[music.length - 1][title.toLowerCase()] = url ? {text, url: `https://www.youtube.com${url}`} : text;
|
music[music.length - 1][title.toLowerCase()] = url ? {text, url: `https://www.youtube.com${url}`} : text;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user