Small Patch for Spotify

Small Patch for spotify
This commit is contained in:
Killer069 2021-09-06 11:14:15 +05:30 committed by GitHub
commit 9646c6d46f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "play-dl",
"version": "0.8.1",
"version": "0.8.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "play-dl",
"version": "0.8.1",
"version": "0.8.2",
"license": "MIT",
"dependencies": {
"got": "^11.8.2"

View File

@ -1,6 +1,6 @@
{
"name": "play-dl",
"version": "0.8.1",
"version": "0.8.2",
"description": "YouTube, SoundCloud, Spotify streaming for discord.js bots",
"main": "dist/index.js",
"typings": "dist/index.d.ts",

View File

@ -26,15 +26,15 @@ function parse_json(url : string, data : string): SpotifyAlbum | SpotifyPlaylist
}
function embed_url(url : string): string{
if(url.indexOf('track') !== -1){
if(url.indexOf('track/') !== -1){
let trackID = url.split('track/')[1].split('?')[0].split('/')[0].split('&')[0]
return `https://open.spotify.com/embed/track/${trackID}`
}
else if(url.indexOf('album') !== -1){
else if(url.indexOf('album/') !== -1){
let albumID = url.split('album/')[1].split('?')[0].split('/')[0].split('&')[0]
return `https://open.spotify.com/embed/album/${albumID}`
}
else if(url.indexOf('playlist') !== -1){
else if(url.indexOf('playlist/') !== -1){
let playlistID = url.split('playlist/')[1].split('?')[0].split('/')[0].split('&')[0]
return `https://open.spotify.com/embed/playlist/${playlistID}`
}
@ -43,13 +43,13 @@ function embed_url(url : string): string{
export function sp_validate(url : string): "track" | "playlist" | "album" | boolean{
if(!url.match(pattern)) return false
if(url.indexOf('track') !== -1){
if(url.indexOf('track/') !== -1){
return "track"
}
else if(url.indexOf('album') !== -1){
else if(url.indexOf('album/') !== -1){
return "album"
}
else if(url.indexOf('playlist') !== -1){
else if(url.indexOf('playlist/') !== -1){
return "playlist"
}
else return false