parent
be93716993
commit
fa6d1d8b74
|
@ -735,6 +735,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
trackAlreadyDownloaded = os.path.isfile(writepath)
|
trackAlreadyDownloaded = os.path.isfile(writepath)
|
||||||
if not trackAlreadyDownloaded or settings['overwriteFile'] == 'y':
|
if not trackAlreadyDownloaded or settings['overwriteFile'] == 'y':
|
||||||
logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Downloading the track")
|
logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Downloading the track")
|
||||||
|
def downloadMusic(dz, track, trackAPI, queueItem, interface, writepath, result, settings):
|
||||||
try:
|
try:
|
||||||
with open(writepath, 'wb') as stream:
|
with open(writepath, 'wb') as stream:
|
||||||
stream_track(dz, track, stream, trackAPI, queueItem, interface)
|
stream_track(dz, track, stream, trackAPI, queueItem, interface)
|
||||||
|
@ -742,7 +743,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
except downloadCancelled:
|
except downloadCancelled:
|
||||||
remove(writepath)
|
remove(writepath)
|
||||||
result['cancel'] = True
|
result['cancel'] = True
|
||||||
return result
|
return 1
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
remove(writepath)
|
remove(writepath)
|
||||||
if track['fallbackId'] != 0:
|
if track['fallbackId'] != 0:
|
||||||
|
@ -751,7 +752,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
if not 'MD5_ORIGIN' in trackNew:
|
if not 'MD5_ORIGIN' in trackNew:
|
||||||
trackNew['MD5_ORIGIN'] = dz.get_track_md5(trackNew['SNG_ID'])
|
trackNew['MD5_ORIGIN'] = dz.get_track_md5(trackNew['SNG_ID'])
|
||||||
track = parseEssentialTrackData(track, trackNew)
|
track = parseEssentialTrackData(track, trackNew)
|
||||||
return downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=track, interface=interface)
|
return 2
|
||||||
elif not 'searched' in track and settings['fallbackSearch']:
|
elif not 'searched' in track and settings['fallbackSearch']:
|
||||||
logger.warn(f"[{track['mainArtist']['name']} - {track['title']}] Track not available, searching for alternative")
|
logger.warn(f"[{track['mainArtist']['name']} - {track['title']}] Track not available, searching for alternative")
|
||||||
searchedId = dz.get_track_from_metadata(track['mainArtist']['name'], track['title'],
|
searchedId = dz.get_track_from_metadata(track['mainArtist']['name'], track['title'],
|
||||||
|
@ -762,8 +763,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
trackNew['MD5_ORIGIN'] = dz.get_track_md5(trackNew['SNG_ID'])
|
trackNew['MD5_ORIGIN'] = dz.get_track_md5(trackNew['SNG_ID'])
|
||||||
track = parseEssentialTrackData(track, trackNew)
|
track = parseEssentialTrackData(track, trackNew)
|
||||||
track['searched'] = True
|
track['searched'] = True
|
||||||
return downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=track,
|
return 2
|
||||||
interface=interface)
|
|
||||||
else:
|
else:
|
||||||
logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not available on deezer's servers and no alternative found!")
|
logger.error(f"[{track['mainArtist']['name']} - {track['title']}] Track not available on deezer's servers and no alternative found!")
|
||||||
trackCompletePercentage(trackAPI, queueItem, interface)
|
trackCompletePercentage(trackAPI, queueItem, interface)
|
||||||
|
@ -780,7 +780,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
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!"})
|
'error': "Track not available on deezer's servers and no alternative found!"})
|
||||||
return result
|
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)
|
||||||
|
@ -797,7 +797,17 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
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!"})
|
'error': "Track not available on deezer's servers!"})
|
||||||
|
return 1
|
||||||
|
except:
|
||||||
|
logger.warn(f"[{track['mainArtist']['name']} - {track['title']}] Error while downloading the track, trying again in 5s...")
|
||||||
|
sleep(5)
|
||||||
|
return downloadMusic(dz, track, trackAPI, queueItem, interface, writepath, result, settings)
|
||||||
|
return 0
|
||||||
|
outcome = downloadMusic(dz, track, trackAPI, queueItem, interface, writepath, result, settings)
|
||||||
|
if outcome == 1:
|
||||||
return result
|
return result
|
||||||
|
elif outcome == 2:
|
||||||
|
return downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=track, interface=interface)
|
||||||
else:
|
else:
|
||||||
logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Skipping track as it's already downloaded")
|
logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Skipping track as it's already downloaded")
|
||||||
trackCompletePercentage(trackAPI, queueItem, interface)
|
trackCompletePercentage(trackAPI, queueItem, interface)
|
||||||
|
|
Loading…
Reference in New Issue