Added fallback ID to "Track not found at desired bitrate"
This fixes #7
This commit is contained in:
parent
54ca38e745
commit
c27da21f1b
|
@ -500,6 +500,43 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
|||
# Get the selected bitrate
|
||||
format = getPreferredBitrate(dz, track, bitrate, settings['fallbackBitrate'])
|
||||
if format == -100:
|
||||
if track['fallbackId'] != 0:
|
||||
logger.warn(f"[{track['mainArtist']['name']} - {track['title']}] Track not found at desired bitrate, using fallback id")
|
||||
trackNew = dz.get_track_gw(track['fallbackId'])
|
||||
if not 'MD5_ORIGIN' in trackNew:
|
||||
trackNew['MD5_ORIGIN'] = dz.get_track_md5(trackNew['SNG_ID'])
|
||||
track = parseEssentialTrackData(track, trackNew)
|
||||
return downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=track, interface=interface)
|
||||
elif not 'searched' in track and settings['fallbackSearch']:
|
||||
logger.warn(f"[{track['mainArtist']['name']} - {track['title']}] Track not found at desired bitrate, searching for alternative")
|
||||
searchedId = dz.get_track_from_metadata(track['mainArtist']['name'], track['title'],
|
||||
track['album']['title'])
|
||||
if searchedId != 0:
|
||||
trackNew = dz.get_track_gw(searchedId)
|
||||
if not 'MD5_ORIGIN' in trackNew:
|
||||
trackNew['MD5_ORIGIN'] = dz.get_track_md5(trackNew['SNG_ID'])
|
||||
track = parseEssentialTrackData(track, trackNew)
|
||||
track['searched'] = True
|
||||
return downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=track,
|
||||
interface=interface)
|
||||
else:
|
||||
logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not found at desired bitrate and no alternative found!")
|
||||
trackCompletePercentage(trackAPI, queueItem, interface)
|
||||
result['error'] = {
|
||||
'message': "Track not found at desired bitrate and no alternative found!",
|
||||
'data': {
|
||||
'id': track['id'],
|
||||
'title': track['title'],
|
||||
'artist': track['mainArtist']['name']
|
||||
}
|
||||
}
|
||||
queueItem['failed'] += 1
|
||||
queueItem['errors'].append(result['error'])
|
||||
if interface:
|
||||
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
|
||||
'error': "Track not found at desired bitrate and no alternative found!"})
|
||||
return result
|
||||
else:
|
||||
logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not found at desired bitrate. Enable fallback to lower bitrates to fix this issue.")
|
||||
trackCompletePercentage(trackAPI, queueItem, interface)
|
||||
result['error'] = {
|
||||
|
|
Loading…
Reference in New Issue