-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathutils.py
51 lines (40 loc) · 1.97 KB
/
utils.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
# VideoEncoder - a telegram bot for compressing/encoding videos in h264 format.
# Copyright (c) 2021 WeebTime/VideoEncoder
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import asyncio
import mimetypes
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
output = InlineKeyboardMarkup([
[InlineKeyboardButton("Developer", url="https://github.com/WeebTime/"),
InlineKeyboardButton("Source", url="https://github.com/WeebTime/Video-Encoder-Bot")]
])
start = InlineKeyboardMarkup([
[InlineKeyboardButton("Developer", url="https://github.com/WeebTime/"),
InlineKeyboardButton("Source", url="https://github.com/WeebTime/Video-Encoder-Bot")],
[InlineKeyboardButton("Support", url="https://t.me/joinchat/4PQUG5J6aRI3NGQ1"),
InlineKeyboardButton("Channel", url="https://t.me/WeebZoneIndia")]
])
async def get_file_mimetype(filename):
mimetype = mimetypes.guess_type(filename)[0]
if not mimetype:
proc = await asyncio.create_subprocess_exec('file', '--brief', '--mime-type', filename, stdout=asyncio.subprocess.PIPE)
stdout, _ = await proc.communicate()
mimetype = stdout.decode().strip()
return mimetype or ''
video_duration_cache = {}
video_duration_lock = asyncio.Lock()
async def convert_to_jpg(original, end):
proc = await asyncio.create_subprocess_exec('ffmpeg', '-y', '-i', original, end)
await proc.communicate()