From 2c16035dce409e1e929d119f99ef872a612e6037 Mon Sep 17 00:00:00 2001 From: anasty17 Date: Thu, 6 Jun 2024 01:47:27 +0300 Subject: [PATCH] Some minor fixes Signed-off-by: anasty17 --- bot/__init__.py | 1 - bot/helper/ext_utils/db_handler.py | 2 +- bot/helper/ext_utils/media_utils.py | 5 ++--- bot/helper/listeners/aria2_listener.py | 6 +++--- .../download_utils/direct_link_generator.py | 8 ++++---- bot/helper/mirror_leech_utils/rclone_utils/transfer.py | 5 +++-- bot/modules/exec.py | 2 +- bot/modules/ytdlp.py | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/bot/__init__.py b/bot/__init__.py index 192ea53beb3..92ef9d8c0f0 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -24,7 +24,6 @@ from time import time from tzlocal import get_localzone from uvloop import install -from asyncio import run as aiorun # from faulthandler import enable as faulthandler_enable # faulthandler_enable() diff --git a/bot/helper/ext_utils/db_handler.py b/bot/helper/ext_utils/db_handler.py index bf3a9c678a0..1a1d214aae8 100644 --- a/bot/helper/ext_utils/db_handler.py +++ b/bot/helper/ext_utils/db_handler.py @@ -37,7 +37,7 @@ async def db_load(self): return # Save bot settings try: - res = await self._db.settings.config.replace_one( + await self._db.settings.config.replace_one( {"_id": bot_id}, config_dict, upsert=True ) except Exception as e: diff --git a/bot/helper/ext_utils/media_utils.py b/bot/helper/ext_utils/media_utils.py index 4b0656e5436..1274d667151 100644 --- a/bot/helper/ext_utils/media_utils.py +++ b/bot/helper/ext_utils/media_utils.py @@ -202,9 +202,8 @@ async def get_document_type(path): path, ] ) - if res := result[1]: - if mime_type.startswith("video"): - is_video = True + if result[1] and mime_type.startswith("video"): + is_video = True except Exception as e: LOGGER.error(f"Get Document Type: {e}. Mostly File not found! - File: {path}") if mime_type.startswith("video"): diff --git a/bot/helper/listeners/aria2_listener.py b/bot/helper/listeners/aria2_listener.py index 396ca592a28..25717fb3e20 100644 --- a/bot/helper/listeners/aria2_listener.py +++ b/bot/helper/listeners/aria2_listener.py @@ -37,7 +37,7 @@ async def _onDownloadStarted(api, gid): if download.is_removed or download.followed_by_ids: await deleteMessage(meta) break - download = download.live + download = await sync_to_async(download.live) return else: LOGGER.info(f"onDownloadStarted: {download.name} - Gid: {gid}") @@ -46,7 +46,7 @@ async def _onDownloadStarted(api, gid): if task := await getTaskByGid(gid): download = await sync_to_async(api.get_download, gid) await sleep(2) - download = download.live + download = await sync_to_async(download.live) task.listener.name = download.name msg, button = await stop_duplicate_check(task.listener) if msg: @@ -127,7 +127,7 @@ async def _onBtDownloadComplete(api, gid): await task.listener.onDownloadComplete() if Intervals["stopAll"]: return - download = download.live + download = await sync_to_async(download.live) if task.listener.seed: if download.is_complete: if task := await getTaskByGid(gid): diff --git a/bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py b/bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py index a77368da0c4..a2abb79a879 100644 --- a/bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py +++ b/bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py @@ -1445,13 +1445,13 @@ def filelions_and_streamwish(url): if quality == version["name"]: return version["url"] elif version["name"] == "l": - error += f"\nLow" + error += "\nLow" elif version["name"] == "n": - error += f"\nNormal" + error += "\nNormal" elif version["name"] == "o": - error += f"\nOriginal" + error += "\nOriginal" elif version["name"] == "h": - error += f"\nHD" + error += "\nHD" error += f" {url}_{version['name']}" raise DirectDownloadLinkException(f"ERROR: {error}") diff --git a/bot/helper/mirror_leech_utils/rclone_utils/transfer.py b/bot/helper/mirror_leech_utils/rclone_utils/transfer.py index 8b6faa9e4e5..9304e201c25 100644 --- a/bot/helper/mirror_leech_utils/rclone_utils/transfer.py +++ b/bot/helper/mirror_leech_utils/rclone_utils/transfer.py @@ -401,8 +401,9 @@ async def clone(self, config_path, src_remote, src_path, mime_type, method): return None, None elif return_code != 0: error = ( - await self._proc.stderr.read() - ).decode().strip() or "Use /shell cat rlog.txt to see more information" + (await self._proc.stderr.read()).decode().strip() + or "Use /shell cat rlog.txt to see more information" + ) LOGGER.error(error) await self._listener.onUploadError(error[:4000]) return None, None diff --git a/bot/modules/exec.py b/bot/modules/exec.py index 2fb3db4739e..dac91bd4a38 100644 --- a/bot/modules/exec.py +++ b/bot/modules/exec.py @@ -88,7 +88,7 @@ async def do(func, message): func_return = ( await sync_to_async(rfunc) if func == "exec" else await rfunc() ) - except Exception as e: + except: value = stdout.getvalue() return f"{value}{format_exc()}" else: diff --git a/bot/modules/ytdlp.py b/bot/modules/ytdlp.py index 8f9e594a956..971320302c7 100644 --- a/bot/modules/ytdlp.py +++ b/bot/modules/ytdlp.py @@ -390,7 +390,7 @@ async def newEvent(self): return if "mdisk.me" in self.link: - name, self.link = await _mdisk(self.link, name) + self.name, self.link = await _mdisk(self.link, self.name) try: await self.beforeStart()