File permission is now set to 770

This fixes #19
This commit is contained in:
RemixDev 2020-06-05 20:00:40 +02:00
parent 7b7249d399
commit cb4b7b6f63
4 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
import os.path as path
from os import mkdir
from os import mkdir, chmod
from deemix.utils import localpaths
from deemix.api.deezer import Deezer
@ -32,6 +32,7 @@ def login():
arl = requestValidArl()
with open(path.join(configFolder, '.arl'), 'w') as f:
f.write(arl)
chmod(path.join(configFolder, '.arl'), 0o770)
def downloadLink(url, settings, bitrate=None):

View File

@ -3,7 +3,7 @@ import os.path
import re
import traceback
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 time import sleep
@ -93,6 +93,7 @@ def downloadImage(url, path, overwrite="n"):
image.raise_for_status()
with open(path, 'wb') as f:
f.write(image.content)
chmod(path, 0o770)
return path
except ConnectionError:
sleep(1)
@ -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']:
with open(os.path.join(filepath, filename + '.lrc'), 'wb') as f:
f.write(track['lyrics']['sync'].encode('utf-8'))
chmod(os.path.join(filepath, filename + '.lrc'), 0o770)
# Save local album art
if coverPath:
@ -710,6 +712,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
try:
with open(writepath, 'wb') as stream:
stream_track(dz, track, stream, trackAPI, queueItem, interface)
chmod(writepath, 0o770)
except downloadCancelled:
remove(writepath)
result['cancel'] = True
@ -885,13 +888,16 @@ def after_download(tracks, settings, queueItem):
if settings['logErrors'] and errors != "":
with open(os.path.join(extrasPath, 'errors.txt'), 'wb') as f:
f.write(errors.encode('utf-8'))
chmod(os.path.join(extrasPath, 'errors.txt'), 0o770)
if settings['logSearched'] and searched != "":
with open(os.path.join(extrasPath, 'searched.txt'), 'wb') as f:
f.write(searched.encode('utf-8'))
chmod(os.path.join(extrasPath, 'searched.txt'), 0o770)
if settings['createM3U8File']:
with open(os.path.join(extrasPath, 'playlist.m3u8'), 'wb') as f:
for line in playlist:
f.write((line + "\n").encode('utf-8'))
chmod(os.path.join(extrasPath, 'playlist.m3u8'), 0o770)
if settings['executeCommand'] != "":
execute(settings['executeCommand'].replace("%folder%", extrasPath))
return extrasPath
@ -914,6 +920,7 @@ def after_download_single(track, settings, queueItem):
orig += "\r\n"
orig += track['searched'] + "\r\n"
f.write(orig.encode('utf-8'))
chmod(os.path.join(track['extrasPath'], 'searched.txt'), 0o770)
if settings['executeCommand'] != "":
execute(settings['executeCommand'].replace("%folder%", track['extrasPath']))
return track['extrasPath']

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import json
import os.path as path
from os import makedirs
from os import makedirs, chmod
import random
import string
import logging
@ -30,6 +30,7 @@ def initSettings(localFolder = False, configFolder = None):
if not path.isfile(path.join(configFolder, 'config.json')):
with open(path.join(configFolder, 'config.json'), 'w') as f:
json.dump(defaultSettings, f, indent=2)
chmod(path.join(configFolder, 'config.json'), 0o770)
with open(path.join(configFolder, 'config.json'), 'r') as configFile:
settings = json.load(configFile)
settingsCheck()
@ -59,6 +60,7 @@ def saveSettings(newSettings):
settings = newSettings
with open(path.join(configDir, 'config.json'), 'w') as configFile:
json.dump(settings, configFile, indent=2)
chmod(path.join(configDir, 'config.json'), 0o770)
return True

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import json
import os.path as path
from os import mkdir
from os import mkdir, chmod
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
@ -42,6 +42,7 @@ class SpotifyHelper:
if not path.isfile(path.join(self.configFolder, 'authCredentials.json')):
with open(path.join(self.configFolder, 'authCredentials.json'), 'w') as f:
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:
self.credentials = json.load(credentialsFile)
self.checkCredentials()
@ -64,6 +65,7 @@ class SpotifyHelper:
def setCredentials(self, spotifyCredentials):
with open(path.join(self.configFolder, 'authCredentials.json'), 'w') as f:
json.dump(spotifyCredentials, f, indent=2)
chmod(path.join(self.configFolder, 'authCredentials.json'), 0o770)
self.credentials = spotifyCredentials
self.checkCredentials()