🔥 Remove ytpl and use youtube-sr
This commit is contained in:
parent
c0a0657e23
commit
fdbd2b5839
3 changed files with 4 additions and 17 deletions
|
@ -37,8 +37,7 @@
|
||||||
"soundcloud-scraper": "^4.0.0",
|
"soundcloud-scraper": "^4.0.0",
|
||||||
"spotify-url-info": "^2.2.0",
|
"spotify-url-info": "^2.2.0",
|
||||||
"youtube-sr": "^2.0.1",
|
"youtube-sr": "^2.0.1",
|
||||||
"ytdl-core": "^4.0.6",
|
"ytdl-core": "^4.0.6"
|
||||||
"ytpl": "^1.0.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@discordjs/opus": "^0.3.2",
|
"@discordjs/opus": "^0.3.2",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
const ytdl = require('discord-ytdl-core')
|
const ytdl = require('discord-ytdl-core')
|
||||||
const Discord = require('discord.js')
|
const Discord = require('discord.js')
|
||||||
const ytsr = require('youtube-sr')
|
const ytsr = require('youtube-sr')
|
||||||
const ytpl = require('ytpl')
|
|
||||||
const spotify = require('spotify-url-info')
|
const spotify = require('spotify-url-info')
|
||||||
const soundcloud = require('soundcloud-scraper')
|
const soundcloud = require('soundcloud-scraper')
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
|
@ -291,19 +290,9 @@ class Player extends EventEmitter {
|
||||||
* @param {String} query
|
* @param {String} query
|
||||||
*/
|
*/
|
||||||
async _handlePlaylist (message, query) {
|
async _handlePlaylist (message, query) {
|
||||||
const playlist = await ytpl(query).catch(() => {})
|
const playlist = await ytsr.getPlaylist(query)
|
||||||
if (!playlist) return this.emit('noResults', message, query)
|
if (!playlist) return this.emit('noResults', message, query)
|
||||||
playlist.tracks = playlist.items.map((item) => new Track({
|
playlist.tracks = playlist.videos.map((item) => new Track(item, message.author))
|
||||||
title: item.title,
|
|
||||||
description: item.description,
|
|
||||||
views: item.views,
|
|
||||||
durationFormatted: item.duration,
|
|
||||||
url: item.url,
|
|
||||||
thumbnail: item.thumbnail,
|
|
||||||
channel: {
|
|
||||||
name: item.author.name
|
|
||||||
}
|
|
||||||
}, message.author))
|
|
||||||
playlist.duration = playlist.tracks.reduce((prev, next) => prev + next.duration, 0)
|
playlist.duration = playlist.tracks.reduce((prev, next) => prev + next.duration, 0)
|
||||||
playlist.thumbnail = playlist.tracks[0].thumbnail
|
playlist.thumbnail = playlist.tracks[0].thumbnail
|
||||||
playlist.requestedBy = message.author
|
playlist.requestedBy = message.author
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
const ytpl = require('ytpl')
|
|
||||||
const { Util: { PlaylistURLRegex: playlistURLRegex } } = require('youtube-sr')
|
const { Util: { PlaylistURLRegex: playlistURLRegex } } = require('youtube-sr')
|
||||||
const soundcloud = require('soundcloud-scraper')
|
const soundcloud = require('soundcloud-scraper')
|
||||||
const Discord = require('discord.js')
|
const Discord = require('discord.js')
|
||||||
|
|
||||||
const youtubeVideoRegex = (/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/)
|
const youtubeVideoRegex = (/(?:youtube\.com\/(?:[^/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?/\s]{11})/)
|
||||||
const spotifySongRegex = (/https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/)
|
const spotifySongRegex = (/https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/)
|
||||||
|
|
||||||
module.exports = class Util {
|
module.exports = class Util {
|
||||||
|
|
Loading…
Reference in a new issue