Implemented dateFormat option
This commit is contained in:
parent
47456727f7
commit
1ed277e3a9
|
@ -31,7 +31,7 @@
|
||||||
"artistImageTemplate": "folder",
|
"artistImageTemplate": "folder",
|
||||||
"PNGcovers": false,
|
"PNGcovers": false,
|
||||||
"multitagSeparator": "default",
|
"multitagSeparator": "default",
|
||||||
"dateFormat": "YMD",
|
"dateFormat": "Y-M-D",
|
||||||
"savePlaylistAsCompilation": false,
|
"savePlaylistAsCompilation": false,
|
||||||
"removeAlbumVersion": false,
|
"removeAlbumVersion": false,
|
||||||
"moveFeaturedToTitle": false,
|
"moveFeaturedToTitle": false,
|
||||||
|
|
|
@ -37,6 +37,23 @@ def downloadImage(url, path):
|
||||||
else:
|
else:
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
def formatDate(date, template):
|
||||||
|
if 'YYYY' in template:
|
||||||
|
template = template.replace('YYYY', str(date['year']))
|
||||||
|
if 'YY' in template:
|
||||||
|
template = template.replace('YY', str(date['year']))
|
||||||
|
if 'Y' in template:
|
||||||
|
template = template.replace('Y', str(date['year']))
|
||||||
|
if 'MM' in template:
|
||||||
|
template = template.replace('MM', str(date['month']))
|
||||||
|
if 'M' in template:
|
||||||
|
template = template.replace('M', str(date['month']))
|
||||||
|
if 'DD' in template:
|
||||||
|
template = template.replace('DD', str(date['day']))
|
||||||
|
if 'D' in template:
|
||||||
|
template = template.replace('D', str(date['day']))
|
||||||
|
return template
|
||||||
|
|
||||||
|
|
||||||
def getPreferredBitrate(filesize, bitrate):
|
def getPreferredBitrate(filesize, bitrate):
|
||||||
formats = {'flac': 9, 'mp3_320': 3, 'mp3_128': 1}
|
formats = {'flac': 9, 'mp3_320': 3, 'mp3_128': 1}
|
||||||
|
@ -239,6 +256,16 @@ def getTrackData(dz, trackAPI_gw, trackAPI = None, albumAPI_gw = None, albumAPI
|
||||||
if not albumAPI_gw:
|
if not albumAPI_gw:
|
||||||
albumAPI_gw = dz.get_album_gw(track['album']['id'])
|
albumAPI_gw = dz.get_album_gw(track['album']['id'])
|
||||||
track['copyright'] = albumAPI_gw['COPYRIGHT']
|
track['copyright'] = albumAPI_gw['COPYRIGHT']
|
||||||
|
|
||||||
|
# Fix incorrect day month when detectable
|
||||||
|
if int(track['date']['month']) > 12:
|
||||||
|
monthTemp = track['date']['month']
|
||||||
|
track['date']['month'] = track['date']['day']
|
||||||
|
track['date']['day'] = monthTemp
|
||||||
|
if int(track['album']['date']['month']) > 12:
|
||||||
|
monthTemp = track['album']['date']['month']
|
||||||
|
track['album']['date']['month'] = track['album']['date']['day']
|
||||||
|
track['album']['date']['day'] = monthTemp
|
||||||
return track
|
return track
|
||||||
|
|
||||||
def downloadTrackObj(dz, trackAPI, settings, overwriteBitrate=False, extraTrack=None):
|
def downloadTrackObj(dz, trackAPI, settings, overwriteBitrate=False, extraTrack=None):
|
||||||
|
@ -272,6 +299,8 @@ def downloadTrackObj(dz, trackAPI, settings, overwriteBitrate=False, extraTrack=
|
||||||
track['selectedFilesize'] = filesize
|
track['selectedFilesize'] = filesize
|
||||||
track['album']['bitrate'] = format
|
track['album']['bitrate'] = format
|
||||||
track['album']['picUrl'] = "https://e-cdns-images.dzcdn.net/images/cover/{}/{}x{}-000000-80-0-0.{}".format(track['album']['pic'], settings['embeddedArtworkSize'], settings['embeddedArtworkSize'], 'png' if settings['PNGcovers'] else 'jpg')
|
track['album']['picUrl'] = "https://e-cdns-images.dzcdn.net/images/cover/{}/{}x{}-000000-80-0-0.{}".format(track['album']['pic'], settings['embeddedArtworkSize'], settings['embeddedArtworkSize'], 'png' if settings['PNGcovers'] else 'jpg')
|
||||||
|
track['dateString'] = formatDate(track['date'], settings['dateFormat'])
|
||||||
|
track['album']['dateString'] = formatDate(track['album']['date'], settings['dateFormat'])
|
||||||
|
|
||||||
# Generate filename and filepath from metadata
|
# Generate filename and filepath from metadata
|
||||||
filename = generateFilename(track, trackAPI, settings)
|
filename = generateFilename(track, trackAPI, settings)
|
||||||
|
|
|
@ -108,7 +108,7 @@ def settingsRegex(filename, track, settings, playlist=None):
|
||||||
else:
|
else:
|
||||||
filename = filename.replace("%genre%", "Unknown")
|
filename = filename.replace("%genre%", "Unknown")
|
||||||
filename = filename.replace("%year%", str(track['date']['year']))
|
filename = filename.replace("%year%", str(track['date']['year']))
|
||||||
filename = filename.replace("%date%", "{}-{}-{}".format(str(track['date']['year']), str(track['date']['month']), str(track['date']['day'])))
|
filename = filename.replace("%date%", track['dateString'])
|
||||||
filename = filename.replace("%bpm%", str(track['bpm']))
|
filename = filename.replace("%bpm%", str(track['bpm']))
|
||||||
filename = filename.replace("%label%", fixName(track['album']['label'], settings['illegalCharacterReplacer']))
|
filename = filename.replace("%label%", fixName(track['album']['label'], settings['illegalCharacterReplacer']))
|
||||||
filename = filename.replace("%isrc%", track['ISRC'])
|
filename = filename.replace("%isrc%", track['ISRC'])
|
||||||
|
@ -141,7 +141,7 @@ def settingsRegexAlbum(foldername, album, settings):
|
||||||
else:
|
else:
|
||||||
foldername = foldername.replace("%genre%", "Unknown")
|
foldername = foldername.replace("%genre%", "Unknown")
|
||||||
foldername = foldername.replace("%year%", str(album['date']['year']))
|
foldername = foldername.replace("%year%", str(album['date']['year']))
|
||||||
foldername = foldername.replace("%date%", "{}-{}-{}".format(str(album['date']['year']), str(album['date']['month']), str(album['date']['day'])))
|
foldername = foldername.replace("%date%", album['dateString'])
|
||||||
foldername = foldername.replace("%bitrate%", bitrateLabels[int(album['bitrate'])])
|
foldername = foldername.replace("%bitrate%", bitrateLabels[int(album['bitrate'])])
|
||||||
|
|
||||||
foldername = foldername.replace('\\', pathSep).replace('/', pathSep)
|
foldername = foldername.replace('\\', pathSep).replace('/', pathSep)
|
||||||
|
|
|
@ -85,7 +85,7 @@ def tagFLAC(stream, track, save):
|
||||||
if save['year']:
|
if save['year']:
|
||||||
tag["YEAR"] = str(track['date']['year'])
|
tag["YEAR"] = str(track['date']['year'])
|
||||||
if save['date']:
|
if save['date']:
|
||||||
tag["DATE"] = "{}-{}-{}".format(str(track['date']['year']), str(track['date']['month']), str(track['date']['day']))
|
tag["DATE"] = track['dateString']
|
||||||
if save['length']:
|
if save['length']:
|
||||||
tag["LENGTH"] = str(track['duration'])
|
tag["LENGTH"] = str(track['duration'])
|
||||||
if save['bpm']:
|
if save['bpm']:
|
||||||
|
|
Loading…
Reference in New Issue