🔥 Remove ytpl and use youtube-sr

This commit is contained in:
Androz2091 2020-11-23 21:17:09 +01:00
parent c0a0657e23
commit fdbd2b5839
3 changed files with 4 additions and 17 deletions

View file

@ -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",

View file

@ -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

View file

@ -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 {