mirror of
https://gitlab.com/RemixDev/deemix-js.git
synced 2024-12-28 18:36:26 +00:00
Better testing for InvalidID
This commit is contained in:
parent
8114f497aa
commit
b27c9f7bd3
|
@ -22,7 +22,7 @@ async function generateTrackItem(dz, id, bitrate, trackAPI, albumAPI){
|
||||||
throw new ISRCnotOnDeezer(`https://deezer.com/track/${id}`)
|
throw new ISRCnotOnDeezer(`https://deezer.com/track/${id}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Number.isInteger(id)) throw new InvalidID(`https://deezer.com/track/${id}`)
|
if (!(/^\d+$/.test(id))) throw new InvalidID(`https://deezer.com/track/${id}`)
|
||||||
|
|
||||||
// Get essential track info
|
// Get essential track info
|
||||||
let trackAPI_gw
|
let trackAPI_gw
|
||||||
|
@ -66,7 +66,7 @@ async function generateAlbumItem(dz, id, bitrate, rootArtist){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (String(id).startsWith('upc')) { id = albumAPI['id'] }
|
if (String(id).startsWith('upc')) { id = albumAPI['id'] }
|
||||||
if (!Number.isInteger(id)) throw new InvalidID(`https://deezer.com/album/${id}`)
|
if (!(/^\d+$/.test(id))) throw new InvalidID(`https://deezer.com/album/${id}`)
|
||||||
|
|
||||||
// Get extra info about album
|
// Get extra info about album
|
||||||
// This saves extra api calls when downloading
|
// This saves extra api calls when downloading
|
||||||
|
@ -119,7 +119,7 @@ async function generateAlbumItem(dz, id, bitrate, rootArtist){
|
||||||
|
|
||||||
async function generatePlaylistItem(dz, id, bitrate, playlistAPI, playlistTracksAPI){
|
async function generatePlaylistItem(dz, id, bitrate, playlistAPI, playlistTracksAPI){
|
||||||
if (!playlistAPI){
|
if (!playlistAPI){
|
||||||
if (!Number.isInteger(id)) throw new InvalidID(`https://deezer.com/playlist/${id}`)
|
if (!(/^\d+$/.test(id))) throw new InvalidID(`https://deezer.com/playlist/${id}`)
|
||||||
// Get essential playlist info
|
// Get essential playlist info
|
||||||
try{
|
try{
|
||||||
playlistAPI = await dz.api.get_playlist(id)
|
playlistAPI = await dz.api.get_playlist(id)
|
||||||
|
@ -178,7 +178,7 @@ async function generatePlaylistItem(dz, id, bitrate, playlistAPI, playlistTracks
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateArtistItem(dz, id, bitrate, listener){
|
async function generateArtistItem(dz, id, bitrate, listener){
|
||||||
if (!Number.isInteger(id)) throw new InvalidID(`https://deezer.com/artist/${id}`)
|
if (!(/^\d+$/.test(id))) throw new InvalidID(`https://deezer.com/artist/${id}`)
|
||||||
// Get essential artist info
|
// Get essential artist info
|
||||||
let artistAPI
|
let artistAPI
|
||||||
try{
|
try{
|
||||||
|
@ -212,7 +212,7 @@ async function generateArtistItem(dz, id, bitrate, listener){
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateArtistDiscographyItem(dz, id, bitrate, listener){
|
async function generateArtistDiscographyItem(dz, id, bitrate, listener){
|
||||||
if (!Number.isInteger(id)) throw new InvalidID(`https://deezer.com/artist/${id}/discography`)
|
if (!(/^\d+$/.test(id))) throw new InvalidID(`https://deezer.com/artist/${id}/discography`)
|
||||||
// Get essential artist info
|
// Get essential artist info
|
||||||
let artistAPI
|
let artistAPI
|
||||||
try{
|
try{
|
||||||
|
@ -249,7 +249,7 @@ async function generateArtistDiscographyItem(dz, id, bitrate, listener){
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateArtistTopItem(dz, id, bitrate){
|
async function generateArtistTopItem(dz, id, bitrate){
|
||||||
if (!Number.isInteger(id)) throw new InvalidID(`https://deezer.com/artist/${id}/top_track`)
|
if (!(/^\d+$/.test(id))) throw new InvalidID(`https://deezer.com/artist/${id}/top_track`)
|
||||||
// Get essential artist info
|
// Get essential artist info
|
||||||
let artistAPI
|
let artistAPI
|
||||||
try{
|
try{
|
||||||
|
|
Loading…
Reference in a new issue