Added 'b' option for overwriteFile
It will keep both files and add a number at the end of the filename
This commit is contained in:
parent
f91e7fe943
commit
c65b85631b
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
__version__ = "1.1.24"
|
__version__ = "1.1.25"
|
||||||
|
|
|
@ -101,7 +101,7 @@ def trackRemovePercentage(trackAPI, queueItem, interface):
|
||||||
|
|
||||||
|
|
||||||
def downloadImage(url, path, overwrite="n"):
|
def downloadImage(url, path, overwrite="n"):
|
||||||
if not os.path.isfile(path) or overwrite in ['y', 't']:
|
if not os.path.isfile(path) or overwrite in ['y', 't', 'b']:
|
||||||
try:
|
try:
|
||||||
image = get(url, headers={'User-Agent': USER_AGENT_HEADER}, timeout=30)
|
image = get(url, headers={'User-Agent': USER_AGENT_HEADER}, timeout=30)
|
||||||
image.raise_for_status()
|
image.raise_for_status()
|
||||||
|
@ -177,7 +177,7 @@ def getPreferredBitrate(dz, track, bitrate, fallback=True):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
return error_num
|
return error_num
|
||||||
|
|
||||||
return error_num # fallback is enabled and loop went through all formats
|
return error_num # fallback is enabled and loop went through all formats
|
||||||
|
|
||||||
|
|
||||||
|
@ -790,6 +790,16 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
result['artistPath'] = os.path.join(artistPath,
|
result['artistPath'] = os.path.join(artistPath,
|
||||||
f"{settingsRegexArtist(settings['artistImageTemplate'], track['album']['mainArtist'], settings)}")
|
f"{settingsRegexArtist(settings['artistImageTemplate'], track['album']['mainArtist'], settings)}")
|
||||||
|
|
||||||
|
trackAlreadyDownloaded = os.path.isfile(writepath)
|
||||||
|
if trackAlreadyDownloaded and settings['overwriteFile'] == 'b':
|
||||||
|
baseFilename = os.path.join(filepath, filename)
|
||||||
|
i = 1
|
||||||
|
currentFilename = baseFilename+' ('+str(i)+')'+ extensions[track['selectedFormat']]
|
||||||
|
while os.path.isfile(currentFilename):
|
||||||
|
i += 1
|
||||||
|
currentFilename = baseFilename+' ('+str(i)+')'+ extensions[track['selectedFormat']]
|
||||||
|
trackAlreadyDownloaded = False
|
||||||
|
writepath = currentFilename
|
||||||
# Data for m3u file
|
# Data for m3u file
|
||||||
if extrasPath:
|
if extrasPath:
|
||||||
result['extrasPath'] = extrasPath
|
result['extrasPath'] = extrasPath
|
||||||
|
@ -815,7 +825,6 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
|
|
||||||
track['downloadUrl'] = dz.get_track_stream_url(track['id'], track['MD5'], track['mediaVersion'],
|
track['downloadUrl'] = dz.get_track_stream_url(track['id'], track['MD5'], track['mediaVersion'],
|
||||||
track['selectedFormat'])
|
track['selectedFormat'])
|
||||||
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):
|
def downloadMusic(dz, track, trackAPI, queueItem, interface, writepath, result, settings):
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="deemix",
|
name="deemix",
|
||||||
version="1.1.24",
|
version="1.1.25",
|
||||||
description="A barebone deezer downloader library",
|
description="A barebone deezer downloader library",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|
Loading…
Reference in New Issue