Made 'errid' available on the queueItem as well

This commit is contained in:
RemixDev 2020-07-23 16:01:58 +02:00
parent aa70a8b45f
commit 267b7e4fa8
1 changed files with 16 additions and 8 deletions

View File

@ -458,6 +458,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
if trackAPI['SNG_ID'] == 0: if trackAPI['SNG_ID'] == 0:
result['error'] = { result['error'] = {
'message': "This track is not available on Deezer!", 'message': "This track is not available on Deezer!",
'errid': 'notOnDeezer'
} }
if 'SNG_TITLE' in trackAPI: if 'SNG_TITLE' in trackAPI:
result['error']['data'] = { result['error']['data'] = {
@ -470,7 +471,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
queueItem['errors'].append(result['error']) queueItem['errors'].append(result['error'])
if interface: if interface:
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'], interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
'error': "This track is not available on Deezer!", 'errid': 'notOnDeezer'}) 'error': result['error']['message'], 'errid': result['error']['errid']})
return result return result
# Get the metadata # Get the metadata
logger.info(f"[{trackAPI['ART_NAME']} - {trackAPI['SNG_TITLE']}] Getting the tags") logger.info(f"[{trackAPI['ART_NAME']} - {trackAPI['SNG_TITLE']}] Getting the tags")
@ -507,6 +508,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
trackCompletePercentage(trackAPI, queueItem, interface) trackCompletePercentage(trackAPI, queueItem, interface)
result['error'] = { result['error'] = {
'message': "Track not yet encoded and no alternative found!", 'message': "Track not yet encoded and no alternative found!",
'errid': 'notEncodedNoAlternative',
'data': { 'data': {
'id': track['id'], 'id': track['id'],
'title': track['title'], 'title': track['title'],
@ -517,13 +519,14 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
queueItem['errors'].append(result['error']) queueItem['errors'].append(result['error'])
if interface: if interface:
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'], interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
'error': "Track not yet encoded and no alternative found!", 'errid': 'notEncodedNoAlternative'}) 'error': result['error']['message'], 'errid': result['error']['errid']})
return result return result
else: else:
logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not yet encoded!") logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not yet encoded!")
trackCompletePercentage(trackAPI, queueItem, interface) trackCompletePercentage(trackAPI, queueItem, interface)
result['error'] = { result['error'] = {
'message': "Track not yet encoded!", 'message': "Track not yet encoded!",
'errid': 'notEncoded',
'data': { 'data': {
'id': track['id'], 'id': track['id'],
'title': track['title'], 'title': track['title'],
@ -534,7 +537,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
queueItem['errors'].append(result['error']) queueItem['errors'].append(result['error'])
if interface: if interface:
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'], interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
'error': "Track not yet encoded!", 'errid': 'notEncoded'}) 'error': result['error']['message'], 'errid': result['error']['errid']})
return result return result
# Get the selected bitrate # Get the selected bitrate
@ -560,6 +563,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
trackCompletePercentage(trackAPI, queueItem, interface) trackCompletePercentage(trackAPI, queueItem, interface)
result['error'] = { result['error'] = {
'message': "Track not found at desired bitrate and no alternative found!", 'message': "Track not found at desired bitrate and no alternative found!",
'errid': 'wrongBitrateNoAlternative',
'data': { 'data': {
'id': track['id'], 'id': track['id'],
'title': track['title'], 'title': track['title'],
@ -570,13 +574,14 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
queueItem['errors'].append(result['error']) queueItem['errors'].append(result['error'])
if interface: if interface:
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'], interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
'error': "Track not found at desired bitrate and no alternative found!", 'errid': 'wrongBitrateNoAlternative'}) 'error': result['error']['message'], 'errid': result['error']['errid']})
return result return result
else: else:
logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not found at desired bitrate. Enable fallback to lower bitrates to fix this issue.") 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) trackCompletePercentage(trackAPI, queueItem, interface)
result['error'] = { result['error'] = {
'message': "Track not found at desired bitrate.", 'message': "Track not found at desired bitrate.",
'errid': 'wrongBitrate',
'data': { 'data': {
'id': track['id'], 'id': track['id'],
'title': track['title'], 'title': track['title'],
@ -587,13 +592,14 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
queueItem['errors'].append(result['error']) queueItem['errors'].append(result['error'])
if interface: if interface:
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'], interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
'error': "Track not found at desired bitrate.", 'errid': 'wrongBitrate'}) 'error': result['error']['message'], 'errid': result['error']['errid']})
return result return result
elif selectedBitrate == -200: elif selectedBitrate == -200:
logger.error(f"[{track['mainArtist']['name']} - {track['title']}] This track is not available in 360 Reality Audio format. Please select another format.") logger.error(f"[{track['mainArtist']['name']} - {track['title']}] This track is not available in 360 Reality Audio format. Please select another format.")
trackCompletePercentage(trackAPI, queueItem, interface) trackCompletePercentage(trackAPI, queueItem, interface)
result['error'] = { result['error'] = {
'message': "Track is not available in Reality Audio 360.", 'message': "Track is not available in Reality Audio 360.",
'errid': 'no360RA',
'data': { 'data': {
'id': track['id'], 'id': track['id'],
'title': track['title'], 'title': track['title'],
@ -604,7 +610,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
queueItem['errors'].append(result['error']) queueItem['errors'].append(result['error'])
if interface: if interface:
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'], interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
'error': "Track is not available in Reality Audio 360.", 'errid': 'no360RA'}) 'error': result['error']['message'], 'errid': result['error']['errid']})
return result return result
track['selectedFormat'] = selectedBitrate track['selectedFormat'] = selectedBitrate
if "_EXTRA_PLAYLIST" in trackAPI: if "_EXTRA_PLAYLIST" in trackAPI:
@ -809,6 +815,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
trackCompletePercentage(trackAPI, queueItem, interface) trackCompletePercentage(trackAPI, queueItem, interface)
result['error'] = { result['error'] = {
'message': "Track not available on deezer's servers and no alternative found!", 'message': "Track not available on deezer's servers and no alternative found!",
'errid': 'notAvailableNoAlternative',
'data': { 'data': {
'id': track['id'], 'id': track['id'],
'title': track['title'], 'title': track['title'],
@ -819,13 +826,14 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
queueItem['errors'].append(result['error']) queueItem['errors'].append(result['error'])
if interface: if interface:
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'], interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
'error': "Track not available on deezer's servers and no alternative found!", 'errid': 'notAvailableNoAlternative'}) 'error': result['error']['message'], 'errid': result['error']['errid']})
return 1 return 1
else: else:
logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not available on deezer's servers!") logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not available on deezer's servers!")
trackCompletePercentage(trackAPI, queueItem, interface) trackCompletePercentage(trackAPI, queueItem, interface)
result['error'] = { result['error'] = {
'message': "Track not available on deezer's servers!", 'message': "Track not available on deezer's servers!",
'errid': 'notAvailable',
'data': { 'data': {
'id': track['id'], 'id': track['id'],
'title': track['title'], 'title': track['title'],
@ -836,7 +844,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
queueItem['errors'].append(result['error']) queueItem['errors'].append(result['error'])
if interface: if interface:
interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'], interface.send("updateQueue", {'uuid': queueItem['uuid'], 'failed': True, 'data': result['error']['data'],
'error': "Track not available on deezer's servers!", 'errid': 'notAvailable'}) 'error': result['error']['message'], 'errid': result['error']['errid']})
return 1 return 1
except: except:
logger.warn(f"[{track['mainArtist']['name']} - {track['title']}] Error while downloading the track, trying again in 5s...") logger.warn(f"[{track['mainArtist']['name']} - {track['title']}] Error while downloading the track, trying again in 5s...")