Support unlisted and direct url for YouTube

This commit is contained in:
2022-01-30 21:35:56 +07:00
parent 0759290306
commit 040eab96ef
+24 -1
View File
@@ -237,7 +237,30 @@ class DiscordMusicPlayer {
} }
} }
// TODO: Construct our own YouTubeVideo for unlisted videos or somehow the search failed let yt_info = await playdl.video_info("https://www.youtube.com/watch?v=" + youtubeLink.videoId);
if(yt_info) {
return new YouTubeVideo({
id: yt_info.video_details.id,
url: yt_info.video_details.url,
type: yt_info.video_details.type,
title: yt_info.video_details.title,
description: yt_info.video_details.description,
durationRaw: yt_info.video_details.durationRaw,
durationInSec: yt_info.video_details.durationInSec,
uploadedAt: yt_info.video_details.uploadedAt,
upcoming: yt_info.video_details.upcoming,
views: yt_info.video_details.views,
thumbnails: yt_info.video_details.thumbnails,
channel: yt_info.video_details.channel,
likes: yt_info.video_details.likes,
live: yt_info.video_details.live,
private: yt_info.video_details.private,
tags: yt_info.video_details.tags,
discretionAdvised: yt_info.video_details.discretionAdvised,
music: yt_info.video_details.music
});
}
return null; return null;
} }