diff --git a/bot/helper/mirror_utils/download_utils/qbit_downloader.py b/bot/helper/mirror_utils/download_utils/qbit_downloader.py index 77bd5291..94eb29a4 100644 --- a/bot/helper/mirror_utils/download_utils/qbit_downloader.py +++ b/bot/helper/mirror_utils/download_utils/qbit_downloader.py @@ -52,6 +52,7 @@ def add_torrent(self, link, dire, listener, qbitsel): tor_info = self.client.torrents_info(torrent_hashes=self.ext_hash) if len(tor_info) > 0: sendMessage("This torrent is already in list.", listener.bot, listener.update) + self.client.auth_log_out() return if is_file: op = self.client.torrents_add(torrent_files=[link], save_path=dire) @@ -64,6 +65,7 @@ def add_torrent(self, link, dire, listener, qbitsel): while True: if time.time() - self.meta_time >= 300: sendMessage("The torrent was not added. report when u see this error", listener.bot, listener.update) + self.client.auth_log_out() return False tor_info = self.client.torrents_info(torrent_hashes=self.ext_hash) if len(tor_info) > 0: @@ -118,10 +120,12 @@ def add_torrent(self, link, dire, listener, qbitsel): except qba.UnsupportedMediaType415Error as e: LOGGER.error(str(e)) sendMessage("This is an unsupported/invalid link. {str(e)}", listener.bot, listener.update) + self.client.auth_log_out() except Exception as e: LOGGER.error(str(e)) sendMessage(str(e), listener.bot, listener.update) self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.auth_log_out() def update(self): @@ -136,6 +140,7 @@ def update(self): if time.time() - self.meta_time >= 600: self.listener.onDownloadError("Dead Torrent!") self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.auth_log_out() self.updater.cancel() return elif tor_info.state == "downloading": @@ -153,17 +158,20 @@ def update(self): if result: self.listener.onDownloadError(f"{mssg}.\nYour File/Folder size is {get_readable_file_size(size)}") self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.auth_log_out() self.updater.cancel() return elif tor_info.state == "stalledDL": if time.time() - self.stalled_time >= 900: self.listener.onDownloadError("Dead Torrent!") self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.auth_log_out() self.updater.cancel() return elif tor_info.state == "error": self.listener.onDownloadError("Error. IDK why, report in support group") self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.auth_log_out() self.updater.cancel() return elif tor_info.state == "uploading" or tor_info.state.lower().endswith("up"): @@ -176,10 +184,12 @@ def update(self): for folder in subdir: if fnmatch(folder, ".unwanted"): shutil.rmtree(os.path.join(dirpath, folder)) + for dirpath, subdir, files in os.walk(f"{self.dire}", topdown=False): if not os.listdir(dirpath): os.rmdir(dirpath) self.listener.onDownloadComplete() self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True) + self.client.auth_log_out() self.updater.cancel() except: self.updater.cancel() diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index 5ccbd4ee..06f53c44 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -56,6 +56,7 @@ def clean(self): try: aria2.purge() get_client().torrents_delete(torrent_hashes="all", delete_files=True) + get_client().auth_log_out() Interval[0].cancel() del Interval[0] delete_all_messages()