Small Patch for spotify
This commit is contained in:
parent
c5b51c2154
commit
04630737bf
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "0.8.1",
|
"version": "0.8.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "0.8.1",
|
"version": "0.8.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"got": "^11.8.2"
|
"got": "^11.8.2"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "play-dl",
|
"name": "play-dl",
|
||||||
"version": "0.8.1",
|
"version": "0.8.2",
|
||||||
"description": "YouTube, SoundCloud, Spotify streaming for discord.js bots",
|
"description": "YouTube, SoundCloud, Spotify streaming for discord.js bots",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
|||||||
@ -26,15 +26,15 @@ function parse_json(url : string, data : string): SpotifyAlbum | SpotifyPlaylist
|
|||||||
}
|
}
|
||||||
|
|
||||||
function embed_url(url : string): string{
|
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]
|
let trackID = url.split('track/')[1].split('?')[0].split('/')[0].split('&')[0]
|
||||||
return `https://open.spotify.com/embed/track/${trackID}`
|
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]
|
let albumID = url.split('album/')[1].split('?')[0].split('/')[0].split('&')[0]
|
||||||
return `https://open.spotify.com/embed/album/${albumID}`
|
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]
|
let playlistID = url.split('playlist/')[1].split('?')[0].split('/')[0].split('&')[0]
|
||||||
return `https://open.spotify.com/embed/playlist/${playlistID}`
|
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{
|
export function sp_validate(url : string): "track" | "playlist" | "album" | boolean{
|
||||||
if(!url.match(pattern)) return false
|
if(!url.match(pattern)) return false
|
||||||
if(url.indexOf('track') !== -1){
|
if(url.indexOf('track/') !== -1){
|
||||||
return "track"
|
return "track"
|
||||||
}
|
}
|
||||||
else if(url.indexOf('album') !== -1){
|
else if(url.indexOf('album/') !== -1){
|
||||||
return "album"
|
return "album"
|
||||||
}
|
}
|
||||||
else if(url.indexOf('playlist') !== -1){
|
else if(url.indexOf('playlist/') !== -1){
|
||||||
return "playlist"
|
return "playlist"
|
||||||
}
|
}
|
||||||
else return false
|
else return false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user