Skip to content

Commit

Permalink
Minor fix (#76)
Browse files Browse the repository at this point in the history
* Minor fix

* Forgot tag in gd_search.py
  • Loading branch information
rk-shaju authored Oct 10, 2024
1 parent baed38d commit 9c21180
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
15 changes: 14 additions & 1 deletion bot/helper/ext_utils/help_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
"""

thumbnail_layout = """
Thumbnail Layout: -tl
<b>Thumbnail Layout</b>: -tl
/cmd link -tl 3x3 (widthxheight) 3 photos in row and 3 photos in column
"""
Expand All @@ -282,6 +282,17 @@
/cmd link -med (Leech as media)
"""

metadata = """
<b>Metadata</b>: -md
/cmd link -md text
It will add text in your video metadata. (MKV & MP4 supports only)
<b>Metadata Attachment</b>: -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",
Expand All @@ -303,6 +314,7 @@
"ʜʏʙʀɪᴅ\nʟᴇᴇᴄʜ": mixed_leech,
"ᴛʜᴜᴍʙ\nʟᴀʏᴏᴜᴛ": thumbnail_layout,
"ʟᴇᴇᴄʜ\nᴛʏᴘᴇ": leech_as,
"ᴍᴇᴛᴀᴅᴀᴛᴀ\nᴀᴛᴛᴀᴄʜ": metadata,
}

MIRROR_HELP_DICT = {
Expand Down Expand Up @@ -332,6 +344,7 @@
"ʜʏʙʀɪᴅ\nʟᴇᴇᴄʜ": mixed_leech,
"ᴛʜᴜᴍʙ\nʟᴀʏᴏᴜᴛ": thumbnail_layout,
"ʟᴇᴇᴄʜ\nᴛʏᴘᴇ": leech_as,
"ᴍᴇᴛᴀᴅᴀᴛᴀ\nᴀᴛᴛᴀᴄʜ": metadata,
}

CLONE_HELP_DICT = {
Expand Down
19 changes: 11 additions & 8 deletions bot/helper/ext_utils/media_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}")
Expand Down
10 changes: 10 additions & 0 deletions bot/modules/gd_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
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
from ..helper.telegram_helper.filters import CustomFilters
from ..helper.telegram_helper.message_utils import (
anno_checker,
auto_delete_message,
is_admin,
send_message,
edit_message
)
Expand Down Expand Up @@ -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\n<b>cc</b>: {message.from_user.mention}"
msg += f"\n<b>Thank You</b>"
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,
Expand Down

0 comments on commit 9c21180

Please sign in to comment.