From 9c21180a7e44a90b3636674698adb019f1845ee0 Mon Sep 17 00:00:00 2001 From: RK Shaju Date: Thu, 10 Oct 2024 21:49:39 +0600 Subject: [PATCH] Minor fix (#76) * Minor fix * Forgot tag in gd_search.py --- bot/helper/ext_utils/help_messages.py | 15 ++++++++++++++- bot/helper/ext_utils/media_utils.py | 19 +++++++++++-------- bot/modules/gd_search.py | 10 ++++++++++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/bot/helper/ext_utils/help_messages.py b/bot/helper/ext_utils/help_messages.py index b2c9eaebfef9..ca39094d604e 100644 --- a/bot/helper/ext_utils/help_messages.py +++ b/bot/helper/ext_utils/help_messages.py @@ -270,7 +270,7 @@ """ thumbnail_layout = """ -Thumbnail Layout: -tl +Thumbnail Layout: -tl /cmd link -tl 3x3 (widthxheight) 3 photos in row and 3 photos in column """ @@ -282,6 +282,17 @@ /cmd link -med (Leech as media) """ +metadata = """ +Metadata: -md +/cmd link -md text +It will add text in your video metadata. (MKV & MP4 supports only) + + +Metadata Attachment: -mda +/cmd link -mda tg-message-link(doc or photo) or any direct link +It will embed thumb in your video. (MKV & MP4 supports only) +""" + YT_HELP_DICT = { "main": yt, "ʀᴇɴᴀᴍᴇ\nꜰɪʟᴇ": f"{new_name}\nNote: Don't add file extension", @@ -303,6 +314,7 @@ "ʜʏʙʀɪᴅ\nʟᴇᴇᴄʜ": mixed_leech, "ᴛʜᴜᴍʙ\nʟᴀʏᴏᴜᴛ": thumbnail_layout, "ʟᴇᴇᴄʜ\nᴛʏᴘᴇ": leech_as, + "ᴍᴇᴛᴀᴅᴀᴛᴀ\nᴀᴛᴛᴀᴄʜ": metadata, } MIRROR_HELP_DICT = { @@ -332,6 +344,7 @@ "ʜʏʙʀɪᴅ\nʟᴇᴇᴄʜ": mixed_leech, "ᴛʜᴜᴍʙ\nʟᴀʏᴏᴜᴛ": thumbnail_layout, "ʟᴇᴇᴄʜ\nᴛʏᴘᴇ": leech_as, + "ᴍᴇᴛᴀᴅᴀᴛᴀ\nᴀᴛᴛᴀᴄʜ": metadata, } CLONE_HELP_DICT = { diff --git a/bot/helper/ext_utils/media_utils.py b/bot/helper/ext_utils/media_utils.py index ae2787bf4ede..ab58b2cfb02b 100644 --- a/bot/helper/ext_utils/media_utils.py +++ b/bot/helper/ext_utils/media_utils.py @@ -35,6 +35,8 @@ ARCH_EXT, get_mime_type ) +from .links_utils import is_telegram_link +from ..telegram_helper.message_utils import get_tg_link_message async def convert_video(listener, video_file, ext, retry=False): @@ -890,18 +892,12 @@ async def create_sample_video(listener, video_file, sample_duration, part_durati return False -SUPPORTED_VIDEO_EXTENSIONS = { - ".mp4", - ".mkv" -} - - async def edit_video_metadata(listener, dir): data = listener.metadata dir_path = Path(dir) - if dir_path.suffix.lower() not in SUPPORTED_VIDEO_EXTENSIONS: + if not dir_path.lower().endswith(("mkv", "mp4")): return dir file_name = dir_path.name @@ -1074,12 +1070,19 @@ async def add_attachment(listener, dir): data = listener.m_attachment dir_path = Path(dir) - if dir_path.suffix.lower() not in SUPPORTED_VIDEO_EXTENSIONS: + if not dir_path.lower().endswith(("mkv", "mp4")): return dir file_name = dir_path.name work_path = dir_path.with_suffix(".temp.mkv") + if data: + if is_telegram_link(data): + msg = (await get_tg_link_message(data))[0] + data = ( + await create_thumb(msg) if msg.photo or msg.document else "" + ) + data_ext = data.split(".")[-1].lower() if not (mime_type := MIME_TYPES.get(data_ext)): LOGGER.error(f"Unsupported attachment type: {data_ext}") diff --git a/bot/modules/gd_search.py b/bot/modules/gd_search.py index 354a0fac07ab..1888f2b9dfed 100644 --- a/bot/modules/gd_search.py +++ b/bot/modules/gd_search.py @@ -20,6 +20,7 @@ get_telegraph_list ) from ..helper.ext_utils.status_utils import get_readable_time +from ..helper.ext_utils.token_manager import checking_access from ..helper.task_utils.gdrive_utils.search import GoogleDriveSearch from ..helper.telegram_helper.bot_commands import BotCommands from ..helper.telegram_helper.button_build import ButtonMaker @@ -27,6 +28,7 @@ from ..helper.telegram_helper.message_utils import ( anno_checker, auto_delete_message, + is_admin, send_message, edit_message ) @@ -224,6 +226,14 @@ async def gdrive_search(_, message): ) return user_id = from_user.id + if not await is_admin(message, user_id): + msg, btn = await checking_access(user_id) + if msg is not None: + msg += f"\n\ncc: {message.from_user.mention}" + msg += f"\nThank You" + gdmsg = await send_message(message, msg, btn.build_menu(1)) + await auto_delete_message(message, gdmsg) + return buttons = await list_buttons(user_id) gmsg = await send_message( message,