From 16e45f3f2088008c9d8fcbf7bc9a24463cf48cbb Mon Sep 17 00:00:00 2001 From: 5hojib Date: Wed, 1 Jan 2025 23:24:53 +0600 Subject: [PATCH] MediaInfoCommand --- bot/__main__.py | 2 +- bot/core/handlers.py | 4 ++++ bot/helper/telegram_helper/bot_commands.py | 1 + bot/modules/__init__.py | 2 ++ bot/modules/mediainfo.py | 13 +++---------- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bot/__main__.py b/bot/__main__.py index b5d1d4a89..9a0ed6e0e 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -45,7 +45,7 @@ "YtdlCommand": "- Mirror yt-dlp supported link", "YtdlLeechCommand": "- Leech through yt-dlp supported link", "CloneCommand": "- Copy file/folder to Drive", - # Mediainfo command + "MediaInfoCommand": "- Get mediainfo", "ForceStartCommand": "- Start task from queue", "CountCommand": "- Count file/folder on Google Drive", "ListCommand": "- Search in Drive", diff --git a/bot/core/handlers.py b/bot/core/handlers.py index f7d3f3ff4..f33b437c0 100644 --- a/bot/core/handlers.py +++ b/bot/core/handlers.py @@ -175,6 +175,10 @@ def add_handlers(): BotCommands.RestartSessionsCommand, CustomFilters.sudo, ), + "mediainfo": ( + mediainfo, + BotCommands.MediaInfoCommand, + CustomFilters.authorized,) } for handler_func, command_name, custom_filter in command_filters.values(): diff --git a/bot/helper/telegram_helper/bot_commands.py b/bot/helper/telegram_helper/bot_commands.py index d9e3d8e67..fb65ca158 100644 --- a/bot/helper/telegram_helper/bot_commands.py +++ b/bot/helper/telegram_helper/bot_commands.py @@ -11,6 +11,7 @@ def __init__(self): self.LeechCommand = [f"leech{i}", f"l{i}"] self.YtdlLeechCommand = [f"ytdlleech{i}", f"yl{i}"] self.CloneCommand = f"clone{i}" + self.MediaInfoCommand = f"mediainfo{i}" self.CountCommand = f"count{i}" self.DeleteCommand = f"del{i}" self.CancelAllCommand = f"cancelall{i}" diff --git a/bot/modules/__init__.py b/bot/modules/__init__.py index f8069d86b..51da1fa48 100644 --- a/bot/modules/__init__.py +++ b/bot/modules/__init__.py @@ -19,6 +19,7 @@ restart_notification, restart_sessions, ) +from .mediainfo import mediainfo from .rss import get_rss_menu, rss_listener from .search import initiate_search_tools, torrent_search, torrent_search_update from .services import log, ping, start @@ -44,6 +45,7 @@ "cancel_all_update", "cancel_multi", "clear", + "mediainfo", "clone_node", "confirm_restart", "confirm_selection", diff --git a/bot/modules/mediainfo.py b/bot/modules/mediainfo.py index 86bf3ef06..62fcde7fc 100644 --- a/bot/modules/mediainfo.py +++ b/bot/modules/mediainfo.py @@ -11,7 +11,8 @@ from pyrogram.filters import command from pyrogram.handlers import MessageHandler -from bot import LOGGER, bot +from bot import LOGGER +from bot.core.aeon_client import TgClient from bot.helper.aeon_utils.access_check import token_check from bot.helper.aeon_utils.gen_mediainfo import parseinfo from bot.helper.ext_utils.bot_utils import cmd_exec @@ -51,7 +52,7 @@ async def gen_mediainfo(message, link=None, media=None, msg=None): if media.file_size <= 50000000: await msg.download(ospath.join(getcwd(), des_path)) else: - async for chunk in bot.stream_media(media, limit=5): + async for chunk in TgClient.bot.stream_media(media, limit=5): async with aiopen(des_path, "ab") as f: await f.write(chunk) @@ -103,11 +104,3 @@ async def mediainfo(_, message): await send_message(message, help_msg) else: await send_message(message, help_msg) - - -bot.add_handler( - MessageHandler( - mediainfo, - filters=command(BotCommands.MediaInfoCommand) & CustomFilters.authorized, - ), -)