2020-03-02 12:46:48 +00:00
|
|
|
from deemix.api.deezer import Deezer
|
2020-04-06 18:21:06 +00:00
|
|
|
import deemix.utils.localpaths as localpaths
|
2020-04-10 14:12:21 +00:00
|
|
|
from deemix.app.queuemanager import addToQueue
|
2020-04-07 22:19:27 +00:00
|
|
|
from deemix.app.settings import initSettings
|
2020-03-21 10:53:43 +00:00
|
|
|
from os import system as execute
|
2020-04-06 18:21:06 +00:00
|
|
|
import os.path as path
|
|
|
|
from os import mkdir, rmdir
|
2020-03-02 12:46:48 +00:00
|
|
|
|
|
|
|
dz = Deezer()
|
2020-04-07 22:19:27 +00:00
|
|
|
settings = {}
|
2020-03-02 12:46:48 +00:00
|
|
|
|
2020-04-06 18:21:06 +00:00
|
|
|
def requestValidArl():
|
|
|
|
while True:
|
|
|
|
arl = input("Paste here your arl:")
|
|
|
|
if dz.login_via_arl(arl):
|
|
|
|
break
|
|
|
|
return arl
|
|
|
|
|
|
|
|
def login():
|
|
|
|
configFolder = localpaths.getConfigFolder()
|
|
|
|
if not path.isdir(configFolder):
|
|
|
|
mkdir(configFolder)
|
|
|
|
if path.isfile(path.join(configFolder, '.arl')):
|
|
|
|
with open(path.join(configFolder, '.arl'), 'r') as f:
|
|
|
|
arl = f.read()
|
|
|
|
if not dz.login_via_arl(arl):
|
|
|
|
arl = requestValidArl()
|
|
|
|
else:
|
|
|
|
arl = requestValidArl()
|
|
|
|
with open(path.join(configFolder, '.arl'), 'w') as f:
|
|
|
|
f.write(arl)
|
|
|
|
|
2020-04-07 22:19:27 +00:00
|
|
|
def initialize():
|
|
|
|
global settings
|
|
|
|
settings = initSettings()
|
|
|
|
login()
|
|
|
|
return True
|
2020-04-06 18:21:06 +00:00
|
|
|
|
2020-04-08 16:43:35 +00:00
|
|
|
def mainSearch(term):
|
2020-04-09 14:06:33 +00:00
|
|
|
return dz.search_main_gw(term)
|
|
|
|
|
|
|
|
def search(term, type, start, nb):
|
|
|
|
return dz.search_gw(term, type, start, nb)
|
2020-04-07 22:19:27 +00:00
|
|
|
|
2020-04-10 14:12:21 +00:00
|
|
|
def addToQueue_link(url, bitrate=None, socket=None):
|
|
|
|
addToQueue(dz, url, settings, bitrate, socket)
|
|
|
|
|
2020-04-07 22:19:27 +00:00
|
|
|
def downloadLink(url, bitrate=None):
|
2020-03-21 10:53:43 +00:00
|
|
|
if settings['executeCommand'] != "":
|
2020-03-21 11:56:55 +00:00
|
|
|
execute(settings['executeCommand'].replace("%folder%", folder))
|