deemix-py/deemix/app/cli.py

39 lines
986 B
Python
Raw Normal View History

2020-04-07 22:19:27 +00:00
#!/usr/bin/env python3
import os.path as path
from os import mkdir
from deemix.utils import localpaths
from deemix.api.deezer import Deezer
from deemix.app.queuemanager import addToQueue
from deemix.app.spotify import SpotifyHelper
2020-04-07 22:19:27 +00:00
dz = Deezer()
sp = SpotifyHelper()
2020-04-07 22:19:27 +00:00
2020-04-07 22:19:27 +00:00
def requestValidArl():
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():
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:48:57 +00:00
arl = f.readline()
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):
addToQueue(dz, sp, url, settings, bitrate)