diff --git a/src/Player.ts b/src/Player.ts index 539fda0..a9da7fb 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -305,9 +305,9 @@ class DiscordPlayer extends EventEmitter { // @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 { 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 }; } diff --git a/src/Structures/Track.ts b/src/Structures/Track.ts index 4ac2c0b..907b169 100644 --- a/src/Structures/Track.ts +++ b/src/Structures/Track.ts @@ -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 }); } /** diff --git a/src/utils/QueryResolver.ts b/src/utils/QueryResolver.ts index 42269b5..5713202 100644 --- a/src/utils/QueryResolver.ts +++ b/src/utils/QueryResolver.ts @@ -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;