2020-04-07 22:19:27 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-04-17 10:31:47 +00:00
|
|
|
import os.path as path
|
2020-06-13 07:58:45 +00:00
|
|
|
from os import mkdir
|
2020-04-17 10:31:47 +00:00
|
|
|
|
2020-05-05 08:27:48 +00:00
|
|
|
from deemix.utils import localpaths
|
2020-04-17 10:31:47 +00:00
|
|
|
from deemix.api.deezer import Deezer
|
2020-04-10 14:12:21 +00:00
|
|
|
from deemix.app.queuemanager import addToQueue
|
2020-04-16 08:37:02 +00:00
|
|
|
from deemix.app.spotify import SpotifyHelper
|
2020-04-07 22:19:27 +00:00
|
|
|
|
|
|
|
dz = Deezer()
|
2020-04-16 08:37:02 +00:00
|
|
|
sp = SpotifyHelper()
|
2020-04-07 22:19:27 +00:00
|
|
|
|
2020-04-17 10:31:47 +00:00
|
|
|
|
2020-04-07 22:19:27 +00:00
|
|
|
def requestValidArl():
|
2020-04-17 10:31:47 +00:00
|
|
|
while True:
|
|
|
|
arl = input("Paste here your arl:")
|
|
|
|
if dz.login_via_arl(arl):
|
|
|
|
break
|
|
|
|
return arl
|
|
|
|
|
2020-04-07 22:19:27 +00:00
|
|
|
|
|
|
|
def login():
|
2020-04-17 10:31:47 +00:00
|
|
|
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:
|
2020-05-07 14:57:23 +00:00
|
|
|
arl = f.readline().rstrip("\n")
|
2020-04-17 10:31:47 +00:00
|
|
|
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 downloadLink(url, settings, bitrate=None):
|
2020-04-17 10:31:47 +00:00
|
|
|
addToQueue(dz, sp, url, settings, bitrate)
|