Откат к старому автопроигрыванию
This commit is contained in:
parent
cdf816dc5a
commit
bec9c0b940
3 changed files with 39 additions and 10 deletions
|
@ -32,7 +32,7 @@
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"DevAndromeda <devandromeda@snowflakedev.org>",
|
"DevAndromeda <devandromeda@snowflakedev.org>",
|
||||||
"Jonny_Bro#4226"
|
"Jonny_Bro#4226"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -65,7 +65,8 @@
|
||||||
"play-dl": "^1.9.5",
|
"play-dl": "^1.9.5",
|
||||||
"spotify-url-info": "^3.1.2",
|
"spotify-url-info": "^3.1.2",
|
||||||
"tiny-typed-emitter": "^2.1.0",
|
"tiny-typed-emitter": "^2.1.0",
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0",
|
||||||
|
"youtube-sr": "^4.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@discordjs/ts-docgen": "^0.4.1",
|
"@discordjs/ts-docgen": "^0.4.1",
|
||||||
|
|
|
@ -5,6 +5,7 @@ import Track from "./Track";
|
||||||
import { PlayerOptions, PlayerProgressbarOptions, PlayOptions, QueueFilters, QueueRepeatMode, TrackSource } from "../types/types";
|
import { PlayerOptions, PlayerProgressbarOptions, PlayOptions, QueueFilters, QueueRepeatMode, TrackSource } from "../types/types";
|
||||||
import { AudioResource, StreamType } from "@discordjs/voice";
|
import { AudioResource, StreamType } from "@discordjs/voice";
|
||||||
import play from "play-dl";
|
import play from "play-dl";
|
||||||
|
import YouTube from "youtube-sr";
|
||||||
import { Util } from "../utils/Util";
|
import { Util } from "../utils/Util";
|
||||||
import AudioFilters from "../utils/AudioFilters";
|
import AudioFilters from "../utils/AudioFilters";
|
||||||
import { PlayerError, ErrorStatusCode } from "./PlayerError";
|
import { PlayerError, ErrorStatusCode } from "./PlayerError";
|
||||||
|
@ -691,21 +692,43 @@ class Queue<T = unknown> {
|
||||||
if (this.options.leaveOnEnd) this.destroy();
|
if (this.options.leaveOnEnd) this.destroy();
|
||||||
return void this.player.emit("queueEnd", this);
|
return void this.player.emit("queueEnd", this);
|
||||||
}
|
}
|
||||||
const info = await play.video_info(track.url).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[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);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
if (this.options.leaveOnEnd) this.destroy();
|
if (this.options.leaveOnEnd) this.destroy();
|
||||||
return void this.player.emit("queueEnd", this);
|
return void this.player.emit("queueEnd", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const related = await play.video_info(info.related_videos[1]);
|
|
||||||
const nextTrack = new Track(this.player, {
|
const nextTrack = new Track(this.player, {
|
||||||
title: related.video_details.title,
|
title: info.title,
|
||||||
url: related.video_details.url,
|
url: `https://www.youtube.com/watch?v=${info.id}`,
|
||||||
duration: related.video_details.durationRaw ? Util.buildTimeCode(Util.parseMS(related.video_details.durationInSec * 1000)) : "0:00",
|
duration: info.durationFormatted ? Util.buildTimeCode(Util.parseMS(info.duration * 1000)) : "0:00",
|
||||||
description: "",
|
description: "",
|
||||||
thumbnail: Util.last(related.video_details.thumbnails).url,
|
thumbnail: typeof info.thumbnail === "string" ? info.thumbnail : info.thumbnail.url,
|
||||||
views: related.video_details.views,
|
views: info.views,
|
||||||
author: related.video_details.channel.name,
|
author: info.channel.name,
|
||||||
requestedBy: track.requestedBy,
|
requestedBy: track.requestedBy,
|
||||||
source: "youtube"
|
source: "youtube"
|
||||||
});
|
});
|
||||||
|
|
|
@ -1511,3 +1511,8 @@
|
||||||
"integrity" "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="
|
"integrity" "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="
|
||||||
"resolved" "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"
|
"resolved" "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"
|
||||||
"version" "0.1.0"
|
"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"
|
||||||
|
|
Loading…
Reference in a new issue