fix youtube playlist not playing

This commit is contained in:
Snowflake107 2021-06-14 13:13:31 +05:45
parent d5e3f6225c
commit 7f34fbd786
3 changed files with 10 additions and 10 deletions

View file

@ -305,9 +305,9 @@ class DiscordPlayer extends EventEmitter<PlayerEvents> {
// @todo: better way of handling large playlists
await ytpl.fetch().catch(() => {});
const playlist = new Playlist(this, {
const playlist: Playlist = new Playlist(this, {
title: ytpl.title,
thumbnail: ytpl.thumbnail?.displayThumbnailURL("maxresdefault"),
thumbnail: ytpl.thumbnail as unknown as string,
description: "",
type: "playlist",
source: "youtube",
@ -321,22 +321,22 @@ class DiscordPlayer extends EventEmitter<PlayerEvents> {
rawPlaylist: ytpl
});
for (const video of ytpl) {
playlist.tracks.push(
playlist.tracks = ytpl.videos.map(
(video) =>
new Track(this, {
title: video.title,
description: video.description,
author: video.channel?.name,
url: video.url,
requestedBy: options.requestedBy,
thumbnail: video.thumbnail?.displayThumbnailURL("maxresdefault"),
thumbnail: video.thumbnail.url,
views: video.views,
duration: video.durationFormatted,
raw: video,
playlist: playlist
playlist: playlist,
source: "youtube"
})
);
}
);
return { playlist: playlist, tracks: playlist.tracks };
}

View file

@ -106,7 +106,7 @@ class Track {
this.playlist = data.playlist;
// raw
Object.defineProperty(this, "raw", { get: () => data.raw ?? data, enumerable: false });
Object.defineProperty(this, "raw", { get: () => Object.assign({}, { source: data.raw?.source ?? data.source }, data.raw ?? data), enumerable: false });
}
/**

View file

@ -19,8 +19,8 @@ class QueryResolver {
static resolve(query: string): QueryType {
if (SoundcloudValidateURL(query, "track")) return QueryType.SOUNDCLOUD_TRACK;
if (SoundcloudValidateURL(query, "playlist") || query.includes("/sets/")) return QueryType.SOUNDCLOUD_PLAYLIST;
if (YouTube.isPlaylist(query)) return QueryType.YOUTUBE_PLAYLIST;
if (validateID(query) || validateURL(query)) return QueryType.YOUTUBE_SEARCH;
if (YouTube.validate(query, "PLAYLIST_ID")) return QueryType.YOUTUBE_PLAYLIST;
if (spotifySongRegex.test(query)) return QueryType.SPOTIFY_SONG;
if (spotifyPlaylistRegex.test(query)) return QueryType.SPOTIFY_PLAYLIST;
if (spotifyAlbumRegex.test(query)) return QueryType.SPOTIFY_ALBUM;