Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b563af8
Start
Kannada-bot May 11, 2020
88f14b8
Start
Kannada-bot May 11, 2020
3d17966
START
Kannada-bot May 11, 2020
0f1a58f
Update youtube_dl_button.py
Kannada-bot May 16, 2020
d93cebf
Rename_file.py
Kannada-bot May 17, 2020
97e35c2
Start
Kannada-bot May 17, 2020
acb2589
Start
Kannada-bot May 17, 2020
c813da3
Create FFMpegRoBot.py
Kannada-bot May 18, 2020
0d1c07c
Create convert_to_audio.py
Kannada-bot May 18, 2020
6c003a5
Create convert_to_video.py
Kannada-bot May 18, 2020
0407779
Download_stickers.py
Kannada-bot May 18, 2020
1f58906
Generate screenshot.py
Kannada-bot May 18, 2020
f27c4b9
Create get_external_link.py
Kannada-bot May 18, 2020
cba411f
Start
Kannada-bot May 18, 2020
0f7218b
Update generate_screen_shot.py
Kannada-bot May 18, 2020
6a78879
translation.py
Kannada-bot May 18, 2020
7057fdb
Update translation.py
Kannada-bot May 18, 2020
f56b959
Update translation.py
Kannada-bot May 18, 2020
e6c447f
Update generate_screen_shot.py
Kannada-bot May 18, 2020
6b03a11
Update youtube_dl_button.py
Kannada-bot May 18, 2020
b72cbab
Create unzip.py
Kannada-bot May 21, 2020
827928f
Create extract_streams.py
Kannada-bot May 21, 2020
ff9ee57
Create _core.py
Kannada-bot May 21, 2020
77b1b11
Update translation.py
Kannada-bot May 21, 2020
fe51c65
Update translation.py
Kannada-bot May 21, 2020
be3ebaa
Delete _core.py
Kannada-bot May 23, 2020
2bc6da9
Delete extract_streams.py
Kannada-bot May 23, 2020
bdf641f
Delete unzip.py
Kannada-bot May 23, 2020
fc0dbec
Update translation.py
Kannada-bot May 29, 2020
05715b1
Update display_progress.py
Kannada-bot May 29, 2020
dbe2f27
Update display_progress.py
Kannada-bot Jun 2, 2020
bd1b4b2
Update translation.py
Kannada-bot Jun 2, 2020
0c55455
Update translation.py
Kannada-bot Jun 11, 2020
1ca4aa0
Update display_progress.py
Kannada-bot Jun 11, 2020
b391226
Update translation.py
SHER321 Jun 12, 2020
1dc1af2
Update README.md
SHER321 Jun 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## [AnyDLBot](https://telegram.dog/AnyDLBot) - Clone
---

https://heroku.com/deploy
An Open Source ALL-In-One Telegram RoBot, that can do lot of things.

