24
24
async def compress (client : Client , message : Message ):
25
25
replied = message .reply_to_message
26
26
if not replied .media :
27
- await edit_or_reply (
28
- message , "<b>Please Reply To A Video</b>" , parse_mode = enums .ParseMode .HTML
29
- )
27
+ await edit_or_reply (message , "<b>Please Reply To A Video</b>" )
30
28
return
31
29
if replied .media :
32
30
c_time = time .time ()
33
31
ms_ = await edit_or_reply (
34
32
message ,
35
33
"<code>Downloading Video . . .</code>" ,
36
- parse_mode = enums .ParseMode .HTML ,
37
34
)
38
35
file = await client .download_media (
39
36
message = replied ,
@@ -68,9 +65,8 @@ async def compress(client: Client, message: Message):
68
65
await edit_or_reply (
69
66
message ,
70
67
"<code>Trying to compress. . .</code>" ,
71
- parse_mode = enums .ParseMode .HTML ,
72
68
)
73
- # await message.edit("<code>If video size is big it'll take a while please be patient</code>", parse_mode=enums.ParseMode.HTML )
69
+ # await message.edit("<code>If video size is big it'll take a while please be patient</code>")
74
70
with open (progress , "w" ):
75
71
pass
76
72
proce = await asyncio .create_subprocess_shell (
@@ -94,8 +90,8 @@ async def compress(client: Client, message: Message):
94
90
speed = round (elapse / time_diff , 2 )
95
91
if int (speed ) != 0 :
96
92
some_eta = ((int (total_frames ) - elapse ) / speed ) * 1000
97
- text = f"` Compressing { file } at { crf } CRF.\n ` "
98
- progress_str = "` [{0}{1}] {2}%\n \n ` " .format (
93
+ text = f"<code> Compressing { file } at { crf } CRF.\n </code> "
94
+ progress_str = "<code> [{0}{1}] {2}%\n \n </code> " .format (
99
95
"" .join ("●" for _ in range (math .floor (per / 5 ))),
100
96
"" .join ("" for _ in range (20 - math .floor (per / 5 ))),
101
97
round (per , 2 ),
@@ -110,13 +106,12 @@ async def compress(client: Client, message: Message):
110
106
message ,
111
107
text
112
108
+ progress_str
113
- + "` "
109
+ + "<code> "
114
110
+ e_size
115
- + "` "
116
- + "\n \n ` "
111
+ + "</code> "
112
+ + "\n \n <code> "
117
113
+ eta
118
- + "`" ,
119
- parse_mode = enums .ParseMode .MARKDOWN ,
114
+ + "</code>" ,
120
115
)
121
116
except Exception as e :
122
117
await message .edit_text (format_exc (e ))
@@ -127,7 +122,6 @@ async def compress(client: Client, message: Message):
127
122
await edit_or_reply (
128
123
message ,
129
124
f"<code>Compressed { humanbytes (file_size )} to { humanbytes (out_file_size )} , Uploading Now . . .</code>" ,
130
- parse_mode = enums .ParseMode .HTML ,
131
125
)
132
126
# await message.delete()
133
127
differ = 100 - ((out_file_size / file_size ) * 100 )
@@ -138,25 +132,21 @@ async def compress(client: Client, message: Message):
138
132
progress_args = (ms_ , c_time , "`Uploading...`" ),
139
133
caption = f"<b>Original Size:</b> <code>{ humanbytes (file_size )} MB</code>\n <b>Compressed Size:</b> <code>{ humanbytes (out_file_size )} </code>\n <b>Compression Ratio:</b> <code>{ differ :.2f} %</code>\n <b>Time Taken To Compress:</b> <code>{ difff } </code>" ,
140
134
reply_to_message_id = message .id ,
141
- parse_mode = enums .ParseMode .HTML ,
142
135
)
143
136
except BaseException as e :
144
137
await edit_or_reply (
145
138
message ,
146
139
f"<b>INFO:</b> <code>{ e } </code>" ,
147
- parse_mode = enums .ParseMode .HTML ,
148
140
)
149
141
finally :
150
142
os .remove (file )
151
143
os .remove (out_file )
152
144
os .remove (progress )
153
145
else :
154
- await edit_or_reply (
155
- message , "<b>Please Reply To A Video</b>" , parse_mode = enums .ParseMode .HTML
156
- )
146
+ await edit_or_reply (message , "<b>Please Reply To A Video</b>" )
157
147
return
158
148
159
149
160
150
modules_help ["compress" ] = {
161
- "compress [crf value]" : f "reply to a video to compress it :)\n crf value is optional if not given default will be used"
151
+ "compress [crf value]" : "reply to a video to compress it :)\n crf value is optional if not given default will be used"
162
152
}
0 commit comments