Made settings more compatible with deezloader
This commit is contained in:
parent
c0f419e1be
commit
a4e4ecdb98
|
@ -1,12 +1,40 @@
|
||||||
{
|
{
|
||||||
"pathSettings": {
|
"downloadLocation": "",
|
||||||
"downloadLocation": ""
|
"tracknameTemplate": "%artist% - %title%",
|
||||||
},
|
"albumTracknameTemplate": "%number% - %title%",
|
||||||
"appSettings": {
|
"playlistTracknameTemplate": "%position% - %artist% - %title%",
|
||||||
"maxBitrate": 3
|
"playlistNameTemplate": "%name%",
|
||||||
},
|
"artistNameTemplate": "",
|
||||||
"taggingSettings": {
|
"albumNameTemplate": "%artist% - %album%",
|
||||||
"artworkSize": 800,
|
"createCDFolder": true,
|
||||||
|
"createStructurePlaylist": false,
|
||||||
|
"createSingleFolder": false,
|
||||||
|
"saveFullArtists": false,
|
||||||
|
"padTrack": true,
|
||||||
|
"paddingSize": "0",
|
||||||
|
"illegalCharacterReplacer": "_",
|
||||||
|
"queueConcurrency": 3,
|
||||||
|
"maxBitrate": "3",
|
||||||
|
"fallbackBitrate": true,
|
||||||
|
"fallbackSearch": true,
|
||||||
|
"logErrors": false,
|
||||||
|
"logSearched": false,
|
||||||
|
"createM3U8File": false,
|
||||||
|
"syncedLyrics": false,
|
||||||
|
"embeddedArtworkSize": 800,
|
||||||
|
"localArtworkSize": 1000,
|
||||||
|
"coverImageTemplate": "",
|
||||||
|
"artistImageTemplate": "",
|
||||||
|
"multitagSeparator": "default",
|
||||||
|
"dateFormat": "0",
|
||||||
|
"dateFormatYear": "4",
|
||||||
|
"savePlaylistAsCompilation": false,
|
||||||
|
"removeAlbumVersion": false,
|
||||||
|
"moveFeaturedToTitle": false,
|
||||||
|
"useNullSeparator": false,
|
||||||
|
"saveID3v1": true,
|
||||||
|
"titleCasing": "nothing",
|
||||||
|
"artistCasing": "nothing",
|
||||||
"tags": {
|
"tags": {
|
||||||
"title": true,
|
"title": true,
|
||||||
"artist": true,
|
"artist": true,
|
||||||
|
@ -32,5 +60,4 @@
|
||||||
"composer": false,
|
"composer": false,
|
||||||
"involvedPeople": false
|
"involvedPeople": false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ def downloadTrackObj(trackAPI, settings, overwriteBitrate=False):
|
||||||
if overwriteBitrate:
|
if overwriteBitrate:
|
||||||
bitrate = overwriteBitrate
|
bitrate = overwriteBitrate
|
||||||
else:
|
else:
|
||||||
bitrate = settings['appSettings']['maxBitrate']
|
bitrate = settings['maxBitrate']
|
||||||
bitrateFound = False;
|
bitrateFound = False;
|
||||||
if int(bitrate) == 9:
|
if int(bitrate) == 9:
|
||||||
track['selectedFormat'] = 9
|
track['selectedFormat'] = 9
|
||||||
|
@ -217,21 +217,21 @@ def downloadTrackObj(trackAPI, settings, overwriteBitrate=False):
|
||||||
track['selectedFormat'] = 8
|
track['selectedFormat'] = 8
|
||||||
track['selectedFilesize'] = track['filesize']['default']
|
track['selectedFilesize'] = track['filesize']['default']
|
||||||
track['album']['bitrate'] = track['selectedFormat']
|
track['album']['bitrate'] = track['selectedFormat']
|
||||||
track['album']['picUrl'] = "http://e-cdn-images.deezer.com/images/cover/{}/{}x{}-000000-80-0-0.jpg".format(track['album']['pic'], settings['taggingSettings']['artworkSize'], settings['taggingSettings']['artworkSize'])
|
track['album']['picUrl'] = "http://e-cdn-images.deezer.com/images/cover/{}/{}x{}-000000-80-0-0.jpg".format(track['album']['pic'], settings['embeddedArtworkSize'], settings['embeddedArtworkSize'])
|
||||||
|
|
||||||
# Create the filename
|
# Create the filename
|
||||||
filename = "{artist} - {title}".format(title=track['title'], artist=track['mainArtist']['name']) + extensions[
|
filename = "{artist} - {title}".format(title=track['title'], artist=track['mainArtist']['name']) + extensions[
|
||||||
track['selectedFormat']]
|
track['selectedFormat']]
|
||||||
writepath = os.path.join(settings['pathSettings']['downloadLocation'], filename)
|
writepath = os.path.join(settings['downloadLocation'], filename)
|
||||||
|
|
||||||
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'])
|
||||||
with open(writepath, 'wb') as stream:
|
with open(writepath, 'wb') as stream:
|
||||||
dz.stream_track(track['id'], track['downloadUrl'], stream)
|
dz.stream_track(track['id'], track['downloadUrl'], stream)
|
||||||
if track['selectedFormat'] in [3, 1, 8]:
|
if track['selectedFormat'] in [3, 1, 8]:
|
||||||
tagID3(writepath, track, settings['taggingSettings']['tags'])
|
tagID3(writepath, track, settings['tags'])
|
||||||
elif track['selectedFormat'] == 9:
|
elif track['selectedFormat'] == 9:
|
||||||
tagFLAC(writepath, track, settings['taggingSettings']['tags'])
|
tagFLAC(writepath, track, settings['tags'])
|
||||||
|
|
||||||
def download_track(id, settings, overwriteBitrate=False):
|
def download_track(id, settings, overwriteBitrate=False):
|
||||||
trackAPI = dz.get_track_gw(id)
|
trackAPI = dz.get_track_gw(id)
|
||||||
|
|
|
@ -6,23 +6,27 @@ import json
|
||||||
import deemix.utils.localpaths as localpaths
|
import deemix.utils.localpaths as localpaths
|
||||||
|
|
||||||
settings = {}
|
settings = {}
|
||||||
|
defaultSettings = {}
|
||||||
|
|
||||||
def initSettings():
|
def initSettings():
|
||||||
global settings
|
global settings
|
||||||
|
global defaultSettings
|
||||||
currentFolder = path.abspath(path.dirname(__file__))
|
currentFolder = path.abspath(path.dirname(__file__))
|
||||||
if not path.isdir(localpaths.getConfigFolder()):
|
|
||||||
mkdir(localpaths.getConfigFolder())
|
|
||||||
configFolder = localpaths.getConfigFolder()
|
configFolder = localpaths.getConfigFolder()
|
||||||
|
if not path.isdir(configFolder):
|
||||||
|
mkdir(configFolder)
|
||||||
|
with open(path.join(currentFolder, 'default.json'), 'r') as d:
|
||||||
|
defaultSettings = json.load(d)
|
||||||
if not path.isfile(path.join(configFolder, 'config.json')):
|
if not path.isfile(path.join(configFolder, 'config.json')):
|
||||||
with open(path.join(configFolder, 'config.json'), 'w') as f:
|
with open(path.join(configFolder, 'config.json'), 'w') as f:
|
||||||
with open(path.join(currentFolder, 'default.json'), 'r') as d:
|
f.write(json.dumps(defaultSettings))
|
||||||
f.write(d.read())
|
|
||||||
with open(path.join(configFolder, 'config.json'), 'r') as configFile:
|
with open(path.join(configFolder, 'config.json'), 'r') as configFile:
|
||||||
settings = json.load(configFile)
|
settings = json.load(configFile)
|
||||||
if settings['pathSettings']['downloadLocation'] == "":
|
settingsCheck()
|
||||||
settings['pathSettings']['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
|
if settings['downloadLocation'] == "":
|
||||||
|
settings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
|
||||||
saveSettings(settings)
|
saveSettings(settings)
|
||||||
if not path.isdir(settings['pathSettings']['downloadLocation']):
|
if not path.isdir(settings['downloadLocation']):
|
||||||
mkdir(settings['pathSettings']['downloadLocation'])
|
mkdir(settings['pathSettings']['downloadLocation'])
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
@ -36,3 +40,18 @@ def saveSettings(newSettings):
|
||||||
with open(path.join(localpaths.getConfigFolder(), 'config.json'), 'w') as configFile:
|
with open(path.join(localpaths.getConfigFolder(), 'config.json'), 'w') as configFile:
|
||||||
json.dump(settings, configFile)
|
json.dump(settings, configFile)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def settingsCheck():
|
||||||
|
global settings
|
||||||
|
global defaultSettings
|
||||||
|
changes = 0
|
||||||
|
for x in defaultSettings:
|
||||||
|
if not x in settings or type(settings[x]) != type(defaultSettings[x]):
|
||||||
|
settings[x] = defaultSettings[x]
|
||||||
|
changes+=1
|
||||||
|
for x in defaultSettings['tags']:
|
||||||
|
if not x in settings['tags'] or type(settings['tags'][x]) != type(defaultSettings['tags'][x]):
|
||||||
|
settings['tags'][x] = defaultSettings['tags'][x]
|
||||||
|
changes+=1
|
||||||
|
if changes > 0:
|
||||||
|
saveSettings(settings)
|
||||||
|
|
Loading…
Reference in New Issue