Skip to content

Commit

Permalink
Handle stuck issue after adding direct link torrent with qbittorrent
Browse files Browse the repository at this point in the history
- for some server there is not response to some direct links maybe blocked whatever

Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed Oct 21, 2024
1 parent 89facdd commit 862831a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bot/helper/ext_utils/jdownloader_booter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions bot/helper/mirror_leech_utils/download_utils/qbit_download.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 862831a

Please sign in to comment.