mirror of
https://github.com/anasty17/mirror-leech-telegram-bot.git
synced 2025-01-08 12:07:33 +08:00
Minor fix for jdwonloader sync while download and when adding cred from botsettings
Signed-off-by: anasty17 <e.anastayyar@gmail.com>
This commit is contained in:
parent
cb16cb378d
commit
094c79a459
@ -85,13 +85,12 @@ async def _jd_listener():
|
||||
for dl in all_packages
|
||||
if dl["saveTo"].startswith(path)
|
||||
]
|
||||
if len(jd_downloads[d_gid]["ids"]) == 0:
|
||||
await remove_download(d_gid)
|
||||
if len(jd_downloads[d_gid]["ids"]) == 0:
|
||||
await remove_download(d_gid)
|
||||
|
||||
completed_packages = [
|
||||
if completed_packages := [
|
||||
pack["uuid"] for pack in packages if pack.get("finished", False)
|
||||
]
|
||||
if completed_packages:
|
||||
]:
|
||||
for d_gid, d_dict in list(jd_downloads.items()):
|
||||
if d_dict["status"] == "down":
|
||||
is_finished = all(
|
||||
|
@ -39,6 +39,7 @@ from bot import (
|
||||
nzb_options,
|
||||
get_nzb_options,
|
||||
get_qb_options,
|
||||
jd_lock,
|
||||
)
|
||||
from ..helper.ext_utils.bot_utils import (
|
||||
SetInterval,
|
||||
@ -333,7 +334,7 @@ async def edit_variable(_, message, pre_message, key):
|
||||
]:
|
||||
await rclone_serve_booter()
|
||||
elif key in ["JD_EMAIL", "JD_PASS"]:
|
||||
jdownloader.initiate()
|
||||
await jdownloader.initiate()
|
||||
elif key == "RSS_DELAY":
|
||||
add_job()
|
||||
elif key == "USET_SERVERS":
|
||||
@ -442,11 +443,21 @@ async def edit_nzb_server(_, message, pre_message, key, index=0):
|
||||
|
||||
|
||||
async def sync_jdownloader():
|
||||
if not config_dict["DATABASE_URL"] or jdownloader.device is None:
|
||||
return
|
||||
try:
|
||||
await wait_for(retry_function(jdownloader.update_devices), timeout=10)
|
||||
except:
|
||||
async with jd_lock:
|
||||
if not config_dict["DATABASE_URL"] or jdownloader.device is None:
|
||||
return
|
||||
try:
|
||||
await wait_for(retry_function(jdownloader.update_devices), timeout=10)
|
||||
except:
|
||||
is_connected = await jdownloader.jdconnect()
|
||||
if not is_connected:
|
||||
LOGGER.error(jdownloader.error)
|
||||
return
|
||||
isDeviceConnected = await jdownloader.connectToDevice()
|
||||
if not isDeviceConnected:
|
||||
LOGGER.error(jdownloader.error)
|
||||
return
|
||||
await jdownloader.device.system.exit_jd()
|
||||
is_connected = await jdownloader.jdconnect()
|
||||
if not is_connected:
|
||||
LOGGER.error(jdownloader.error)
|
||||
@ -454,17 +465,8 @@ async def sync_jdownloader():
|
||||
isDeviceConnected = await jdownloader.connectToDevice()
|
||||
if not isDeviceConnected:
|
||||
LOGGER.error(jdownloader.error)
|
||||
return
|
||||
await jdownloader.device.system.exit_jd()
|
||||
if await aiopath.exists("cfg.zip"):
|
||||
await remove("cfg.zip")
|
||||
is_connected = await jdownloader.jdconnect()
|
||||
if not is_connected:
|
||||
LOGGER.error(jdownloader.error)
|
||||
return
|
||||
isDeviceConnected = await jdownloader.connectToDevice()
|
||||
if not isDeviceConnected:
|
||||
LOGGER.error(jdownloader.error)
|
||||
await (
|
||||
await create_subprocess_exec("7z", "a", "cfg.zip", "/JDownloader/cfg")
|
||||
).wait()
|
||||
@ -595,14 +597,8 @@ async def edit_bot_settings(client, query):
|
||||
show_alert=True,
|
||||
)
|
||||
return
|
||||
if jd_downloads:
|
||||
await query.answer(
|
||||
"You can't sync settings while using jdownloader!",
|
||||
show_alert=True,
|
||||
)
|
||||
return
|
||||
await query.answer(
|
||||
"Syncronization Started. JDownloader will get restarted. It takes up to 5 sec!",
|
||||
"Syncronization Started. JDownloader will get restarted. It takes up to 10 sec!",
|
||||
show_alert=True,
|
||||
)
|
||||
await sync_jdownloader()
|
||||
|
Loading…
Reference in New Issue
Block a user