**My Features**:
Expand Down
4 changes: 2 additions & 2 deletions helper_funcs/display_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ async def progress_for_pyrogram(
estimated_total_time = TimeFormatter(milliseconds=estimated_total_time)

progress = "[{0}{1}] \nP: {2}%\n".format(
''.join(["" for i in range(math.floor(percentage / 5))]),
''.join(["" for i in range(20 - math.floor(percentage / 5))]),
''.join(["" for i in range(math.floor(percentage / 5))]),
''.join(["" for i in range(20 - math.floor(percentage / 5))]),
round(percentage, 2))

tmp = progress + "{0} of {1}\nSpeed: {2}/s\nETA: {3}\n".format(
Expand Down
264 changes: 264 additions & 0 deletions plugins/FFMpegRoBot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K

# the logging things
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

import os
import time

# the secret configuration specific things
if bool(os.environ.get("WEBHOOK", False)):
from sample_config import Config
else:
from config import Config

# the Strings used for this "thing"
from translation import Translation

import pyrogram
logging.getLogger("pyrogram").setLevel(logging.WARNING)

from helper_funcs.chat_base import TRChatBase
from helper_funcs.display_progress import progress_for_pyrogram
from helper_funcs.help_Nekmo_ffmpeg import take_screen_shot, cult_small_video

from hachoir.metadata import extractMetadata
from hachoir.parser import createParser


@pyrogram.Client.on_message(pyrogram.Filters.command(["ffmpegrobot"]))
async def ffmpegrobot_ad(bot, update):
if update.from_user.id not in Config.AUTH_USERS:
await bot.delete_messages(
chat_id=update.chat.id,
message_ids=update.message_id,
revoke=True
)
return
TRChatBase(update.from_user.id, update.text, "ffmpegrobot")
await bot.send_message(
chat_id=update.chat.id,
text=Translation.FF_MPEG_RO_BOT_AD_VER_TISE_MENT,
disable_web_page_preview=True,
reply_to_message_id=update.message_id
)


@pyrogram.Client.on_message(pyrogram.Filters.command(["trim"]))
async def trim(bot, update):
if update.from_user.id not in Config.AUTH_USERS:
await bot.delete_messages(
chat_id=update.chat.id,
message_ids=update.message_id,
revoke=True
)
return
TRChatBase(update.from_user.id, update.text, "trim")
saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
if os.path.exists(saved_file_path):
a = await bot.send_message(
chat_id=update.chat.id,
text=Translation.DOWNLOAD_START,
reply_to_message_id=update.message_id
)
commands = update.command
if len(commands) == 3:
# output should be video
cmd, start_time, end_time = commands
o = await cult_small_video(saved_file_path, Config.DOWNLOAD_LOCATION, start_time, end_time)
logger.info(o)
if o is not None:
await bot.edit_message_text(
chat_id=update.chat.id,
text=Translation.UPLOAD_START,
message_id=a.message_id
)
c_time = time.time()
await bot.send_video(
chat_id=update.chat.id,
video=o,
# caption=description,
# duration=duration,
# width=width,
# height=height,
supports_streaming=True,
# reply_markup=reply_markup,
# thumb=thumb_image_path,
reply_to_message_id=update.message_id,
progress=progress_for_pyrogram,
progress_args=(
Translation.UPLOAD_START,
a,
c_time
)
)
os.remove(o)
await bot.edit_message_text(
chat_id=update.chat.id,
text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
disable_web_page_preview=True,
message_id=a.message_id
)
elif len(commands) == 2:
# output should be screenshot
cmd, start_time = commands
o = await take_screen_shot(saved_file_path, Config.DOWNLOAD_LOCATION, start_time)
logger.info(o)
if o is not None:
await bot.edit_message_text(
chat_id=update.chat.id,
text=Translation.UPLOAD_START,
message_id=a.message_id
)
c_time = time.time()
await bot.send_document(
chat_id=update.chat.id,
document=o,
# thumb=thumb_image_path,
# caption=description,
# reply_markup=reply_markup,
reply_to_message_id=update.message_id,
progress=progress_for_pyrogram,
progress_args=(
Translation.UPLOAD_START,
a,
c_time
)
)
c_time = time.time()
await bot.send_photo(
chat_id=update.chat.id,
photo=o,
# caption=Translation.CUSTOM_CAPTION_UL_FILE,
reply_to_message_id=update.message_id,
progress=progress_for_pyrogram,
progress_args=(
Translation.UPLOAD_START,
a,
c_time
)
)
os.remove(o)
await bot.edit_message_text(
chat_id=update.chat.id,
text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
disable_web_page_preview=True,
message_id=a.message_id
)
else:
await bot.edit_message_text(
chat_id=update.chat.id,
text=Translation.FF_MPEG_RO_BOT_RE_SURRECT_ED,
message_id=a.message_id
)
else:
# reply help message
await bot.send_message(
chat_id=update.chat.id,
text=Translation.FF_MPEG_RO_BOT_STEP_TWO_TO_ONE,
reply_to_message_id=update.message_id
)


@pyrogram.Client.on_message(pyrogram.Filters.command(["storageinfo"]))
async def storage_info(bot, update):
if update.from_user.id not in Config.AUTH_USERS:
await bot.delete_messages(
chat_id=update.chat.id,
message_ids=update.message_id,
revoke=True
)
return
TRChatBase(update.from_user.id, update.text, "storageinfo")
saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
if os.path.exists(saved_file_path):
metadata = extractMetadata(createParser(saved_file_path))
duration = None
if metadata.has("duration"):
duration = metadata.get('duration')
await bot.send_message(
chat_id=update.chat.id,
text=Translation.FF_MPEG_RO_BOT_STOR_AGE_INFO.format(duration),
reply_to_message_id=update.message_id
)
else:
# reply help message
await bot.send_message(
chat_id=update.chat.id,
text=Translation.FF_MPEG_RO_BOT_STEP_TWO_TO_ONE,
reply_to_message_id=update.message_id
)


@pyrogram.Client.on_message(pyrogram.Filters.command(["clearffmpegmedia"]))
async def clear_media(bot, update):
if update.from_user.id not in Config.AUTH_USERS:
await bot.delete_messages(
chat_id=update.chat.id,
message_ids=update.message_id,
revoke=True
)
return
TRChatBase(update.from_user.id, update.text, "clearffmpegmedia")
saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
if os.path.exists(saved_file_path):
os.remove(saved_file_path)
await bot.send_message(
chat_id=update.chat.id,
text=Translation.FF_MPEG_DEL_ETED_CUSTOM_MEDIA,
reply_to_message_id=update.message_id
)


@pyrogram.Client.on_message(pyrogram.Filters.command(["downloadmedia"]))
async def download_media(bot, update):
if update.from_user.id not in Config.AUTH_USERS:
await bot.delete_messages(
chat_id=update.chat.id,
message_ids=update.message_id,
revoke=True
)
return
TRChatBase(update.from_user.id, update.text, "downloadmedia")
saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
if not os.path.exists(saved_file_path):
a = await bot.send_message(
chat_id=update.chat.id,
text=Translation.DOWNLOAD_START,
reply_to_message_id=update.message_id
)
try:
c_time = time.time()
await bot.download_media(
message=update.reply_to_message,
file_name=saved_file_path,
progress=progress_for_pyrogram,
progress_args=(
Translation.DOWNLOAD_START,
a,
c_time
)
)
except (ValueError) as e:
await bot.edit_message_text(
chat_id=update.chat.id,
text=str(e),
message_id=a.message_id
)
else:
await bot.edit_message_text(
chat_id=update.chat.id,
text=Translation.SAVED_RECVD_DOC_FILE,
message_id=a.message_id
)
else:
await bot.send_message(
chat_id=update.chat.id,
text=Translation.FF_MPEG_RO_BOT_STOR_AGE_ALREADY_EXISTS,
reply_to_message_id=update.message_id
)
Loading