From 862831a68a28e06734c7741310ad3d1b7baf6a56 Mon Sep 17 00:00:00 2001 From: anasty17 Date: Mon, 21 Oct 2024 04:31:52 +0300 Subject: [PATCH] Handle stuck issue after adding direct link torrent with qbittorrent - for some server there is not response to some direct links maybe blocked whatever Signed-off-by: anasty17 --- bot/helper/ext_utils/jdownloader_booter.py | 4 ++-- .../mirror_leech_utils/download_utils/qbit_download.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bot/helper/ext_utils/jdownloader_booter.py b/bot/helper/ext_utils/jdownloader_booter.py index 48eede846e8..d7a6b29daf1 100644 --- a/bot/helper/ext_utils/jdownloader_booter.py +++ b/bot/helper/ext_utils/jdownloader_booter.py @@ -92,12 +92,12 @@ async def jdconnect(self): MYJDErrorEmailNotConfirmedException, ) as err: self.error = f"{err}".strip() - LOGGER.info(f"Failed to connect with jdownloader! ERROR: {self.error}") + LOGGER.error(f"Failed to connect with jdownloader! ERROR: {self.error}") self.device = None return False except MYJDException as e: self.error = f"{e}".strip() - LOGGER.info( + LOGGER.error( f"Failed to connect with jdownloader! Retrying... ERROR: {self.error}" ) return await self.jdconnect() diff --git a/bot/helper/mirror_leech_utils/download_utils/qbit_download.py b/bot/helper/mirror_leech_utils/download_utils/qbit_download.py index 643e0c2aa00..39c21f1e147 100644 --- a/bot/helper/mirror_leech_utils/download_utils/qbit_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/qbit_download.py @@ -1,5 +1,6 @@ from aiofiles.os import remove, path as aiopath from asyncio import sleep +from time import time from bot import ( task_dict, @@ -56,20 +57,24 @@ async def add_qb_torrent(listener, path, ratio, seed_time): tags=f"{listener.mid}", ratio_limit=ratio, seeding_time_limit=seed_time, - headers={"user-agent": "Wget/1.12"}, ) if op.lower() == "ok.": tor_info = await sync_to_async( qbittorrent_client.torrents_info, tag=f"{listener.mid}" ) + start_time = time() if len(tor_info) == 0: - while True: + while (time() - start_time) <= 60: tor_info = await sync_to_async( qbittorrent_client.torrents_info, tag=f"{listener.mid}" ) if len(tor_info) > 0: break await sleep(1) + else: + raise Exception( + "Use torrent file or magnet link incase you have added direct link! Timed Out!" + ) tor_info = tor_info[0] listener.name = tor_info.name ext_hash = tor_info.hash