2020-09-27 21:44:37 +00:00
|
|
|
from pathlib import Path
|
2020-09-03 14:13:57 +00:00
|
|
|
from os import makedirs
|
2020-04-17 10:31:47 +00:00
|
|
|
|
2020-08-15 21:03:05 +00:00
|
|
|
from deemix.app import deemix
|
2020-10-08 11:26:17 +00:00
|
|
|
from deemix.utils import checkFolder
|
2020-08-15 21:03:05 +00:00
|
|
|
|
|
|
|
class cli(deemix):
|
2020-09-27 21:44:37 +00:00
|
|
|
def __init__(self, downloadpath, configFolder=None):
|
2020-10-29 12:00:58 +00:00
|
|
|
super().__init__(configFolder, overwriteDownloadFolder=downloadpath)
|
2020-09-27 21:44:37 +00:00
|
|
|
if downloadpath:
|
2020-09-02 21:19:26 +00:00
|
|
|
print("Using folder: "+self.set.settings['downloadLocation'])
|
2020-08-15 21:03:05 +00:00
|
|
|
|
|
|
|
def downloadLink(self, url, bitrate=None):
|
|
|
|
for link in url:
|
|
|
|
if ';' in link:
|
|
|
|
for l in link.split(";"):
|
2020-09-13 17:26:53 +00:00
|
|
|
self.qm.addToQueue(self.dz, l, self.set.settings, bitrate)
|
2020-08-15 21:03:05 +00:00
|
|
|
else:
|
2020-09-13 17:26:53 +00:00
|
|
|
self.qm.addToQueue(self.dz, link, self.set.settings, bitrate)
|
2020-08-15 21:03:05 +00:00
|
|
|
|
|
|
|
def requestValidArl(self):
|
|
|
|
while True:
|
|
|
|
arl = input("Paste here your arl:")
|
|
|
|
if self.dz.login_via_arl(arl):
|
|
|
|
break
|
|
|
|
return arl
|
|
|
|
|
|
|
|
def login(self):
|
2020-09-27 21:44:37 +00:00
|
|
|
configFolder = Path(self.set.configFolder)
|
|
|
|
if not configFolder.is_dir():
|
2020-09-03 14:13:57 +00:00
|
|
|
makedirs(configFolder, exist_ok=True)
|
2020-09-27 21:44:37 +00:00
|
|
|
if (configFolder / '.arl').is_file():
|
|
|
|
with open(configFolder / '.arl', 'r') as f:
|
2020-08-15 21:03:05 +00:00
|
|
|
arl = f.readline().rstrip("\n")
|
|
|
|
if not self.dz.login_via_arl(arl):
|
|
|
|
arl = self.requestValidArl()
|
2020-07-29 10:18:22 +00:00
|
|
|
else:
|
2020-08-15 21:03:05 +00:00
|
|
|
arl = self.requestValidArl()
|
2020-09-27 21:44:37 +00:00
|
|
|
with open(configFolder / '.arl', 'w') as f:
|
2020-08-15 21:03:05 +00:00
|
|
|
f.write(arl)
|