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 <e.anastayyar@gmail.com>
This commit is contained in:
anasty17 2024-10-21 04:31:52 +03:00
parent 89facdd1a3
commit 862831a68a
No known key found for this signature in database
GPG Key ID: EAAC8A2DF2861DE4
2 changed files with 9 additions and 4 deletions

View File

@ -92,12 +92,12 @@ class JDownloader(MyJdApi):
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()

View File

@ -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