Added playlistFilenameTemplate setting
Variables are: %title%, %artist%, %size%, %type%, %id%, %bitrate%
This commit is contained in:
parent
cb4b7b6f63
commit
42e55b3f06
|
@ -24,6 +24,7 @@
|
||||||
"saveDownloadQueue": false,
|
"saveDownloadQueue": false,
|
||||||
"overwriteFile": "n",
|
"overwriteFile": "n",
|
||||||
"createM3U8File": false,
|
"createM3U8File": false,
|
||||||
|
"playlistFilenameTemplate": "playlist",
|
||||||
"syncedLyrics": false,
|
"syncedLyrics": false,
|
||||||
"embeddedArtworkSize": 800,
|
"embeddedArtworkSize": 800,
|
||||||
"localArtworkSize": 1400,
|
"localArtworkSize": 1400,
|
||||||
|
|
|
@ -13,7 +13,7 @@ from requests.exceptions import HTTPError, ConnectionError
|
||||||
|
|
||||||
from deemix.api.deezer import APIError, USER_AGENT_HEADER
|
from deemix.api.deezer import APIError, USER_AGENT_HEADER
|
||||||
from deemix.utils.misc import changeCase
|
from deemix.utils.misc import changeCase
|
||||||
from deemix.utils.pathtemplates import generateFilename, generateFilepath, settingsRegexAlbum, settingsRegexArtist
|
from deemix.utils.pathtemplates import generateFilename, generateFilepath, settingsRegexAlbum, settingsRegexArtist, settingsRegexPlaylistFile
|
||||||
from deemix.utils.taggers import tagID3, tagFLAC
|
from deemix.utils.taggers import tagID3, tagFLAC
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -894,10 +894,11 @@ def after_download(tracks, settings, queueItem):
|
||||||
f.write(searched.encode('utf-8'))
|
f.write(searched.encode('utf-8'))
|
||||||
chmod(os.path.join(extrasPath, 'searched.txt'), 0o770)
|
chmod(os.path.join(extrasPath, 'searched.txt'), 0o770)
|
||||||
if settings['createM3U8File']:
|
if settings['createM3U8File']:
|
||||||
with open(os.path.join(extrasPath, 'playlist.m3u8'), 'wb') as f:
|
filename = settingsRegexPlaylistFile(settings['playlistFilenameTemplate'], queueItem, settings) or "playlist"
|
||||||
|
with open(os.path.join(extrasPath, filename+'.m3u8'), 'wb') as f:
|
||||||
for line in playlist:
|
for line in playlist:
|
||||||
f.write((line + "\n").encode('utf-8'))
|
f.write((line + "\n").encode('utf-8'))
|
||||||
chmod(os.path.join(extrasPath, 'playlist.m3u8'), 0o770)
|
chmod(os.path.join(extrasPath, filename+'.m3u8'), 0o770)
|
||||||
if settings['executeCommand'] != "":
|
if settings['executeCommand'] != "":
|
||||||
execute(settings['executeCommand'].replace("%folder%", extrasPath))
|
execute(settings['executeCommand'].replace("%folder%", extrasPath))
|
||||||
return extrasPath
|
return extrasPath
|
||||||
|
|
|
@ -94,7 +94,8 @@ def generateFilepath(track, trackAPI, settings):
|
||||||
'_EXTRA_PLAYLIST' in trackAPI and settings['createStructurePlaylist']))
|
'_EXTRA_PLAYLIST' in trackAPI and settings['createStructurePlaylist']))
|
||||||
):
|
):
|
||||||
filepath += antiDot(
|
filepath += antiDot(
|
||||||
settingsRegexAlbum(settings['albumNameTemplate'], track['album'], settings, trackAPI)) + pathSep
|
settingsRegexAlbum(settings['albumNameTemplate'], track['album'], settings,
|
||||||
|
trackAPI['_EXTRA_PLAYLIST'] if'_EXTRA_PLAYLIST' in trackAPI else None)) + pathSep
|
||||||
coverPath = filepath
|
coverPath = filepath
|
||||||
|
|
||||||
if not ('_EXTRA_PLAYLIST' in trackAPI and not settings['tags']['savePlaylistAsCompilation']):
|
if not ('_EXTRA_PLAYLIST' in trackAPI and not settings['tags']['savePlaylistAsCompilation']):
|
||||||
|
@ -154,9 +155,9 @@ def settingsRegex(filename, track, settings, playlist=None):
|
||||||
return antiDot(fixLongName(filename))
|
return antiDot(fixLongName(filename))
|
||||||
|
|
||||||
|
|
||||||
def settingsRegexAlbum(foldername, album, settings, trackAPI):
|
def settingsRegexAlbum(foldername, album, settings, playlist=None):
|
||||||
if trackAPI and '_EXTRA_PLAYLIST' in trackAPI and settings['tags']['savePlaylistAsCompilation']:
|
if playlist and settings['tags']['savePlaylistAsCompilation']:
|
||||||
foldername = foldername.replace("%album_id%", "pl_" + str(trackAPI['_EXTRA_PLAYLIST']['id']))
|
foldername = foldername.replace("%album_id%", "pl_" + str(playlist['id']))
|
||||||
else:
|
else:
|
||||||
foldername = foldername.replace("%album_id%", str(album['id']))
|
foldername = foldername.replace("%album_id%", str(album['id']))
|
||||||
foldername = foldername.replace("%album%", fixName(album['title'], settings['illegalCharacterReplacer']))
|
foldername = foldername.replace("%album%", fixName(album['title'], settings['illegalCharacterReplacer']))
|
||||||
|
@ -199,3 +200,13 @@ def settingsRegexPlaylist(foldername, playlist, settings):
|
||||||
foldername = foldername.replace("%date%", str(playlist['creation_date'][:10]))
|
foldername = foldername.replace("%date%", str(playlist['creation_date'][:10]))
|
||||||
foldername = foldername.replace('\\', pathSep).replace('/', pathSep)
|
foldername = foldername.replace('\\', pathSep).replace('/', pathSep)
|
||||||
return antiDot(fixLongName(foldername))
|
return antiDot(fixLongName(foldername))
|
||||||
|
|
||||||
|
def settingsRegexPlaylistFile(foldername, queueItem, settings):
|
||||||
|
foldername = foldername.replace("%title%", fixName(queueItem['title'], settings['illegalCharacterReplacer']))
|
||||||
|
foldername = foldername.replace("%artist%", fixName(queueItem['artist'], settings['illegalCharacterReplacer']))
|
||||||
|
foldername = foldername.replace("%size%", str(queueItem['size']))
|
||||||
|
foldername = foldername.replace("%type%", fixName(queueItem['type'], settings['illegalCharacterReplacer']))
|
||||||
|
foldername = foldername.replace("%id%", fixName(queueItem['id'], settings['illegalCharacterReplacer']))
|
||||||
|
foldername = foldername.replace("%bitrate%", bitrateLabels[int(queueItem['bitrate'])])
|
||||||
|
foldername = foldername.replace('\\', pathSep).replace('/', pathSep).replace(pathSep, settings['illegalCharacterReplacer'])
|
||||||
|
return antiDot(fixLongName(foldername))
|
||||||
|
|
Loading…
Reference in New Issue