From cb601eb8dfcb1df59151fb7833716553c52ef208 Mon Sep 17 00:00:00 2001 From: anasty17 Date: Wed, 16 Oct 2024 05:55:32 +0300 Subject: [PATCH] minor fixes Signed-off-by: anasty17 --- bot/helper/listeners/jdownloader_listener.py | 6 +++--- bot/helper/mirror_leech_utils/download_utils/jd_download.py | 6 ++++-- .../mirror_leech_utils/download_utils/yt_dlp_download.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bot/helper/listeners/jdownloader_listener.py b/bot/helper/listeners/jdownloader_listener.py index 199cfbf0168..0623b8e5bfd 100644 --- a/bot/helper/listeners/jdownloader_listener.py +++ b/bot/helper/listeners/jdownloader_listener.py @@ -1,6 +1,6 @@ -from asyncio import sleep, wait_for +from asyncio import sleep -from bot import intervals, jd_lock, jd_downloads, LOGGER +from bot import intervals, jd_lock, jd_downloads from ..ext_utils.bot_utils import new_task, retry_function from ..ext_utils.jdownloader_booter import jdownloader from ..ext_utils.status_utils import get_task_by_gid @@ -12,7 +12,7 @@ async def remove_download(gid): return await retry_function( jdownloader.device.downloads.remove_links, - package_ids=[gid], + package_ids=jd_downloads[gid]["ids"], ) if task := await get_task_by_gid(gid): await task.listener.on_download_error("Download removed manually!") diff --git a/bot/helper/mirror_leech_utils/download_utils/jd_download.py b/bot/helper/mirror_leech_utils/download_utils/jd_download.py index 2c73abd73df..580cb2f1226 100644 --- a/bot/helper/mirror_leech_utils/download_utils/jd_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/jd_download.py @@ -112,8 +112,6 @@ def trim_path(path): async def add_jd_download(listener, path): try: async with jd_lock: - gid = token_urlsafe(12) - jd_downloads[gid] = {"status": "collect", "path": path} if jdownloader.device is None: raise MYJDException(jdownloader.error) @@ -141,6 +139,10 @@ async def add_jd_download(listener, path): jdownloader.device.linkgrabber.remove_links, package_ids=odl_list, ) + + gid = token_urlsafe(12) + jd_downloads[gid] = {"status": "collect", "path": path} + if await aiopath.exists(listener.link): async with aiopen(listener.link, "rb") as dlc: content = await dlc.read() diff --git a/bot/helper/mirror_leech_utils/download_utils/yt_dlp_download.py b/bot/helper/mirror_leech_utils/download_utils/yt_dlp_download.py index b02514cc3c1..472cf444728 100644 --- a/bot/helper/mirror_leech_utils/download_utils/yt_dlp_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/yt_dlp_download.py @@ -182,7 +182,7 @@ def _download(self, path): ) return if self._listener.is_cancelled: - raise ValueError + return async_to_sync(self._listener.on_download_complete) except ValueError: self._on_download_error("Download Stopped by User!")