diff --git a/package.json b/package.json index 13f4d07..a2b82da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player-play-dl", - "version": "5.3.3", + "version": "5.3.4", "description": "Complete framework to facilitate music commands using discord.js and play-dl", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -65,8 +65,7 @@ "play-dl": "^1.9.5", "spotify-url-info": "^3.1.2", "tiny-typed-emitter": "^2.1.0", - "tslib": "^2.4.0", - "youtube-sr": "^4.3.0" + "tslib": "^2.4.0" }, "devDependencies": { "@discordjs/ts-docgen": "^0.4.1", diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index f6f14c6..fca2d77 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -5,7 +5,6 @@ import Track from "./Track"; import { PlayerOptions, PlayerProgressbarOptions, PlayOptions, QueueFilters, QueueRepeatMode, TrackSource } from "../types/types"; import { AudioResource, StreamType } from "@discordjs/voice"; import play from "play-dl"; -import YouTube from "youtube-sr"; import { Util } from "../utils/Util"; import AudioFilters from "../utils/AudioFilters"; import { PlayerError, ErrorStatusCode } from "./PlayerError"; @@ -692,44 +691,21 @@ class Queue { if (this.options.leaveOnEnd) this.destroy(); return void this.player.emit("queueEnd", this); } - // const info = await play.video_info(track.url).catch(Util.noop); - // if (!info) { - // if (this.options.leaveOnEnd) this.destroy(); - // return void this.player.emit("queueEnd", this); - // } - - // const related = await play.video_info(info.related_videos[1]); - // const nextTrack = new Track(this.player, { - // title: related.video_details.title, - // url: related.video_details.url, - // duration: related.video_details.durationRaw ? Util.buildTimeCode(Util.parseMS(related.video_details.durationInSec * 1000)) : "0:00", - // description: "", - // thumbnail: Util.last(related.video_details.thumbnails).url, - // views: related.video_details.views, - // author: related.video_details.channel.name, - // requestedBy: track.requestedBy, - // source: "youtube" - // }); - let info = await YouTube.getVideo(track.url) - .then((x) => x.videos[0]) - .catch(Util.noop); - if (!info) - info = await YouTube.search(track.author) - .then((x) => x[0]) - .catch(Util.noop); + const info = await play.video_info(track.url).catch(Util.noop); if (!info) { if (this.options.leaveOnEnd) this.destroy(); return void this.player.emit("queueEnd", this); } + const related = await play.video_info(info.related_videos[Math.floor(Math.random() * info.related_videos.length + 1)]); const nextTrack = new Track(this.player, { - title: info.title, - url: `https://www.youtube.com/watch?v=${info.id}`, - duration: info.durationFormatted ? Util.buildTimeCode(Util.parseMS(info.duration * 1000)) : "0:00", + title: related.video_details.title, + url: related.video_details.url, + duration: related.video_details.durationRaw ? Util.buildTimeCode(Util.parseMS(related.video_details.durationInSec * 1000)) : "0:00", description: "", - thumbnail: typeof info.thumbnail === "string" ? info.thumbnail : info.thumbnail.url, - views: info.views, - author: info.channel.name, + thumbnail: Util.last(related.video_details.thumbnails).url, + views: related.video_details.views, + author: related.video_details.channel.name, requestedBy: track.requestedBy, source: "youtube" }); diff --git a/yarn.lock b/yarn.lock index 260fa20..c2f81bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1511,8 +1511,3 @@ "integrity" "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==" "resolved" "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz" "version" "0.1.0" - -"youtube-sr@^4.3.0": - "integrity" "sha512-cRMOeJZi/DYIRqru0R9UsBLwkj4tQvekldnCj4MZOT+ijlfesrllbUDXqKuA2RbYA4ByJlFf9wxZ1ndvuCJ5Ow==" - "resolved" "https://registry.npmjs.org/youtube-sr/-/youtube-sr-4.3.0.tgz" - "version" "4.3.0"