def read(): txt = "" if "XDG_CONFIG_HOME" in os.environ: txt = getFileContent( os.environ['XDG_CONFIG_HOME'] + '/.tidal-dl.token.json', True) else: txt = getFileContent(os.environ['HOME'] + '/.tidal-dl.token.json', True) if txt == "": return TokenSettings() txt = __decode__(txt) data = json.loads(txt) ret = dictToModel(data, TokenSettings()) return ret
def read(): txt = getFileContent('./usersettings.json', True) if txt == "": return UserSettings() txt = __decode__(txt) data = json.loads(txt) ret = dictToModel(data, UserSettings()) return ret
def __merger__(files, filepath): try: with open(filepath, "wb") as fd: for item in files: data = getFileContent(item, True) fd.write(data) return True except: return False
def read(): path = TokenSettings.__getFilePath__() txt = getFileContent(path, True) if txt == "": return TokenSettings() txt = __decode__(txt) data = json.loads(txt) ret = dictToModel(data, TokenSettings()) return ret
def read(): txt = getFileContent('./settings.json') if txt == "": return Settings() data = json.loads(txt) ret = dictToModel(data, Settings()) ret.audioQuality = Settings.getAudioQuality(ret.audioQuality) ret.videoQuality = Settings.getVideoQuality(ret.videoQuality) return ret
def read(): txt = "" if "XDG_CONFIG_HOME" in os.environ: txt = getFileContent( os.environ['XDG_CONFIG_HOME'] + '/.tidal-dl.json', True) else: txt = getFileContent(os.environ['HOME'] + '/.tidal-dl.json', True) if txt == "": return Settings() data = json.loads(txt) ret = dictToModel(data, Settings()) ret.audioQuality = Settings.getAudioQuality(ret.audioQuality) ret.videoQuality = Settings.getVideoQuality(ret.videoQuality) ret.usePlaylistFolder = ret.usePlaylistFolder == True or ret.usePlaylistFolder is None ret.multiThreadDownload = ret.multiThreadDownload == True or ret.multiThreadDownload is None if ret.albumFolderFormat is None: ret.albumFolderFormat = Settings.getDefualtAlbumFolderFormat() if ret.trackFileFormat is None: ret.trackFileFormat = Settings.getDefualtTrackFileFormat() return ret
def read(): txt = getFileContent('./settings.json') if txt == "": return Settings() data = json.loads(txt) ret = dictToModel(data, Settings()) ret.audioQuality = Settings.getAudioQuality(ret.audioQuality) ret.videoQuality = Settings.getVideoQuality(ret.videoQuality) ret.usePlaylistFolder = ret.usePlaylistFolder == True or ret.usePlaylistFolder is None ret.multiThreadDownload = ret.multiThreadDownload == True or ret.multiThreadDownload is None return ret
def __file__(user, conf, string): txt = getFileContent(string) if isNull(txt): Printf.err("Nothing can read!") return array = txt.split('\n') for item in array: if isNull(item): continue if item[0] == '#': continue if item[0] == '[': continue start(user, conf, item)
def read(): path = Settings.__getFilePath__() txt = getFileContent(path, True) if txt == "": return Settings() data = json.loads(txt) ret = dictToModel(data, Settings()) ret.audioQuality = Settings.getAudioQuality(ret.audioQuality) ret.videoQuality = Settings.getVideoQuality(ret.videoQuality) ret.usePlaylistFolder = ret.usePlaylistFolder == True or ret.usePlaylistFolder is None ret.multiThreadDownload = ret.multiThreadDownload == True or ret.multiThreadDownload is None if ret.albumFolderFormat is None: ret.albumFolderFormat = Settings.getDefaultAlbumFolderFormat() if ret.trackFileFormat is None: ret.trackFileFormat = Settings.getDefaultTrackFileFormat() return ret
def getInstalledVersion(projectName, pipver='3'): try: cmd = 'pip' + pipver + ' freeze' stdoutFile = 'piplibversion-stdout.txt' fp = open(stdoutFile, 'w') res = subprocess.call(cmd, shell=True, stdout=fp, stderr=fp) fp.close() txt = fileHelper.getFileContent(stdoutFile) lines = txt.split('\n') for item in lines: if item.find(projectName + '==') == 0: version = item[len((projectName + '==')):] return version except Exception as e: pass return ''
def _checkTool(self): check = False try: cmd = "ffmpeg -V" stdoutFile = 'ffmpegcheck-stdout.txt' fp = open(stdoutFile, 'w') if sys.version_info[0] > 2: res = subprocess.call(cmd, timeout=self.mergerTimeout, shell=True, stdout=fp, stderr=fp) else: res = subprocess.call(cmd, shell=True, stdout=fp, stderr=fp) fp.close() txt = fileHelper.getFileContent(stdoutFile) if 'version' in txt and 'Copyright' in txt: check = True except: pass pathHelper.remove(stdoutFile) return check