|
| 1 | +# Copyright (C) 2020 Alfiananda P.A |
| 2 | +# |
| 3 | +# Licensed under the Raphielscape Public License, Version 1.d (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# |
| 6 | + |
| 7 | +import asyncio |
| 8 | +import os |
| 9 | +import time |
| 10 | + |
| 11 | +from telethon.tl.types import DocumentAttributeFilename |
| 12 | +from userbot import CMD_HELP, bot |
| 13 | +from userbot.events import register |
| 14 | +from userbot.utils import progress |
| 15 | + |
| 16 | + |
| 17 | +@register(outgoing=True, pattern=r"^\.ssvideo(?: |$)(.*)") |
| 18 | +async def ssvideo(framecap): |
| 19 | + if not framecap.reply_to_msg_id: |
| 20 | + return await framecap.edit("`reply to video!`") |
| 21 | + reply_message = await framecap.get_reply_message() |
| 22 | + if not reply_message.media: |
| 23 | + return await framecap.edit("`reply to a video!`") |
| 24 | + try: |
| 25 | + frame = int(framecap.pattern_match.group(1)) |
| 26 | + if frame > 10: |
| 27 | + return await framecap.edit("`hey..dont put that much`") |
| 28 | + except BaseException: |
| 29 | + return await framecap.edit("`Please input number of frame!`") |
| 30 | + if (reply_message.photo |
| 31 | + or (DocumentAttributeFilename(file_name="AnimatedSticker.tgs") |
| 32 | + in reply_message.media.document.attributes) |
| 33 | + or (DocumentAttributeFilename(file_name="sticker.webp") |
| 34 | + in reply_message.media.document.attributes) |
| 35 | + ): |
| 36 | + return await framecap.edit("`Unsupported files!`") |
| 37 | + c_time = time.time() |
| 38 | + await framecap.edit("`Downloading media...`") |
| 39 | + ss = await bot.download_media( |
| 40 | + reply_message, |
| 41 | + "anu.mp4", |
| 42 | + progress_callback=lambda d, t: asyncio.get_event_loop().create_task( |
| 43 | + progress(d, t, framecap, c_time, "[DOWNLOAD]") |
| 44 | + ), |
| 45 | + ) |
| 46 | + try: |
| 47 | + await framecap.edit("`Proccessing...`") |
| 48 | + command = f"vcsi -g {frame}x{frame} {ss} -o ss.png " |
| 49 | + os.system(command) |
| 50 | + await framecap.client.send_file( |
| 51 | + framecap.chat_id, |
| 52 | + "ss.png", |
| 53 | + reply_to=framecap.reply_to_msg_id, |
| 54 | + ) |
| 55 | + await framecap.delete() |
| 56 | + except BaseException as e: |
| 57 | + await framecap.edit(f"{e}") |
| 58 | + os.system("rm -rf *.png *.mp4") |
| 59 | + |
| 60 | + |
| 61 | +CMD_HELP.update( |
| 62 | + { |
| 63 | + "ssvideo": ".ssvideo <grid>\ |
| 64 | + \nUsage: Capture video frames by <grid> x <grid>.\ |
| 65 | + \n*max grid is 10." |
| 66 | + } |
| 67 | +) |
0 commit comments