Made settings more compatible with deezloader
This commit is contained in:
parent
c0f419e1be
commit
a4e4ecdb98
|
@ -1,36 +1,63 @@
|
|||
{
|
||||
"pathSettings": {
|
||||
"downloadLocation": ""
|
||||
},
|
||||
"appSettings": {
|
||||
"maxBitrate": 3
|
||||
},
|
||||
"taggingSettings": {
|
||||
"artworkSize": 800,
|
||||
"tags": {
|
||||
"title": true,
|
||||
"artist": true,
|
||||
"album": true,
|
||||
"cover": true,
|
||||
"trackNumber": true,
|
||||
"trackTotal": false,
|
||||
"discNumber": true,
|
||||
"discTotal": false,
|
||||
"albumArtist": true,
|
||||
"genre": true,
|
||||
"year": true,
|
||||
"date": true,
|
||||
"explicit": false,
|
||||
"isrc": true,
|
||||
"length": false,
|
||||
"barcode": false,
|
||||
"bpm": true,
|
||||
"replayGain": false,
|
||||
"label": true,
|
||||
"lyrics": false,
|
||||
"copyright": false,
|
||||
"composer": false,
|
||||
"involvedPeople": false
|
||||
}
|
||||
"downloadLocation": "",
|
||||
"tracknameTemplate": "%artist% - %title%",
|
||||
"albumTracknameTemplate": "%number% - %title%",
|
||||
"playlistTracknameTemplate": "%position% - %artist% - %title%",
|
||||
"playlistNameTemplate": "%name%",
|
||||
"artistNameTemplate": "",
|
||||
"albumNameTemplate": "%artist% - %album%",
|
||||
"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": {
|
||||
"title": true,
|
||||
"artist": true,
|
||||
"album": true,
|
||||
"cover": true,
|
||||
"trackNumber": true,
|
||||
"trackTotal": false,
|
||||
"discNumber": true,
|
||||
"discTotal": false,
|
||||
"albumArtist": true,
|
||||
"genre": true,
|
||||
"year": true,
|
||||
"date": true,
|
||||
"explicit": false,
|
||||
"isrc": true,
|
||||
"length": false,
|
||||
"barcode": false,
|
||||
"bpm": true,
|
||||
"replayGain": false,
|
||||
"label": true,
|
||||
"lyrics": false,
|
||||
"copyright": false,
|
||||
"composer": false,
|
||||
"involvedPeople": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ def downloadTrackObj(trackAPI, settings, overwriteBitrate=False):
|
|||
if overwriteBitrate:
|
||||
bitrate = overwriteBitrate
|
||||
else:
|
||||
bitrate = settings['appSettings']['maxBitrate']
|
||||
bitrate = settings['maxBitrate']
|
||||
bitrateFound = False;
|
||||
if int(bitrate) == 9:
|
||||
track['selectedFormat'] = 9
|
||||
|
@ -217,21 +217,21 @@ def downloadTrackObj(trackAPI, settings, overwriteBitrate=False):
|
|||
track['selectedFormat'] = 8
|
||||
track['selectedFilesize'] = track['filesize']['default']
|
||||
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
|
||||
filename = "{artist} - {title}".format(title=track['title'], artist=track['mainArtist']['name']) + extensions[
|
||||
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['selectedFormat'])
|
||||
with open(writepath, 'wb') as stream:
|
||||
dz.stream_track(track['id'], track['downloadUrl'], stream)
|
||||
if track['selectedFormat'] in [3, 1, 8]:
|
||||
tagID3(writepath, track, settings['taggingSettings']['tags'])
|
||||
tagID3(writepath, track, settings['tags'])
|
||||
elif track['selectedFormat'] == 9:
|
||||
tagFLAC(writepath, track, settings['taggingSettings']['tags'])
|
||||
tagFLAC(writepath, track, settings['tags'])
|
||||
|
||||
def download_track(id, settings, overwriteBitrate=False):
|
||||
trackAPI = dz.get_track_gw(id)
|
||||
|
|
|
@ -6,23 +6,27 @@ import json
|
|||
import deemix.utils.localpaths as localpaths
|
||||
|
||||
settings = {}
|
||||
defaultSettings = {}
|
||||
|
||||
def initSettings():
|
||||
global settings
|
||||
global defaultSettings
|
||||
currentFolder = path.abspath(path.dirname(__file__))
|
||||
if not path.isdir(localpaths.getConfigFolder()):
|
||||
mkdir(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')):
|
||||
with open(path.join(configFolder, 'config.json'), 'w') as f:
|
||||
with open(path.join(currentFolder, 'default.json'), 'r') as d:
|
||||
f.write(d.read())
|
||||
f.write(json.dumps(defaultSettings))
|
||||
with open(path.join(configFolder, 'config.json'), 'r') as configFile:
|
||||
settings = json.load(configFile)
|
||||
if settings['pathSettings']['downloadLocation'] == "":
|
||||
settings['pathSettings']['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
|
||||
settingsCheck()
|
||||
if settings['downloadLocation'] == "":
|
||||
settings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
|
||||
saveSettings(settings)
|
||||
if not path.isdir(settings['pathSettings']['downloadLocation']):
|
||||
if not path.isdir(settings['downloadLocation']):
|
||||
mkdir(settings['pathSettings']['downloadLocation'])
|
||||
return settings
|
||||
|
||||
|
@ -36,3 +40,18 @@ def saveSettings(newSettings):
|
|||
with open(path.join(localpaths.getConfigFolder(), 'config.json'), 'w') as configFile:
|
||||
json.dump(settings, configFile)
|
||||
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