🔥 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",
|
||||
"spotify-url-info": "^2.2.0",
|
||||
"youtube-sr": "^2.0.1",
|
||||
"ytdl-core": "^4.0.6",
|
||||
"ytpl": "^1.0.1"
|
||||
"ytdl-core": "^4.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@discordjs/opus": "^0.3.2",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const ytdl = require('discord-ytdl-core')
|
||||
const Discord = require('discord.js')
|
||||
const ytsr = require('youtube-sr')
|
||||
const ytpl = require('ytpl')
|
||||
const spotify = require('spotify-url-info')
|
||||
const soundcloud = require('soundcloud-scraper')
|
||||
const moment = require('moment')
|
||||
|
@ -291,19 +290,9 @@ class Player extends EventEmitter {
|
|||
* @param {String} 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)
|
||||
playlist.tracks = playlist.items.map((item) => new Track({
|
||||
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.tracks = playlist.videos.map((item) => new Track(item, message.author))
|
||||
playlist.duration = playlist.tracks.reduce((prev, next) => prev + next.duration, 0)
|
||||
playlist.thumbnail = playlist.tracks[0].thumbnail
|
||||
playlist.requestedBy = message.author
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
const ytpl = require('ytpl')
|
||||
const { Util: { PlaylistURLRegex: playlistURLRegex } } = require('youtube-sr')
|
||||
const soundcloud = require('soundcloud-scraper')
|
||||
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})/)
|
||||
|
||||
module.exports = class Util {
|
||||
|
|
Loading…
Reference in a new issue