parent
d5bb5685f0
commit
1e2fc4077d
|
|
@ -17,16 +17,15 @@ class AriaDownloadHelper(DownloadHelper):
|
||||||
@new_thread
|
@new_thread
|
||||||
def __onDownloadStarted(self, api, gid):
|
def __onDownloadStarted(self, api, gid):
|
||||||
if STOP_DUPLICATE or TORRENT_DIRECT_LIMIT is not None or TAR_UNZIP_LIMIT is not None:
|
if STOP_DUPLICATE or TORRENT_DIRECT_LIMIT is not None or TAR_UNZIP_LIMIT is not None:
|
||||||
sleep(1)
|
sleep(2)
|
||||||
dl = getDownloadByGid(gid)
|
dl = getDownloadByGid(gid)
|
||||||
download = aria2.get_download(gid)
|
download = aria2.get_download(gid)
|
||||||
if STOP_DUPLICATE:
|
if STOP_DUPLICATE and dl is not None:
|
||||||
LOGGER.info(f"Checking File/Folder if already in Drive...")
|
LOGGER.info(f"Checking File/Folder if already in Drive...")
|
||||||
sleep(1)
|
|
||||||
sname = aria2.get_download(gid).name
|
sname = aria2.get_download(gid).name
|
||||||
if self.listener.isTar:
|
if dl.getListener().isTar:
|
||||||
sname = sname + ".tar"
|
sname = sname + ".tar"
|
||||||
if self.listener.extract:
|
if dl.getListener().extract:
|
||||||
smsg = None
|
smsg = None
|
||||||
else:
|
else:
|
||||||
gdrive = GoogleDriveHelper(None)
|
gdrive = GoogleDriveHelper(None)
|
||||||
|
|
@ -36,9 +35,9 @@ class AriaDownloadHelper(DownloadHelper):
|
||||||
aria2.remove([download], force=True)
|
aria2.remove([download], force=True)
|
||||||
sendMarkup("Here are the search results:", dl.getListener().bot, dl.getListener().update, button)
|
sendMarkup("Here are the search results:", dl.getListener().bot, dl.getListener().update, button)
|
||||||
return
|
return
|
||||||
if TORRENT_DIRECT_LIMIT is not None or TAR_UNZIP_LIMIT is not None:
|
if (TORRENT_DIRECT_LIMIT is not None or TAR_UNZIP_LIMIT is not None) and dl is not None:
|
||||||
limit = None
|
limit = None
|
||||||
if TAR_UNZIP_LIMIT is not None and (self.listener.isTar or self.listener.extract):
|
if TAR_UNZIP_LIMIT is not None and (dl.getListener().isTar or dl.getListener().extract):
|
||||||
LOGGER.info(f"Checking File/Folder Size...")
|
LOGGER.info(f"Checking File/Folder Size...")
|
||||||
limit = TAR_UNZIP_LIMIT
|
limit = TAR_UNZIP_LIMIT
|
||||||
mssg = f'Tar/Unzip limit is {TAR_UNZIP_LIMIT}'
|
mssg = f'Tar/Unzip limit is {TAR_UNZIP_LIMIT}'
|
||||||
|
|
@ -47,7 +46,6 @@ class AriaDownloadHelper(DownloadHelper):
|
||||||
limit = TORRENT_DIRECT_LIMIT
|
limit = TORRENT_DIRECT_LIMIT
|
||||||
mssg = f'Torrent/Direct limit is {TORRENT_DIRECT_LIMIT}'
|
mssg = f'Torrent/Direct limit is {TORRENT_DIRECT_LIMIT}'
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
sleep(1.5)
|
|
||||||
size = aria2.get_download(gid).total_length
|
size = aria2.get_download(gid).total_length
|
||||||
limit = limit.split(' ', maxsplit=1)
|
limit = limit.split(' ', maxsplit=1)
|
||||||
limitint = int(limit[0])
|
limitint = int(limit[0])
|
||||||
|
|
@ -103,7 +101,8 @@ class AriaDownloadHelper(DownloadHelper):
|
||||||
aria2.listen_to_notifications(threaded=True, on_download_start=self.__onDownloadStarted,
|
aria2.listen_to_notifications(threaded=True, on_download_start=self.__onDownloadStarted,
|
||||||
on_download_error=self.__onDownloadError,
|
on_download_error=self.__onDownloadError,
|
||||||
on_download_stop=self.__onDownloadStopped,
|
on_download_stop=self.__onDownloadStopped,
|
||||||
on_download_complete=self.__onDownloadComplete)
|
on_download_complete=self.__onDownloadComplete,
|
||||||
|
timeout=1)
|
||||||
|
|
||||||
def add_download(self, link: str, path, listener, filename):
|
def add_download(self, link: str, path, listener, filename):
|
||||||
if is_magnet(link):
|
if is_magnet(link):
|
||||||
|
|
@ -116,4 +115,3 @@ class AriaDownloadHelper(DownloadHelper):
|
||||||
with download_dict_lock:
|
with download_dict_lock:
|
||||||
download_dict[listener.uid] = AriaDownloadStatus(download.gid, listener)
|
download_dict[listener.uid] = AriaDownloadStatus(download.gid, listener)
|
||||||
LOGGER.info(f"Started: {download.gid} DIR:{download.dir} ")
|
LOGGER.info(f"Started: {download.gid} DIR:{download.dir} ")
|
||||||
self.listener = listener
|
|
||||||
|
|
|
||||||
|
|
@ -77,12 +77,6 @@ class AriaDownloadStatus(Status):
|
||||||
def download(self):
|
def download(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def updateName(self,name):
|
|
||||||
self.__name = name
|
|
||||||
|
|
||||||
def updateGid(self,gid):
|
|
||||||
self.__gid = gid
|
|
||||||
|
|
||||||
def getListener(self):
|
def getListener(self):
|
||||||
return self.__listener
|
return self.__listener
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ def _mirror(bot, update, isTar=False, extract=False):
|
||||||
try:
|
try:
|
||||||
link = direct_link_generator(link)
|
link = direct_link_generator(link)
|
||||||
except DirectDownloadLinkException as e:
|
except DirectDownloadLinkException as e:
|
||||||
LOGGER.info(f'{link}: {e}')
|
LOGGER.info(e)
|
||||||
if "ERROR:" in str(e):
|
if "ERROR:" in str(e):
|
||||||
sendMessage(f"{e}", bot, update)
|
sendMessage(f"{e}", bot, update)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue