parent
7b7249d399
commit
cb4b7b6f63
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os.path as path
|
import os.path as path
|
||||||
from os import mkdir
|
from os import mkdir, chmod
|
||||||
|
|
||||||
from deemix.utils import localpaths
|
from deemix.utils import localpaths
|
||||||
from deemix.api.deezer import Deezer
|
from deemix.api.deezer import Deezer
|
||||||
|
@ -32,6 +32,7 @@ def login():
|
||||||
arl = requestValidArl()
|
arl = requestValidArl()
|
||||||
with open(path.join(configFolder, '.arl'), 'w') as f:
|
with open(path.join(configFolder, '.arl'), 'w') as f:
|
||||||
f.write(arl)
|
f.write(arl)
|
||||||
|
chmod(path.join(configFolder, '.arl'), 0o770)
|
||||||
|
|
||||||
|
|
||||||
def downloadLink(url, settings, bitrate=None):
|
def downloadLink(url, settings, bitrate=None):
|
||||||
|
|
|
@ -3,7 +3,7 @@ import os.path
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from os import makedirs, remove, system as execute
|
from os import makedirs, remove, system as execute, chmod
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
@ -93,7 +93,8 @@ def downloadImage(url, path, overwrite="n"):
|
||||||
image.raise_for_status()
|
image.raise_for_status()
|
||||||
with open(path, 'wb') as f:
|
with open(path, 'wb') as f:
|
||||||
f.write(image.content)
|
f.write(image.content)
|
||||||
return path
|
chmod(path, 0o770)
|
||||||
|
return path
|
||||||
except ConnectionError:
|
except ConnectionError:
|
||||||
sleep(1)
|
sleep(1)
|
||||||
return downloadImage(url, path, overwrite)
|
return downloadImage(url, path, overwrite)
|
||||||
|
@ -674,6 +675,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
if not os.path.isfile(os.path.join(filepath, filename + '.lrc')) or settings['overwriteFile'] in ['y', 't']:
|
if not os.path.isfile(os.path.join(filepath, filename + '.lrc')) or settings['overwriteFile'] in ['y', 't']:
|
||||||
with open(os.path.join(filepath, filename + '.lrc'), 'wb') as f:
|
with open(os.path.join(filepath, filename + '.lrc'), 'wb') as f:
|
||||||
f.write(track['lyrics']['sync'].encode('utf-8'))
|
f.write(track['lyrics']['sync'].encode('utf-8'))
|
||||||
|
chmod(os.path.join(filepath, filename + '.lrc'), 0o770)
|
||||||
|
|
||||||
# Save local album art
|
# Save local album art
|
||||||
if coverPath:
|
if coverPath:
|
||||||
|
@ -710,6 +712,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
try:
|
try:
|
||||||
with open(writepath, 'wb') as stream:
|
with open(writepath, 'wb') as stream:
|
||||||
stream_track(dz, track, stream, trackAPI, queueItem, interface)
|
stream_track(dz, track, stream, trackAPI, queueItem, interface)
|
||||||
|
chmod(writepath, 0o770)
|
||||||
except downloadCancelled:
|
except downloadCancelled:
|
||||||
remove(writepath)
|
remove(writepath)
|
||||||
result['cancel'] = True
|
result['cancel'] = True
|
||||||
|
@ -885,13 +888,16 @@ def after_download(tracks, settings, queueItem):
|
||||||
if settings['logErrors'] and errors != "":
|
if settings['logErrors'] and errors != "":
|
||||||
with open(os.path.join(extrasPath, 'errors.txt'), 'wb') as f:
|
with open(os.path.join(extrasPath, 'errors.txt'), 'wb') as f:
|
||||||
f.write(errors.encode('utf-8'))
|
f.write(errors.encode('utf-8'))
|
||||||
|
chmod(os.path.join(extrasPath, 'errors.txt'), 0o770)
|
||||||
if settings['logSearched'] and searched != "":
|
if settings['logSearched'] and searched != "":
|
||||||
with open(os.path.join(extrasPath, 'searched.txt'), 'wb') as f:
|
with open(os.path.join(extrasPath, 'searched.txt'), 'wb') as f:
|
||||||
f.write(searched.encode('utf-8'))
|
f.write(searched.encode('utf-8'))
|
||||||
|
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:
|
with open(os.path.join(extrasPath, 'playlist.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)
|
||||||
if settings['executeCommand'] != "":
|
if settings['executeCommand'] != "":
|
||||||
execute(settings['executeCommand'].replace("%folder%", extrasPath))
|
execute(settings['executeCommand'].replace("%folder%", extrasPath))
|
||||||
return extrasPath
|
return extrasPath
|
||||||
|
@ -914,6 +920,7 @@ def after_download_single(track, settings, queueItem):
|
||||||
orig += "\r\n"
|
orig += "\r\n"
|
||||||
orig += track['searched'] + "\r\n"
|
orig += track['searched'] + "\r\n"
|
||||||
f.write(orig.encode('utf-8'))
|
f.write(orig.encode('utf-8'))
|
||||||
|
chmod(os.path.join(track['extrasPath'], 'searched.txt'), 0o770)
|
||||||
if settings['executeCommand'] != "":
|
if settings['executeCommand'] != "":
|
||||||
execute(settings['executeCommand'].replace("%folder%", track['extrasPath']))
|
execute(settings['executeCommand'].replace("%folder%", track['extrasPath']))
|
||||||
return track['extrasPath']
|
return track['extrasPath']
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import json
|
import json
|
||||||
import os.path as path
|
import os.path as path
|
||||||
from os import makedirs
|
from os import makedirs, chmod
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import logging
|
import logging
|
||||||
|
@ -30,6 +30,7 @@ def initSettings(localFolder = False, configFolder = None):
|
||||||
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:
|
||||||
json.dump(defaultSettings, f, indent=2)
|
json.dump(defaultSettings, f, indent=2)
|
||||||
|
chmod(path.join(configFolder, 'config.json'), 0o770)
|
||||||
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)
|
||||||
settingsCheck()
|
settingsCheck()
|
||||||
|
@ -59,6 +60,7 @@ def saveSettings(newSettings):
|
||||||
settings = newSettings
|
settings = newSettings
|
||||||
with open(path.join(configDir, 'config.json'), 'w') as configFile:
|
with open(path.join(configDir, 'config.json'), 'w') as configFile:
|
||||||
json.dump(settings, configFile, indent=2)
|
json.dump(settings, configFile, indent=2)
|
||||||
|
chmod(path.join(configDir, 'config.json'), 0o770)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import json
|
import json
|
||||||
import os.path as path
|
import os.path as path
|
||||||
from os import mkdir
|
from os import mkdir, chmod
|
||||||
|
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
|
@ -42,6 +42,7 @@ class SpotifyHelper:
|
||||||
if not path.isfile(path.join(self.configFolder, 'authCredentials.json')):
|
if not path.isfile(path.join(self.configFolder, 'authCredentials.json')):
|
||||||
with open(path.join(self.configFolder, 'authCredentials.json'), 'w') as f:
|
with open(path.join(self.configFolder, 'authCredentials.json'), 'w') as f:
|
||||||
json.dump({'clientId': "", 'clientSecret': ""}, f, indent=2)
|
json.dump({'clientId': "", 'clientSecret': ""}, f, indent=2)
|
||||||
|
chmod(path.join(self.configFolder, 'authCredentials.json'), 0o770)
|
||||||
with open(path.join(self.configFolder, 'authCredentials.json'), 'r') as credentialsFile:
|
with open(path.join(self.configFolder, 'authCredentials.json'), 'r') as credentialsFile:
|
||||||
self.credentials = json.load(credentialsFile)
|
self.credentials = json.load(credentialsFile)
|
||||||
self.checkCredentials()
|
self.checkCredentials()
|
||||||
|
@ -64,6 +65,7 @@ class SpotifyHelper:
|
||||||
def setCredentials(self, spotifyCredentials):
|
def setCredentials(self, spotifyCredentials):
|
||||||
with open(path.join(self.configFolder, 'authCredentials.json'), 'w') as f:
|
with open(path.join(self.configFolder, 'authCredentials.json'), 'w') as f:
|
||||||
json.dump(spotifyCredentials, f, indent=2)
|
json.dump(spotifyCredentials, f, indent=2)
|
||||||
|
chmod(path.join(self.configFolder, 'authCredentials.json'), 0o770)
|
||||||
self.credentials = spotifyCredentials
|
self.credentials = spotifyCredentials
|
||||||
self.checkCredentials()
|
self.checkCredentials()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue