diff --git a/bot/helper/download_status.py b/bot/helper/download_status.py index 8ece80c..0487f72 100644 --- a/bot/helper/download_status.py +++ b/bot/helper/download_status.py @@ -60,4 +60,7 @@ class DownloadStatus: def download(self): self.__update() - return self.__download \ No newline at end of file + return self.__download + + def uid(self): + return self.__uid diff --git a/bot/helper/download_tools.py b/bot/helper/download_tools.py index a72928c..7a32bd0 100644 --- a/bot/helper/download_tools.py +++ b/bot/helper/download_tools.py @@ -24,6 +24,7 @@ class DownloadHelper: def add_download(self, link: str): download = None + link = link.strip() if self.is_url(link): if link.endswith('.torrent'): self.__is_torrent = True @@ -32,7 +33,8 @@ class DownloadHelper: download = aria2.add_magnet(link, {'dir': DOWNLOAD_DIR + str(self.__listener.message.message_id)}) self.__is_torrent = True else: - self.__listener.onDownloadError("No download URL or URL malformed", None, None) + _list = get_download_status_list() + self.__listener.onDownloadError("No download URL or URL malformed", get_download_status_list(), None) return download_dict[self.__listener.message.message_id] = DownloadStatus(download.gid, self.__listener.message.message_id) diff --git a/bot/mirror.py b/bot/mirror.py index 6fcb2d9..0c70e7e 100644 --- a/bot/mirror.py +++ b/bot/mirror.py @@ -33,11 +33,12 @@ class MirrorListener(listeners.MirrorListeners): def onDownloadError(self, error, progress_status_list: list, index: int): LOGGER.error(error) - if progress_status_list is not None: + deleteMessage(self.context, status_reply_dict[self.update.effective_chat.id]) + if index is not None: fs_utils.clean_download(progress_status_list[index].path()) + del download_dict[self.message.message_id] msg = f"@{self.message.from_user.username} your download has been cancelled due to: {error}" sendMessage(msg, self.context, self.update) - del download_dict[self.message.message_id] def onUploadStarted(self, progress_status_list: list, index: int): pass