Added a simple login function

because of api changes
This commit is contained in:
RemixDev 2020-04-06 20:21:06 +02:00
parent 3f61f6b167
commit 1f5ca4fe9a
2 changed files with 26 additions and 0 deletions

View File

@ -8,6 +8,7 @@ from deemix.app.settings import initSettings
@click.argument('url') @click.argument('url')
def download(bitrate, url): def download(bitrate, url):
settings = initSettings() settings = initSettings()
app.login()
app.downloadLink(url, settings, bitrate) app.downloadLink(url, settings, bitrate)
click.echo("All done!") click.echo("All done!")

View File

@ -1,11 +1,36 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from deemix.api.deezer import Deezer from deemix.api.deezer import Deezer
import deemix.utils.localpaths as localpaths
from deemix.utils.misc import getIDFromLink, getTypeFromLink, getBitrateInt from deemix.utils.misc import getIDFromLink, getTypeFromLink, getBitrateInt
from deemix.app.downloader import download_track, download_album, download_playlist, download_artist, download_spotifytrack, download_spotifyalbum from deemix.app.downloader import download_track, download_album, download_playlist, download_artist, download_spotifytrack, download_spotifyalbum
from os import system as execute from os import system as execute
import os.path as path
from os import mkdir, rmdir
dz = Deezer() dz = Deezer()
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)
def downloadLink(url, settings, bitrate=None): def downloadLink(url, settings, bitrate=None):
forcedBitrate = getBitrateInt(bitrate) forcedBitrate = getBitrateInt(bitrate)
type = getTypeFromLink(url) type = getTypeFromLink(url)