mirror of
https://gitlab.com/RemixDev/deemix-js.git
synced 2025-01-01 12:25:59 +00:00
Added fallbackISRC option
It will search for available alternatives with the same ISRC
This commit is contained in:
parent
da04a94191
commit
47092d77b6
|
@ -332,7 +332,7 @@ class Downloader {
|
||||||
)
|
)
|
||||||
}catch (e){
|
}catch (e){
|
||||||
if (e.name === "WrongLicense") { throw new DownloadFailed("wrongLicense")}
|
if (e.name === "WrongLicense") { throw new DownloadFailed("wrongLicense")}
|
||||||
if (e.name === "WrongGeolocation") { throw new DownloadFailed("wrongGeolocation")}
|
if (e.name === "WrongGeolocation") { throw new DownloadFailed("wrongGeolocation", track)}
|
||||||
if (e.name === "PreferredBitrateNotFound") { throw new DownloadFailed("wrongBitrate", track) }
|
if (e.name === "PreferredBitrateNotFound") { throw new DownloadFailed("wrongBitrate", track) }
|
||||||
if (e.name === "TrackNot360") { throw new DownloadFailed("no360RA") }
|
if (e.name === "TrackNot360") { throw new DownloadFailed("no360RA") }
|
||||||
console.trace(e)
|
console.trace(e)
|
||||||
|
@ -535,17 +535,35 @@ class Downloader {
|
||||||
if (track.fallbackID != 0){
|
if (track.fallbackID != 0){
|
||||||
this.warn(itemData, e.errid, 'fallback')
|
this.warn(itemData, e.errid, 'fallback')
|
||||||
let newTrack = await this.dz.gw.get_track_with_fallback(track.fallbackID)
|
let newTrack = await this.dz.gw.get_track_with_fallback(track.fallbackID)
|
||||||
|
newTrack = map_track(newTrack)
|
||||||
track.parseEssentialData(newTrack)
|
track.parseEssentialData(newTrack)
|
||||||
await track.retriveFilesizes(this.dz)
|
|
||||||
return await this.downloadWrapper(extraData, track)
|
return await this.downloadWrapper(extraData, track)
|
||||||
}
|
}
|
||||||
|
if (track.albumsFallback.length && this.settings.fallbackISRC){
|
||||||
|
let newAlbumID = track.albumsFallback.pop()
|
||||||
|
let newAlbum = await this.dz.gw.get_album_page(newAlbumID)
|
||||||
|
let fallbackID = 0
|
||||||
|
for (let newTrack of newAlbum.SONGS.data) {
|
||||||
|
if (newTrack.ISRC === track.ISRC) {
|
||||||
|
fallbackID = newTrack.SNG_ID
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fallbackID != 0){
|
||||||
|
this.warn(itemData, e.errid, 'fallback')
|
||||||
|
let newTrack = await this.dz.gw.get_track_with_fallback(fallbackID)
|
||||||
|
newTrack = map_track(newTrack)
|
||||||
|
track.parseEssentialData(newTrack)
|
||||||
|
return await this.downloadWrapper(extraData, track)
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!track.searched && this.settings.fallbackSearch){
|
if (!track.searched && this.settings.fallbackSearch){
|
||||||
this.warn(itemData, e.errid, 'search')
|
this.warn(itemData, e.errid, 'search')
|
||||||
let searchedID = await this.dz.api.get_track_id_from_metadata(track.mainArtist.name, track.title, track.album.title)
|
let searchedID = await this.dz.api.get_track_id_from_metadata(track.mainArtist.name, track.title, track.album.title)
|
||||||
if (searchedID != "0"){
|
if (searchedID != "0"){
|
||||||
let newTrack = await this.dz.gw.get_track_with_fallback(searchedID)
|
let newTrack = await this.dz.gw.get_track_with_fallback(searchedID)
|
||||||
|
newTrack = map_track(newTrack)
|
||||||
track.parseEssentialData(newTrack)
|
track.parseEssentialData(newTrack)
|
||||||
await track.retriveFilesizes(this.dz)
|
|
||||||
track.searched = true
|
track.searched = true
|
||||||
this.log(itemData, "searchFallback")
|
this.log(itemData, "searchFallback")
|
||||||
return await this.downloadWrapper(extraData, track)
|
return await this.downloadWrapper(extraData, track)
|
||||||
|
|
|
@ -89,7 +89,8 @@ const ErrorMessages = {
|
||||||
noSpaceLeft: "No space left on target drive, clean up some space for the tracks.",
|
noSpaceLeft: "No space left on target drive, clean up some space for the tracks.",
|
||||||
albumDoesntExists: "Track's album does not exsist, failed to gather info.",
|
albumDoesntExists: "Track's album does not exsist, failed to gather info.",
|
||||||
notLoggedIn: "You need to login to download tracks.",
|
notLoggedIn: "You need to login to download tracks.",
|
||||||
wrongGeolocation: "Your account can't stream the track from your current country."
|
wrongGeolocation: "Your account can't stream the track from your current country.",
|
||||||
|
wrongGeolocationNoAlternative: "Your account can't stream the track from your current country and no alternative found."
|
||||||
}
|
}
|
||||||
|
|
||||||
class DownloadFailed extends DownloadError {
|
class DownloadFailed extends DownloadError {
|
||||||
|
|
|
@ -37,6 +37,8 @@ async function generateTrackItem(dz, id, bitrate, trackAPI, albumAPI){
|
||||||
cover = `https://e-cdns-images.dzcdn.net/images/cover/${trackAPI.md5_image}/75x75-000000-80-0-0.jpg`
|
cover = `https://e-cdns-images.dzcdn.net/images/cover/${trackAPI.md5_image}/75x75-000000-80-0-0.jpg`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete trackAPI.track_token
|
||||||
|
|
||||||
return new Single({
|
return new Single({
|
||||||
type: 'track',
|
type: 'track',
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -118,6 +120,7 @@ async function generateAlbumItem(dz, id, bitrate, rootArtist){
|
||||||
let collection = []
|
let collection = []
|
||||||
tracksArray.forEach((trackAPI, pos) => {
|
tracksArray.forEach((trackAPI, pos) => {
|
||||||
trackAPI = map_track(trackAPI)
|
trackAPI = map_track(trackAPI)
|
||||||
|
delete trackAPI.track_token
|
||||||
trackAPI.position = pos+1
|
trackAPI.position = pos+1
|
||||||
collection.push(trackAPI)
|
collection.push(trackAPI)
|
||||||
})
|
})
|
||||||
|
@ -178,6 +181,7 @@ async function generatePlaylistItem(dz, id, bitrate, playlistAPI, playlistTracks
|
||||||
trackAPI = map_track(trackAPI)
|
trackAPI = map_track(trackAPI)
|
||||||
if (trackAPI.explicit_lyrics)
|
if (trackAPI.explicit_lyrics)
|
||||||
playlistAPI.explicit = true
|
playlistAPI.explicit = true
|
||||||
|
delete trackAPI.track_token
|
||||||
trackAPI.position = pos+1
|
trackAPI.position = pos+1
|
||||||
collection.push(trackAPI)
|
collection.push(trackAPI)
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,6 +41,7 @@ const DEFAULTS = {
|
||||||
feelingLucky: false,
|
feelingLucky: false,
|
||||||
fallbackBitrate: false,
|
fallbackBitrate: false,
|
||||||
fallbackSearch: false,
|
fallbackSearch: false,
|
||||||
|
fallbackISRC: false,
|
||||||
logErrors: true,
|
logErrors: true,
|
||||||
logSearched: false,
|
logSearched: false,
|
||||||
overwriteFile: OverwriteOption.DONT_OVERWRITE,
|
overwriteFile: OverwriteOption.DONT_OVERWRITE,
|
||||||
|
|
|
@ -27,6 +27,7 @@ class Track {
|
||||||
this.trackTokenExpiration = 0
|
this.trackTokenExpiration = 0
|
||||||
this.duration = 0
|
this.duration = 0
|
||||||
this.fallbackID = "0"
|
this.fallbackID = "0"
|
||||||
|
this.albumsFallback = []
|
||||||
this.filesizes = {}
|
this.filesizes = {}
|
||||||
this.localTrack = false
|
this.localTrack = false
|
||||||
this.mainArtist = null
|
this.mainArtist = null
|
||||||
|
@ -221,6 +222,13 @@ class Track {
|
||||||
this.artist[artist.role].push(artist.name)
|
this.artist[artist.role].push(artist.name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (trackAPI.alternative_albums){
|
||||||
|
trackAPI.alternative_albums.data.forEach(album => {
|
||||||
|
if (album.RIGHTS.STREAM_ADS_AVAILABLE || album.RIGHTS.STREAM_SUB_AVAILABLE)
|
||||||
|
this.albumsFallback.push(album.ALB_ID)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeDuplicateArtists(){
|
removeDuplicateArtists(){
|
||||||
|
|
Loading…
Reference in a new issue