Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed Oct 16, 2024
1 parent 375838a commit cb601eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions bot/helper/listeners/jdownloader_listener.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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!")
Expand Down
6 changes: 4 additions & 2 deletions bot/helper/mirror_leech_utils/download_utils/jd_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down

0 comments on commit cb601eb

Please sign in to comment.