Implemented remove Album Version from trackname

This commit is contained in:
RemixDev 2020-03-22 16:52:17 +01:00
parent d9ae3f3289
commit d8ec35d9b2
2 changed files with 15 additions and 6 deletions

View File

@ -6,6 +6,7 @@ Run `python -m deemix --help` to see how to use the app
Finish porting all features: Finish porting all features:
- logging - logging
- gui - gui
- spotify features
- ? - ?
Settings not yet implemented: Settings not yet implemented:

View File

@ -8,6 +8,7 @@ from requests import get
from requests.exceptions import HTTPError from requests.exceptions import HTTPError
from tempfile import gettempdir from tempfile import gettempdir
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
import re
TEMPDIR = os.path.join(gettempdir(), 'deezloader-imgs') TEMPDIR = os.path.join(gettempdir(), 'deezloader-imgs')
if not os.path.isdir(TEMPDIR): if not os.path.isdir(TEMPDIR):
@ -418,6 +419,13 @@ def downloadTrackObj(dz, trackAPI, settings, overwriteBitrate=False, extraTrack=
track['dateString'] = formatDate(track['date'], settings['dateFormat']) track['dateString'] = formatDate(track['date'], settings['dateFormat'])
track['album']['dateString'] = formatDate(track['album']['date'], settings['dateFormat']) track['album']['dateString'] = formatDate(track['album']['date'], settings['dateFormat'])
# Remove (Album Version) from tracks that have that
if settings['removeAlbumVersion']:
if "Album Version" in track['title']:
track['title'] = re.sub(r' ?\(Album Version\)', "", track['title']).strip()
track['title_clean'] = re.sub(r' ?\(Album Version\)', "", track['title_clean']).strip()
track['title_feat'] = re.sub(r' ?\(Album Version\)', "", track['title_feat']).strip()
# Generate filename and filepath from metadata # Generate filename and filepath from metadata
filename = generateFilename(track, trackAPI, settings) filename = generateFilename(track, trackAPI, settings)
(filepath, artistPath, coverPath, extrasPath) = generateFilepath(track, trackAPI, settings) (filepath, artistPath, coverPath, extrasPath) = generateFilepath(track, trackAPI, settings)
@ -542,16 +550,16 @@ def after_download(tracks, settings):
return extrasPath return extrasPath
def after_download_single(track, settings): def after_download_single(track, settings):
if settings['logSearched'] and 'extrasPath' in result and 'searched' in result: if settings['logSearched'] and 'extrasPath' in track and 'searched' in track:
with open(os.path.join(result['extrasPath'], 'searched.txt'), 'w+') as f: with open(os.path.join(track['extrasPath'], 'searched.txt'), 'w+') as f:
orig = f.read() orig = f.read()
if not result['searched'] in orig: if not track['searched'] in orig:
if orig != "": if orig != "":
orig += "\r\n" orig += "\r\n"
orig += result['searched']+"\r\n" orig += track['searched']+"\r\n"
f.write(orig) f.write(orig)
if 'extrasPath' in result: if 'extrasPath' in track:
return result['extrasPath'] return track['extrasPath']
else: else:
return None return None