forked from 1Danish-00/CompressorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstuff.py
129 lines (112 loc) · 4.75 KB
/
stuff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# This file is part of the CompressorBot distribution.
# Copyright (c) 2021 Danish_00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# License can be found in < https://github.com/1Danish-00/CompressorBot/blob/main/License> .
from .worker import *
async def up(event):
if not event.is_private:
return
stt = dt.now()
ed = dt.now()
v = ts(int((ed - uptime).seconds) * 1000)
ms = (ed - stt).microseconds / 1000
p = f"🌋Pɪɴɢ = {ms}ms"
await event.reply(v + "\n" + p)
async def start(event):
ok = await event.client(GetFullUserRequest(event.sender_id))
await event.reply(
f"Hi `{ok.user.first_name}`\nThis is A CompressorBot Which Can Encode Videos.\nReduce Size of Videos With Negligible Quality Change\nU can Generate Samples/screenshots too.",
buttons=[
[Button.inline("HELP", data="ihelp")],
[
Button.url("SOURCE CODE", url="github.com/1Danish-00/CompressorBot"),
Button.url("DEVELOPER", url="t.me/danish_00"),
],
],
)
async def help(event):
await event.reply(
"**🐠 A Quality CompressorBot**\n\n+This Bot Compress Videos With Negligible Quality Change.\n+Generate Sample Compressed Video\n+Easy to Use\n-Due to Quality Settings Bot Takes Time To Compress.\nSo Be patience Nd Send videos One By One After Completing.\nDont Spam Bot.\n\nJust Forward Video To Get Options"
)
async def ihelp(event):
await event.edit(
"**🐠 A Quality CompressorBot**\n\n+This Bot Compress Videos With Negligible Quality Change.\n+Generate Sample Compressed Video\n+Screenshots Too\n+Easy to Use\n-Due to Quality Settings Bot Takes Time To Compress.\nSo Be patience Nd Send videos One By One After Completing.\nDont Spam Bot.\n\nJust Forward Video To Get Options",
buttons=[Button.inline("BACK", data="beck")],
)
async def beck(event):
ok = await event.client(GetFullUserRequest(event.sender_id))
await event.edit(
f"Hi `{ok.user.first_name}`\nThis is A CompressorBot Which Can Encode Videos.\nReduce Size of Videos With Negligible Quality Change\nU can Generate Samples/screenshots too.",
buttons=[
[Button.inline("HELP", data="ihelp")],
[
Button.url("SOURCE CODE", url="github.com/1Danish-00/"),
Button.url("DEVELOPER", url="t.me/danish_00"),
],
],
)
async def sencc(e):
key = e.pattern_match.group(1).decode("UTF-8")
await e.edit(
"Choose Mode",
buttons=[
[
Button.inline("Default Compress", data=f"encc{key}"),
Button.inline("Custom Compress", data=f"ccom{key}"),
],
[Button.inline("Back", data=f"back{key}")],
],
)
async def back(e):
key = e.pattern_match.group(1).decode("UTF-8")
await e.edit(
"🐠 **What To Do** 🐠",
buttons=[
[
Button.inline("GENERATE SAMPLE", data=f"gsmpl{key}"),
Button.inline("SCREENSHOTS", data=f"sshot{key}"),
],
[Button.inline("COMPRESS", data=f"sencc{key}")],
],
)
async def ccom(e):
await e.edit("Send Ur Custom Name For That File")
wah = e.pattern_match.group(1).decode("UTF-8")
wh = decode(wah)
out, dl, thum, dtime = wh.split(";")
chat = e.sender_id
async with e.client.conversation(chat) as cv:
reply = cv.wait_event(events.NewMessage(from_users=chat))
repl = await reply
if "." in repl.text:
q = repl.text.split(".")[-1]
g = repl.text.replace(q, "mkv")
else:
g = repl.text + ".mkv"
outt = f"encode/{chat}/{g}"
x = await repl.reply(
f"Custom File Name : {g}\n\nSend Thumbnail Picture For it."
)
replyy = cv.wait_event(events.NewMessage(from_users=chat))
rep = await replyy
if rep.media:
tb = await e.client.download_media(rep.media, f"thumb/{chat}.jpg")
elif rep.text and not (rep.text).startswith("/"):
url = rep.text
os.system(f"wget {url}")
tb = url.replace("https://telegra.ph/file/", "")
else:
tb = thum
omk = await rep.reply(f"Thumbnail {tb} Setted Successfully")
hehe = f"{outt};{dl};{tb};{dtime}"
key = code(hehe)
await customenc(omk, key)