Skip to content
This repository was archived by the owner on Sep 29, 2021. It is now read-only.

Commit eb46d79

Browse files
alfianandaaMrMissx
authored andcommitted
userbot: add ssvideo module
squash change from: 1. ProjectAlf: add ssvideo module [alfianandaa/ProjectAlf@d62863e] 2. ssvideo: add download progress [alfianandaa/ProjectAlf@921f840] 3. ssvideo: add missing check condition [MrMissx/UserButt@480adb7] 4. ssvideo: fix typo [MrMissx/UserButt@b43ec1e] Co-authored-by: Alfiananda P.A <[email protected]> Co-authored-by: Mr.Miss <[email protected]> Signed-off-by: MoveAngel <[email protected]>
1 parent 158c057 commit eb46d79

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ urbandict
5555
wikipedia
5656
PyGithub
5757
python-dateutil
58+
vcsi
5859
youtube_search

userbot/modules/ssvideo.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

Comments
 (0)