diff --git a/LICENSE b/LICENSE
index f814055f..9a593180 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2022 Hash Minner
+Copyright (c) 2022 @kalanakt | www.netronk.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Uploader/button.py b/Uploader/button.py
index 9f42d16f..296c38f9 100644
--- a/Uploader/button.py
+++ b/Uploader/button.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
import json
import time
@@ -33,14 +11,16 @@
from Uploader.functions.ran_text import random_char
from Uploader.functions.display_progress import progress_for_pyrogram, humanbytes
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
@@ -50,17 +30,21 @@ async def youtube_dl_call_back(bot, update):
tg_send_type, youtube_dl_format, youtube_dl_ext, ranom = cb_data.split("|")
print(cb_data)
random1 = random_char(5)
- save_ytdl_json_path = Config.DOWNLOAD_LOCATION + \
- "/" + str(update.from_user.id) + f'{ranom}' + ".json"
+ save_ytdl_json_path = (
+ Config.DOWNLOAD_LOCATION + "/" +
+ str(update.from_user.id) + f"{ranom}" + ".json"
+ )
try:
with open(save_ytdl_json_path, "r", encoding="utf8") as f:
response_json = json.load(f)
- except (FileNotFoundError) as e:
+ except FileNotFoundError as e:
await update.message.delete()
return False
youtube_dl_url = update.message.reply_to_message.text
- custom_file_name = str(response_json.get("title")) + \
- "_" + youtube_dl_format + "." + youtube_dl_ext
+ custom_file_name = (
+ str(response_json.get("title")) + "_" +
+ youtube_dl_format + "." + youtube_dl_ext
+ )
youtube_dl_username = None
youtube_dl_password = None
if "|" in youtube_dl_url:
@@ -80,7 +64,7 @@ async def youtube_dl_call_back(bot, update):
elif entity.type == "url":
o = entity.offset
l = entity.length
- youtube_dl_url = youtube_dl_url[o:o + l]
+ youtube_dl_url = youtube_dl_url[o: o + l]
if youtube_dl_url is not None:
youtube_dl_url = youtube_dl_url.strip()
if custom_file_name is not None:
@@ -99,17 +83,18 @@ async def youtube_dl_call_back(bot, update):
elif entity.type == "url":
o = entity.offset
l = entity.length
- youtube_dl_url = youtube_dl_url[o:o + l]
+ youtube_dl_url = youtube_dl_url[o: o + l]
await update.message.edit_caption(
caption=Translation.DOWNLOAD_START.format(custom_file_name)
-
)
description = Translation.CUSTOM_CAPTION_UL_FILE
if "fulltitle" in response_json:
description = response_json["fulltitle"][:1021]
# escape Markdown and special characters
- tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + \
- "/" + str(update.from_user.id) + f'{random1}'
+ tmp_directory_for_each_user = (
+ Config.DOWNLOAD_LOCATION + "/" +
+ str(update.from_user.id) + f"{random1}"
+ )
if not os.path.isdir(tmp_directory_for_each_user):
os.makedirs(tmp_directory_for_each_user)
download_directory = f"{tmp_directory_for_each_user}/{custom_file_name}"
@@ -119,13 +104,17 @@ async def youtube_dl_call_back(bot, update):
command_to_exec = [
"yt-dlp",
"-c",
- "--max-filesize", str(Config.TG_MAX_FILE_SIZE),
+ "--max-filesize",
+ str(Config.TG_MAX_FILE_SIZE),
"--bidi-workaround",
"--extract-audio",
- "--audio-format", youtube_dl_ext,
- "--audio-quality", youtube_dl_format,
+ "--audio-format",
+ youtube_dl_ext,
+ "--audio-quality",
+ youtube_dl_format,
youtube_dl_url,
- "-o", download_directory
+ "-o",
+ download_directory,
]
else:
# command_to_exec = ["yt-dlp", "-f", youtube_dl_format, "--hls-prefer-ffmpeg", "--recode-video", "mp4", "-k", youtube_dl_url, "-o", download_directory]
@@ -135,12 +124,15 @@ async def youtube_dl_call_back(bot, update):
command_to_exec = [
"yt-dlp",
"-c",
- "--max-filesize", str(Config.TG_MAX_FILE_SIZE),
+ "--max-filesize",
+ str(Config.TG_MAX_FILE_SIZE),
"--embed-subs",
- "-f", minus_f_format,
+ "-f",
+ minus_f_format,
"--bidi-workaround",
youtube_dl_url,
- "-o", download_directory
+ "-o",
+ download_directory,
]
if Config.HTTP_PROXY != "":
@@ -171,10 +163,7 @@ async def youtube_dl_call_back(bot, update):
ad_string_to_replace = "please report this issue on https://github.com/kalanakt/All-Url-Uploader/issues"
if e_response and ad_string_to_replace in e_response:
error_message = e_response.replace(ad_string_to_replace, "")
- await update.message.edit_caption(
-
- text=error_message
- )
+ await update.message.edit_caption(text=error_message)
return False
if t_response:
@@ -199,17 +188,15 @@ async def youtube_dl_call_back(bot, update):
thumb = download_location if os.path.isfile(
download_location) else None
- if ((file_size > Config.TG_MAX_FILE_SIZE)):
+ if file_size > Config.TG_MAX_FILE_SIZE:
await update.message.edit_caption(
-
caption=Translation.RCHD_TG_API_LIMIT.format(
- time_taken_for_download, humanbytes(file_size))
-
+ time_taken_for_download, humanbytes(file_size)
+ )
)
else:
await update.message.edit_caption(
caption=Translation.UPLOAD_START.format(custom_file_name)
-
)
start_time = time.time()
if tg_send_type == "video":
@@ -228,8 +215,8 @@ async def youtube_dl_call_back(bot, update):
progress_args=(
Translation.UPLOAD_START,
update.message,
- start_time
- )
+ start_time,
+ ),
)
elif tg_send_type == "audio":
duration = await Mdata03(download_directory)
@@ -244,8 +231,8 @@ async def youtube_dl_call_back(bot, update):
progress_args=(
Translation.UPLOAD_START,
update.message,
- start_time
- )
+ start_time,
+ ),
)
elif tg_send_type == "vm":
width, duration = await Mdata02(download_directory)
@@ -260,8 +247,8 @@ async def youtube_dl_call_back(bot, update):
progress_args=(
Translation.UPLOAD_START,
update.message,
- start_time
- )
+ start_time,
+ ),
)
else:
await update.message.reply_document(
@@ -275,8 +262,8 @@ async def youtube_dl_call_back(bot, update):
progress_args=(
Translation.UPLOAD_START,
update.message,
- start_time
- )
+ start_time,
+ ),
)
end_two = datetime.now()
@@ -287,8 +274,8 @@ async def youtube_dl_call_back(bot, update):
pass
await update.message.edit_caption(
caption=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS.format(
- time_taken_for_download, time_taken_for_upload)
-
+ time_taken_for_download, time_taken_for_upload
+ )
)
logger.info(f"Downloaded in: {str(time_taken_for_download)}")
diff --git a/Uploader/callbacks.py b/Uploader/callbacks.py
index c8d2a651..f1dcd431 100644
--- a/Uploader/callbacks.py
+++ b/Uploader/callbacks.py
@@ -1,32 +1,12 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
from Uploader.dl_button import ddl_call_back
from Uploader.button import youtube_dl_call_back
from Uploader.script import Translation
from pyrogram import Client
import logging
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
diff --git a/Uploader/commands.py b/Uploader/commands.py
index 89990409..74d119ae 100644
--- a/Uploader/commands.py
+++ b/Uploader/commands.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
from pyrogram import Client, filters
from pyrogram.types import Message
from Uploader.script import Translation
diff --git a/Uploader/dl_button.py b/Uploader/dl_button.py
index 003ee121..3ddc65f0 100644
--- a/Uploader/dl_button.py
+++ b/Uploader/dl_button.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
import time
import aiohttp
@@ -27,13 +5,18 @@
from datetime import datetime
-from Uploader.functions.display_progress import progress_for_pyrogram, humanbytes, TimeFormatter
+from Uploader.functions.display_progress import (
+ progress_for_pyrogram,
+ humanbytes,
+ TimeFormatter,
+)
from Uploader.utitles import *
from Uploader.script import Translation
from config import Config
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
@@ -55,7 +38,7 @@ async def ddl_call_back(bot, update): # sourcery skip: low-code-quality
elif entity.type == "url":
o = entity.offset
l = entity.length
- youtube_dl_url = youtube_dl_url[o:o + l]
+ youtube_dl_url = youtube_dl_url[o: o + l]
if youtube_dl_url is not None:
youtube_dl_url = youtube_dl_url.strip()
if custom_file_name is not None:
@@ -67,16 +50,22 @@ async def ddl_call_back(bot, update): # sourcery skip: low-code-quality
elif entity.type == "url":
o = entity.offset
l = entity.length
- youtube_dl_url = youtube_dl_url[o:o + l]
+ youtube_dl_url = youtube_dl_url[o: o + l]
description = custom_file_name
if f".{youtube_dl_ext}" not in custom_file_name:
- custom_file_name += f'.{youtube_dl_ext}'
+ custom_file_name += f".{youtube_dl_ext}"
logger.info(youtube_dl_url)
logger.info(custom_file_name)
start = datetime.now()
- await bot.edit_message_text(text=Translation.DOWNLOAD_START.format(custom_file_name), chat_id=update.message.chat.id, message_id=update.message.id)
+ await bot.edit_message_text(
+ text=Translation.DOWNLOAD_START.format(custom_file_name),
+ chat_id=update.message.chat.id,
+ message_id=update.message.id,
+ )
- tmp_directory_for_each_user = f"{Config.DOWNLOAD_LOCATION}/{str(update.from_user.id)}"
+ tmp_directory_for_each_user = (
+ f"{Config.DOWNLOAD_LOCATION}/{str(update.from_user.id)}"
+ )
if not os.path.isdir(tmp_directory_for_each_user):
os.makedirs(tmp_directory_for_each_user)
@@ -85,14 +74,28 @@ async def ddl_call_back(bot, update): # sourcery skip: low-code-quality
async with aiohttp.ClientSession() as session:
c_time = time.time()
try:
- await download_coroutine(bot, session, youtube_dl_url, download_directory, update.message.chat.id, update.message.id, c_time)
+ await download_coroutine(
+ bot,
+ session,
+ youtube_dl_url,
+ download_directory,
+ update.message.chat.id,
+ update.message.id,
+ c_time,
+ )
except asyncio.TimeoutError:
- await bot.edit_message_text(text=Translation.SLOW_URL_DECED, chat_id=update.message.chat.id, message_id=update.message.id)
+ await bot.edit_message_text(
+ text=Translation.SLOW_URL_DECED,
+ chat_id=update.message.chat.id,
+ message_id=update.message.id,
+ )
return False
if os.path.exists(download_directory):
- save_ytdl_json_path = f"{Config.DOWNLOAD_LOCATION}/{str(update.message.chat.id)}.json"
+ save_ytdl_json_path = (
+ f"{Config.DOWNLOAD_LOCATION}/{str(update.message.chat.id)}.json"
+ )
download_location = f"{Config.DOWNLOAD_LOCATION}/{update.from_user.id}.jpg"
thumb = download_location if os.path.isfile(
download_location) else None
@@ -100,7 +103,11 @@ async def ddl_call_back(bot, update): # sourcery skip: low-code-quality
if os.path.exists(save_ytdl_json_path):
os.remove(save_ytdl_json_path)
end_one = datetime.now()
- await bot.edit_message_text(text=Translation.UPLOAD_START, chat_id=update.message.chat.id, message_id=update.message.id)
+ await bot.edit_message_text(
+ text=Translation.UPLOAD_START,
+ chat_id=update.message.chat.id,
+ message_id=update.message.id,
+ )
file_size = Config.TG_MAX_FILE_SIZE + 1
try:
@@ -109,24 +116,82 @@ async def ddl_call_back(bot, update): # sourcery skip: low-code-quality
download_directory = f"{os.path.splitext(download_directory)[0]}.mkv"
file_size = os.stat(download_directory).st_size
if file_size > Config.TG_MAX_FILE_SIZE:
- await bot.edit_message_text(chat_id=update.message.chat.id, text=Translation.RCHD_TG_API_LIMIT, message_id=update.message.id)
+ await bot.edit_message_text(
+ chat_id=update.message.chat.id,
+ text=Translation.RCHD_TG_API_LIMIT,
+ message_id=update.message.id,
+ )
else:
start_time = time.time()
if tg_send_type == "video":
width, height, duration = await Mdata01(download_directory)
- await bot.send_video(chat_id=update.message.chat.id, video=download_directory, thumb=thumb, caption=description, duration=duration, width=width, height=height, supports_streaming=True, reply_to_message_id=update.message.reply_to_message.id, progress=progress_for_pyrogram, progress_args=(Translation.UPLOAD_START, update.message, start_time))
+ await bot.send_video(
+ chat_id=update.message.chat.id,
+ video=download_directory,
+ thumb=thumb,
+ caption=description,
+ duration=duration,
+ width=width,
+ height=height,
+ supports_streaming=True,
+ reply_to_message_id=update.message.reply_to_message.id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ update.message,
+ start_time,
+ ),
+ )
elif tg_send_type == "audio":
duration = await Mdata03(download_directory)
- await bot.send_audio(chat_id=update.message.chat.id, audio=download_directory, thumb=thumb, caption=description, duration=duration, reply_to_message_id=update.message.reply_to_message.id, progress=progress_for_pyrogram, progress_args=(Translation.UPLOAD_START, update.message, start_time))
+ await bot.send_audio(
+ chat_id=update.message.chat.id,
+ audio=download_directory,
+ thumb=thumb,
+ caption=description,
+ duration=duration,
+ reply_to_message_id=update.message.reply_to_message.id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ update.message,
+ start_time,
+ ),
+ )
elif tg_send_type == "vm":
width, duration = await Mdata02(download_directory)
- await bot.send_video_note(chat_id=update.message.chat.id, video_note=download_directory, thumb=thumb, duration=duration, length=width, reply_to_message_id=update.message.reply_to_message.id, progress=progress_for_pyrogram, progress_args=(Translation.UPLOAD_START, update.message, start_time))
+ await bot.send_video_note(
+ chat_id=update.message.chat.id,
+ video_note=download_directory,
+ thumb=thumb,
+ duration=duration,
+ length=width,
+ reply_to_message_id=update.message.reply_to_message.id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ update.message,
+ start_time,
+ ),
+ )
else:
- await bot.send_document(chat_id=update.message.chat.id, document=download_directory, thumb=thumb, caption=description, reply_to_message_id=update.message.reply_to_message.id, progress=progress_for_pyrogram, progress_args=(Translation.UPLOAD_START, update.message, start_time))
+ await bot.send_document(
+ chat_id=update.message.chat.id,
+ document=download_directory,
+ thumb=thumb,
+ caption=description,
+ reply_to_message_id=update.message.reply_to_message.id,
+ progress=progress_for_pyrogram,
+ progress_args=(
+ Translation.UPLOAD_START,
+ update.message,
+ start_time,
+ ),
+ )
end_two = datetime.now()
try:
@@ -135,12 +200,24 @@ async def ddl_call_back(bot, update): # sourcery skip: low-code-quality
pass
time_taken_for_download = (end_one - start).seconds
time_taken_for_upload = (end_two - end_one).seconds
- await bot.edit_message_text(text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS.format(time_taken_for_download, time_taken_for_upload), chat_id=update.message.chat.id, message_id=update.message.id, disable_web_page_preview=True)
+ await bot.edit_message_text(
+ text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS.format(
+ time_taken_for_download, time_taken_for_upload
+ ),
+ chat_id=update.message.chat.id,
+ message_id=update.message.id,
+ disable_web_page_preview=True,
+ )
logger.info(f"Downloaded in: {str(time_taken_for_download)}")
logger.info(f"Uploaded in: {str(time_taken_for_upload)}")
else:
- await bot.edit_message_text(text=Translation.NO_VOID_FORMAT_FOUND.format("Incorrect Link"), chat_id=update.message.chat.id, message_id=update.message.id, disable_web_page_preview=True)
+ await bot.edit_message_text(
+ text=Translation.NO_VOID_FORMAT_FOUND.format("Incorrect Link"),
+ chat_id=update.message.chat.id,
+ message_id=update.message.id,
+ disable_web_page_preview=True,
+ )
async def download_coroutine(bot, session, url, file_name, chat_id, message_id, start):
@@ -165,17 +242,25 @@ async def download_coroutine(bot, session, url, file_name, chat_id, message_id,
speed = downloaded / diff
elapsed_time = round(diff) * 1000
time_to_completion = (
- round((total_length - downloaded) / speed) * 1000)
+ round((total_length - downloaded) / speed) * 1000
+ )
estimated_total_time = elapsed_time + time_to_completion
try:
current_message = """**Download Status**
URL: {}
File Size: {}
Downloaded: {}
-ETA: {}""".format(url, humanbytes(total_length), humanbytes(downloaded), TimeFormatter(estimated_total_time))
+ETA: {}""".format(
+ url,
+ humanbytes(total_length),
+ humanbytes(downloaded),
+ TimeFormatter(estimated_total_time),
+ )
if current_message != display_message:
- await bot.edit_message_text(chat_id, message_id, text=current_message)
+ await bot.edit_message_text(
+ chat_id, message_id, text=current_message
+ )
display_message = current_message
except Exception as e:
logger.info(str(e))
diff --git a/Uploader/echo.py b/Uploader/echo.py
index e3e8d505..819f62b2 100644
--- a/Uploader/echo.py
+++ b/Uploader/echo.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import time
import json
import asyncio
@@ -34,8 +12,9 @@
from Uploader.functions.ran_text import random_char
from Uploader.functions.display_progress import humanbytes
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
@@ -57,11 +36,11 @@ async def echo(bot, update):
InlineKeyboardButton(
"Audio 🎵", callback_data="ytdl_audio"),
InlineKeyboardButton(
- "Video 🎬", callback_data="ytdl_video")
+ "Video 🎬", callback_data="ytdl_video"),
]
]
),
- quote=True
+ quote=True,
)
if "|" in url:
@@ -80,8 +59,8 @@ async def echo(bot, update):
url = entity.url
elif entity.type == "url":
o = entity.offset
- l = entity.length
- url = url[o:o + l]
+ length = entity.length
+ url = url[o: o + length]
if url is not None:
url = url.strip()
if file_name is not None:
@@ -99,8 +78,8 @@ async def echo(bot, update):
url = entity.url
elif entity.type == "url":
o = entity.offset
- l = entity.length
- url = url[o:o + l]
+ length = entity.length
+ url = url[o: o + length]
if Config.HTTP_PROXY != "":
command_to_exec = [
"yt-dlp",
@@ -108,16 +87,12 @@ async def echo(bot, update):
"--allow-dynamic-mpd",
"-j",
url,
- "--proxy", Config.HTTP_PROXY
+ "--proxy",
+ Config.HTTP_PROXY,
]
else:
- command_to_exec = [
- "yt-dlp",
- "--no-warnings",
- "--allow-dynamic-mpd",
- "-j",
- url
- ]
+ command_to_exec = ["yt-dlp", "--no-warnings",
+ "--allow-dynamic-mpd", "-j", url]
if youtube_dl_username is not None:
command_to_exec.append("--username")
command_to_exec.append(youtube_dl_username)
@@ -127,22 +102,29 @@ async def echo(bot, update):
logger.info(command_to_exec)
chk = await bot.send_message(
chat_id=update.chat.id,
- text='Proccesing your ⌛',
+ text="Proccesing your ⌛",
disable_web_page_preview=True,
- reply_to_message_id=update.id
-
+ reply_to_message_id=update.id,
)
if update.from_user.id not in Config.AUTH_USERS:
if str(update.from_user.id) in Config.ADL_BOT_RQ:
current_time = time.time()
previous_time = Config.ADL_BOT_RQ[str(update.from_user.id)]
- process_max_timeout = round(Config.PROCESS_MAX_TIMEOUT/60)
- present_time = round(Config.PROCESS_MAX_TIMEOUT -
- (current_time - previous_time))
+ process_max_timeout = round(Config.PROCESS_MAX_TIMEOUT / 60)
+ present_time = round(
+ Config.PROCESS_MAX_TIMEOUT(current_time - previous_time)
+ )
Config.ADL_BOT_RQ[str(update.from_user.id)] = time.time()
if round(current_time - previous_time) < Config.PROCESS_MAX_TIMEOUT:
- await bot.edit_message_text(chat_id=update.chat.id, text=Translation.FREE_USER_LIMIT_Q_SZE.format(process_max_timeout, present_time), disable_web_page_preview=True, message_id=chk.id)
+ await bot.edit_message_text(
+ chat_id=update.chat.id,
+ text=Translation.FREE_USER_LIMIT_Q_SZE.format(
+ process_max_timeout, present_time
+ ),
+ disable_web_page_preview=True,
+ message_id=chk.id,
+ )
return
else:
Config.ADL_BOT_RQ[str(update.from_user.id)] = time.time()
@@ -163,7 +145,12 @@ async def echo(bot, update):
if e_response and "nonnumeric port" not in e_response:
# logger.warn("Status : FAIL", exc.returncode, exc.output)
error_message = e_response.replace(
- "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.", "")
+ """
+ please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version;
+ see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
+ """,
+ "",
+ )
if "This video is only available for registered users." in error_message:
error_message += Translation.SET_CUSTOM_USERNAME_PASSWORD
await chk.delete()
@@ -173,8 +160,7 @@ async def echo(bot, update):
chat_id=update.chat.id,
text=Translation.NO_VOID_FORMAT_FOUND.format(str(error_message)),
reply_to_message_id=update.id,
-
- disable_web_page_preview=True
+ disable_web_page_preview=True,
)
return False
if t_response:
@@ -184,8 +170,13 @@ async def echo(bot, update):
x_reponse, _ = x_reponse.split("\n")
response_json = json.loads(x_reponse)
randem = random_char(5)
- save_ytdl_json_path = Config.DOWNLOAD_LOCATION + \
- "/" + str(update.from_user.id) + f'{randem}' + ".json"
+ save_ytdl_json_path = (
+ Config.DOWNLOAD_LOCATION
+ + "/"
+ + str(update.from_user.id)
+ + f"{randem}"
+ + ".json"
+ )
with open(save_ytdl_json_path, "w", encoding="utf8") as outfile:
json.dump(response_json, outfile, ensure_ascii=False)
# logger.info(response_json)
@@ -204,33 +195,38 @@ async def echo(bot, update):
format_ext = formats.get("ext")
- if formats.get('filesize'):
- size = formats['filesize']
- elif formats.get('filesize_approx'):
- size = formats['filesize_approx']
+ if formats.get("filesize"):
+ size = formats["filesize"]
+ elif formats.get("filesize_approx"):
+ size = formats["filesize_approx"]
else:
size = 0
cb_string_video = "{}|{}|{}|{}".format(
- "video", format_id, format_ext, randem)
+ "video", format_id, format_ext, randem
+ )
cb_string_file = "{}|{}|{}|{}".format(
- "file", format_id, format_ext, randem)
- if format_string is not None and not "audio only" in format_string:
+ "file", format_id, format_ext, randem
+ )
+ if format_string is not None and not ("audio only" in format_string):
ikeyboard = [
InlineKeyboardButton(
- "🎬 " + format_string + " " + format_ext +
- " " + humanbytes(size) + " ",
- callback_data=(cb_string_video).encode("UTF-8")
+ "🎬 "
+ + format_string
+ + " "
+ + format_ext
+ + " "
+ + humanbytes(size)
+ + " ",
+ callback_data=(cb_string_video).encode("UTF-8"),
)
]
else:
# special weird case :\
ikeyboard = [
InlineKeyboardButton(
- "🎬 [" +
- "] ( " +
- humanbytes(size) + " )",
- callback_data=(cb_string_video).encode("UTF-8")
+ "🎬 [" + "] ( " + humanbytes(size) + " )",
+ callback_data=(cb_string_video).encode("UTF-8"),
)
]
inline_keyboard.append(ikeyboard)
@@ -241,67 +237,76 @@ async def echo(bot, update):
"audio", "128k", "mp3", randem)
cb_string = "{}|{}|{}|{}".format(
"audio", "320k", "mp3", randem)
- inline_keyboard.append([
- InlineKeyboardButton(
- "🎼 ᴍᴘ𝟹 " + "(" + "64 ᴋʙᴘs" + ")", callback_data=cb_string_64.encode("UTF-8")),
- InlineKeyboardButton(
- "🎼 ᴍᴘ𝟹 " + "(" + "128 ᴋʙᴘs" + ")", callback_data=cb_string_128.encode("UTF-8"))
- ])
- inline_keyboard.append([
- InlineKeyboardButton(
- "🎼 ᴍᴘ𝟹 " + "(" + "320 ᴋʙᴘs" + ")", callback_data=cb_string.encode("UTF-8"))
- ])
- inline_keyboard.append([
- InlineKeyboardButton(
- "⛔ ᴄʟᴏsᴇ", callback_data='close')
- ])
+ inline_keyboard.append(
+ [
+ InlineKeyboardButton(
+ "🎼 ᴍᴘ𝟹 " + "(" + "64 ᴋʙᴘs" + ")",
+ callback_data=cb_string_64.encode("UTF-8"),
+ ),
+ InlineKeyboardButton(
+ "🎼 ᴍᴘ𝟹 " + "(" + "128 ᴋʙᴘs" + ")",
+ callback_data=cb_string_128.encode("UTF-8"),
+ ),
+ ]
+ )
+ inline_keyboard.append(
+ [
+ InlineKeyboardButton(
+ "🎼 ᴍᴘ𝟹 " + "(" + "320 ᴋʙᴘs" + ")",
+ callback_data=cb_string.encode("UTF-8"),
+ )
+ ]
+ )
+ inline_keyboard.append(
+ [InlineKeyboardButton("⛔ ᴄʟᴏsᴇ", callback_data="close")]
+ )
else:
format_id = response_json["format_id"]
format_ext = response_json["ext"]
cb_string_file = "{}|{}|{}|{}".format(
"file", format_id, format_ext, randem)
cb_string_video = "{}|{}|{}|{}".format(
- "video", format_id, format_ext, randem)
- inline_keyboard.append([
- InlineKeyboardButton(
- "🎬 Video",
- callback_data=(cb_string_video).encode("UTF-8")
- )
- ])
- cb_string_file = "{}={}={}".format(
- "file", format_id, format_ext)
- cb_string_video = "{}={}={}".format(
- "video", format_id, format_ext)
- inline_keyboard.append([
- InlineKeyboardButton(
- "📁 Document",
- callback_data=(cb_string_file).encode("UTF-8")
- )
- ])
+ "video", format_id, format_ext, randem
+ )
+ inline_keyboard.append(
+ [
+ InlineKeyboardButton(
+ "🎬 Video", callback_data=(cb_string_video).encode("UTF-8")
+ )
+ ]
+ )
+ cb_string_file = "{}={}={}".format("file", format_id, format_ext)
+ cb_string_video = "{}={}={}".format("video", format_id, format_ext)
+ inline_keyboard.append(
+ [
+ InlineKeyboardButton(
+ "📁 Document", callback_data=(cb_string_file).encode("UTF-8")
+ )
+ ]
+ )
reply_markup = InlineKeyboardMarkup(inline_keyboard)
await chk.delete()
await bot.send_message(
chat_id=update.chat.id,
- text=Translation.FORMAT_SELECTION.format(
- Thumbnail) + "\n" + Translation.SET_CUSTOM_USERNAME_PASSWORD,
+ text=Translation.FORMAT_SELECTION.format(Thumbnail)
+ + "\n"
+ + Translation.SET_CUSTOM_USERNAME_PASSWORD,
reply_markup=reply_markup,
-
- reply_to_message_id=update.id
+ reply_to_message_id=update.id,
)
else:
# fallback for nonnumeric port a.k.a seedbox.io
inline_keyboard = []
- cb_string_file = "{}={}={}".format(
- "file", "LFO", "NONE")
- cb_string_video = "{}={}={}".format(
- "video", "OFL", "ENON")
- inline_keyboard.append([
- InlineKeyboardButton(
- "🎬 ᴍᴇᴅɪᴀ",
- callback_data=(cb_string_video).encode("UTF-8")
- )
- ])
+ cb_string_file = "{}={}={}".format("file", "LFO", "NONE")
+ cb_string_video = "{}={}={}".format("video", "OFL", "ENON")
+ inline_keyboard.append(
+ [
+ InlineKeyboardButton(
+ "🎬 ᴍᴇᴅɪᴀ", callback_data=(cb_string_video).encode("UTF-8")
+ )
+ ]
+ )
reply_markup = InlineKeyboardMarkup(inline_keyboard)
await chk.delete(True)
@@ -309,6 +314,5 @@ async def echo(bot, update):
chat_id=update.chat.id,
text=Translation.FORMAT_SELECTION,
reply_markup=reply_markup,
-
- reply_to_message_id=update.id
+ reply_to_message_id=update.id,
)
diff --git a/Uploader/functions/__init__.py b/Uploader/functions/__init__.py
index 0a6a3a2c..8cca62e5 100644
--- a/Uploader/functions/__init__.py
+++ b/Uploader/functions/__init__.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
from .display_progress import *
from .help_Nekmo_ffmpeg import *
from .help_uploadbot import *
diff --git a/Uploader/functions/display_progress.py b/Uploader/functions/display_progress.py
index 8b035762..be63375e 100644
--- a/Uploader/functions/display_progress.py
+++ b/Uploader/functions/display_progress.py
@@ -1,42 +1,15 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import math
import time
import logging
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
-async def progress_for_pyrogram(
- current,
- total,
- ud_type,
- message,
- start
-):
+async def progress_for_pyrogram(current, total, ud_type, message, start):
now = time.time()
diff = now - start
if round(diff % 10.00) == 0 or current == total:
@@ -51,8 +24,8 @@ async def progress_for_pyrogram(
estimated_total_time = TimeFormatter(milliseconds=estimated_total_time)
progress = "[{0}{1}] \nP: {2}%\n".format(
- ''.join(["◾" for _ in range(math.floor(percentage / 5))]),
- ''.join(["◽" for _ in range(20 - math.floor(percentage / 5))]),
+ "".join(["◾" for _ in range(math.floor(percentage / 5))]),
+ "".join(["◽" for _ in range(20 - math.floor(percentage / 5))]),
round(percentage, 2),
)
@@ -61,7 +34,7 @@ async def progress_for_pyrogram(
humanbytes(total),
humanbytes(speed),
# elapsed_time if elapsed_time != '' else "0 s",
- estimated_total_time if estimated_total_time != '' else "0 s"
+ estimated_total_time if estimated_total_time != "" else "0 s",
)
try:
await message.edit(text=f"{ud_type}\n {tmp}")
@@ -70,20 +43,20 @@ async def progress_for_pyrogram(
return
-SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
+SIZE_UNITS = ["B", "KB", "MB", "GB", "TB", "PB"]
def huanbytes(size_in_bytes) -> str:
if size_in_bytes is None:
- return '0B'
+ return "0B"
index = 0
while size_in_bytes >= 1024:
size_in_bytes /= 1024
index += 1
try:
- return f'{round(size_in_bytes, 2)}{SIZE_UNITS[index]}'
+ return f"{round(size_in_bytes, 2)}{SIZE_UNITS[index]}"
except IndexError:
- return 'File too large'
+ return "File too large"
def humanbytes(size):
@@ -93,7 +66,7 @@ def humanbytes(size):
return ""
power = 2**10
n = 0
- Dic_powerN = {0: ' ', 1: 'K', 2: 'M', 3: 'G', 4: 'T'}
+ Dic_powerN = {0: " ", 1: "K", 2: "M", 3: "G", 4: "T"}
while size > power:
size /= power
n += 1
diff --git a/Uploader/functions/help_Nekmo_ffmpeg.py b/Uploader/functions/help_Nekmo_ffmpeg.py
index e66e1e5a..8e6fffb4 100644
--- a/Uploader/functions/help_Nekmo_ffmpeg.py
+++ b/Uploader/functions/help_Nekmo_ffmpeg.py
@@ -1,33 +1,13 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
import asyncio
from hachoir.parser import createParser
from hachoir.metadata import extractMetadata
import time
import logging
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
@@ -59,15 +39,17 @@ async def place_water_mark(input_file, output_file, water_mark_file):
t_response = stdout.decode().strip()
commands_to_execute = [
"ffmpeg",
- "-i", input_file,
- "-i", watermarked_file,
+ "-i",
+ input_file,
+ "-i",
+ watermarked_file,
"-filter_complex",
# https://stackoverflow.com/a/16235519
# "\"[0:0] scale=400:225 [wm]; [wm][1:0] overlay=305:0 [out]\"",
# "-map \"[out]\" -b:v 896k -r 20 -an ",
- "\"overlay=(main_w-overlay_w):(main_h-overlay_h)\"",
+ '"overlay=(main_w-overlay_w):(main_h-overlay_h)"',
# "-vf \"drawtext=text='@FFMovingPictureExpertGroupBOT':x=W-(W/2):y=H-(H/2):fontfile=" + Config.FONT_FILE + ":fontsize=12:fontcolor=white:shadowcolor=black:shadowx=5:shadowy=5\"",
- output_file
+ output_file,
]
# print(commands_to_execute)
process = await asyncio.create_subprocess_exec(
@@ -85,8 +67,7 @@ async def place_water_mark(input_file, output_file, water_mark_file):
async def take_screen_shot(video_file, output_directory, ttl):
# https://stackoverflow.com/a/13891070/4723940
- out_put_file_name = output_directory + \
- "/" + str(time.time()) + ".jpg"
+ out_put_file_name = output_directory + "/" + str(time.time()) + ".jpg"
file_genertor_command = [
"ffmpeg",
"-ss",
@@ -95,7 +76,7 @@ async def take_screen_shot(video_file, output_directory, ttl):
video_file,
"-vframes",
"1",
- out_put_file_name
+ out_put_file_name,
]
# width = "90"
process = await asyncio.create_subprocess_exec(
@@ -110,6 +91,7 @@ async def take_screen_shot(video_file, output_directory, ttl):
t_response = stdout.decode().strip()
return out_put_file_name if os.path.lexists(out_put_file_name) else None
+
# https://github.com/Nekmo/telegram-upload/blob/master/telegram_upload/video.py#L26
@@ -129,7 +111,7 @@ async def cult_small_video(video_file, output_directory, start_time, end_time):
"1",
"-strict",
"-2",
- out_put_file_name
+ out_put_file_name,
]
process = await asyncio.create_subprocess_exec(
*file_genertor_command,
@@ -145,17 +127,12 @@ async def cult_small_video(video_file, output_directory, start_time, end_time):
async def generate_screen_shots(
- video_file,
- output_directory,
- is_watermarkable,
- wf,
- min_duration,
- no_of_photos
+ video_file, output_directory, is_watermarkable, wf, min_duration, no_of_photos
):
metadata = extractMetadata(createParser(video_file))
duration = 0
if metadata is not None and metadata.has("duration"):
- duration = metadata.get('duration').seconds
+ duration = metadata.get("duration").seconds
if duration > min_duration:
images = []
ttl_step = duration // no_of_photos
diff --git a/Uploader/functions/help_uploadbot.py b/Uploader/functions/help_uploadbot.py
index 0d3e8528..2b4e86cd 100644
--- a/Uploader/functions/help_uploadbot.py
+++ b/Uploader/functions/help_uploadbot.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
import time
import requests
@@ -27,8 +5,9 @@
from Uploader.functions.display_progress import humanbytes
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
@@ -46,15 +25,12 @@ def DownLoadFile(url, file_name, chunk_size, client, ud_type, message_id, chat_i
# https://stackoverflow.com/a/47342052/4723940
total_size = int(r.headers.get("content-length", 0))
downloaded_size = 0
- with open(file_name, 'wb') as fd:
+ with open(file_name, "wb") as fd:
for chunk in r.iter_content(chunk_size=chunk_size):
if chunk:
fd.write(chunk)
downloaded_size += chunk_size
- if (
- client is not None
- and ((total_size // downloaded_size) % 5) == 0
- ):
+ if client is not None and ((total_size // downloaded_size) % 5) == 0:
time.sleep(0.3)
try:
client.edit_message_text(
diff --git a/Uploader/functions/help_ytdl.py b/Uploader/functions/help_ytdl.py
index 849e3e5a..bdcdc8ad 100644
--- a/Uploader/functions/help_ytdl.py
+++ b/Uploader/functions/help_ytdl.py
@@ -1,32 +1,11 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
import logging
from urllib.parse import urlparse
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
@@ -41,22 +20,22 @@ def get_resolution(info_dict):
height = 0
if {"width", "height"} <= info_dict.keys():
- width = int(info_dict['width'])
- height = int(info_dict['height'])
+ width = int(info_dict["width"])
+ height = int(info_dict["height"])
# https://support.google.com/youtube/answer/6375112
- elif info_dict['height'] == 1080:
+ elif info_dict["height"] == 1080:
width = 1920
height = 1080
- elif info_dict['height'] == 720:
+ elif info_dict["height"] == 720:
width = 1280
height = 720
- elif info_dict['height'] == 480:
+ elif info_dict["height"] == 480:
width = 854
height = 480
- elif info_dict['height'] == 360:
+ elif info_dict["height"] == 360:
width = 640
height = 360
- elif info_dict['height'] == 240:
+ elif info_dict["height"] == 240:
width = 426
height = 240
return width, height
diff --git a/Uploader/functions/ran_text.py b/Uploader/functions/ran_text.py
index 83ec6c11..e5c8c89a 100644
--- a/Uploader/functions/ran_text.py
+++ b/Uploader/functions/ran_text.py
@@ -1,31 +1,9 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import random
import string
def random_char(y):
- return ''.join(random.choice(string.ascii_letters) for _ in range(y))
+ return "".join(random.choice(string.ascii_letters) for _ in range(y))
-ran = (random_char(5))
+ran = random_char(5)
diff --git a/Uploader/script.py b/Uploader/script.py
index 6d4870e4..51f8d5a8 100644
--- a/Uploader/script.py
+++ b/Uploader/script.py
@@ -1,35 +1,12 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
class Translation(object):
START_TEXT = """
-Hi {}
+Hi {}
I am Powerful Url Uploader Bot
-
"""
HELP_TEXT = """
@@ -39,10 +16,9 @@ class Translation(object):
# Select the desired option.
# Then be relaxed your file will be uploaded soon..
-
"""
-# give credit to developer
+ # give credit to developer
ABOUT_TEXT = """
♻️ My Name : Url Uploader Bot
@@ -89,41 +65,48 @@ class Translation(object):
"""
START_BUTTONS = InlineKeyboardMarkup(
- [[
- InlineKeyboardButton('❓ Help', callback_data='help'),
- InlineKeyboardButton('🦊 About', callback_data='about')
- ], [
- InlineKeyboardButton('📛 Close', callback_data='close')
- ]]
+ [
+ [
+ InlineKeyboardButton("❓ Help", callback_data="help"),
+ InlineKeyboardButton("🦊 About", callback_data="about"),
+ ],
+ [InlineKeyboardButton("📛 Close", callback_data="close")],
+ ]
)
HELP_BUTTONS = InlineKeyboardMarkup(
- [[
- InlineKeyboardButton('🏠 Home', callback_data='home'),
- InlineKeyboardButton('🦊 About', callback_data='about')
- ], [
- InlineKeyboardButton('📛 Close', callback_data='close')
- ]]
+ [
+ [
+ InlineKeyboardButton("🏠 Home", callback_data="home"),
+ InlineKeyboardButton("🦊 About", callback_data="about"),
+ ],
+ [InlineKeyboardButton("📛 Close", callback_data="close")],
+ ]
)
ABOUT_BUTTONS = InlineKeyboardMarkup(
- [[
- InlineKeyboardButton('🏠 Home', callback_data='home'),
- InlineKeyboardButton('❓ Help', callback_data='help')
- ], [
- InlineKeyboardButton('📛 Close', callback_data='close')
- ]]
+ [
+ [
+ InlineKeyboardButton("🏠 Home", callback_data="home"),
+ InlineKeyboardButton("❓ Help", callback_data="help"),
+ ],
+ [InlineKeyboardButton("📛 Close", callback_data="close")],
+ ]
)
BUTTONS = InlineKeyboardMarkup(
- [[
- InlineKeyboardButton('📛 Close', callback_data='close')
- ]]
+ [[InlineKeyboardButton("📛 Close", callback_data="close")]]
)
FORMAT_SELECTION = "Now Select the desired formats"
SET_CUSTOM_USERNAME_PASSWORD = """"""
DOWNLOAD_START = "Trying to Download ⌛\n\n {} "
UPLOAD_START = "{} \n\n📤 Uploading Please Wait "
RCHD_TG_API_LIMIT = "Downloaded in {} seconds.\nDetected File Size: {}\nSorry. But, I cannot upload files greater than 2GB due to Telegram API limitations."
- AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = "Dᴏᴡɴʟᴏᴀᴅᴇᴅ ɪɴ {} sᴇᴄᴏɴᴅs.\n\nTʜᴀɴᴋs Fᴏʀ Usɪɴɢ Mᴇ\n\nUᴘʟᴏᴀᴅᴇᴅ ɪɴ {} sᴇᴄᴏɴᴅs"
+ AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = (
+ "Dᴏᴡɴʟᴏᴀᴅᴇᴅ ɪɴ {} sᴇᴄᴏɴᴅs.\n\nTʜᴀɴᴋs Fᴏʀ Usɪɴɢ Mᴇ\n\nUᴘʟᴏᴀᴅᴇᴅ ɪɴ {} sᴇᴄᴏɴᴅs"
+ )
FF_MPEG_DEL_ETED_CUSTOM_MEDIA = "✅ Media cleared succesfully."
- CUSTOM_CAPTION_UL_FILE = " "
+ CUSTOM_CAPTION_UL_FILE = ""
NO_VOID_FORMAT_FOUND = "ERROR... {}
"
- SLOW_URL_DECED = "Gosh that seems to be a very slow URL. Since you were screwing my home, I am in no mood to download this file. Meanwhile, why don't you try this:==> https://shrtz.me/PtsVnf6 and get me a fast URL so that I can upload to Telegram, without me slowing down for other users."
+ FREE_USER_LIMIT_Q_SZE = "Cannot Process, Time OUT..."
+ SLOW_URL_DECED = """
+ Gosh that seems to be a very slow URL. Since you were screwing my home,
+ I am in no mood to download this file. Meanwhile, why don't you try this:==> https://shrtz.me/PtsVnf6
+ and get me a fast URL so that I can upload to Telegram, without me slowing down for other users."""
diff --git a/Uploader/thumbunali.py b/Uploader/thumbunali.py
index 28fbf709..edc1930a 100644
--- a/Uploader/thumbunali.py
+++ b/Uploader/thumbunali.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
from pyrogram import Client, filters
@@ -32,10 +10,7 @@ async def save_photo(bot, message):
download_location = f"{Config.DOWNLOAD_LOCATION}/{message.from_user.id}.jpg"
await message.download(file_name=download_location)
- await message.reply_text(
- text="your custom thumbnail is saved",
- quote=True
- )
+ await message.reply_text(text="your custom thumbnail is saved", quote=True)
@Client.on_message(filters.command("thumb") & filters.incoming & filters.private)
@@ -44,12 +19,13 @@ async def send_photo(bot, message):
if os.path.isfile(download_location):
await message.reply_photo(
- photo=download_location,
- caption="your custom thumbnail",
- quote=True
+ photo=download_location, caption="your custom thumbnail", quote=True
)
else:
- await message.reply_text(text="you don't have set thumbnail yet!. send .jpg img to save as thumbnail.", quote=True)
+ await message.reply_text(
+ text="you don't have set thumbnail yet!. send .jpg img to save as thumbnail.",
+ quote=True,
+ )
@Client.on_message(filters.command("delthumb") & filters.incoming & filters.private)
@@ -57,6 +33,11 @@ async def delete_photo(bot, message):
download_location = f"{Config.DOWNLOAD_LOCATION}/{message.from_user.id}.jpg"
if os.path.isfile(download_location):
os.remove(download_location)
- await message.reply_text(text="your thumbnail removed successfully.", quote=True)
+ await message.reply_text(
+ text="your thumbnail removed successfully.", quote=True
+ )
else:
- await message.reply_text(text="you don't have set thumbnail yet!. send .jpg img to save as thumbnail.", quote=True)
+ await message.reply_text(
+ text="you don't have set thumbnail yet!. send .jpg img to save as thumbnail.",
+ quote=True,
+ )
diff --git a/Uploader/utitles.py b/Uploader/utitles.py
index 7df8dc8c..63c552e0 100644
--- a/Uploader/utitles.py
+++ b/Uploader/utitles.py
@@ -1,33 +1,12 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import logging
from hachoir.parser import createParser
from hachoir.metadata import extractMetadata
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
@@ -39,7 +18,7 @@ async def Mdata01(download_directory):
metadata = extractMetadata(createParser(download_directory))
if metadata is not None:
if metadata.has("duration"):
- duration = metadata.get('duration').seconds
+ duration = metadata.get("duration").seconds
if metadata.has("width"):
width = metadata.get("width")
if metadata.has("height"):
@@ -54,7 +33,7 @@ async def Mdata02(download_directory):
metadata = extractMetadata(createParser(download_directory))
if metadata is not None:
if metadata.has("duration"):
- duration = metadata.get('duration').seconds
+ duration = metadata.get("duration").seconds
if metadata.has("width"):
width = metadata.get("width")
@@ -64,7 +43,7 @@ async def Mdata02(download_directory):
async def Mdata03(download_directory):
metadata = extractMetadata(createParser(download_directory))
return (
- metadata.get('duration').seconds
+ metadata.get("duration").seconds
if metadata is not None and metadata.has("duration")
else 0
)
diff --git a/Uploader/youtube.py b/Uploader/youtube.py
index 031362b2..f3574ad0 100644
--- a/Uploader/youtube.py
+++ b/Uploader/youtube.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
import asyncio
@@ -40,9 +18,9 @@ async def callback_query_ytdl_audio(_, callback_query):
try:
url = callback_query.message.reply_to_message.text
ydl_opts = {
- 'format': 'bestaudio',
- 'outtmpl': '%(title)s - %(extractor)s-%(id)s.%(ext)s',
- 'writethumbnail': True
+ "format": "bestaudio",
+ "outtmpl": "%(title)s - %(extractor)s-%(id)s.%(ext)s",
+ "writethumbnail": True,
}
with YoutubeDL(ydl_opts) as ydl:
message = callback_query.message
@@ -53,8 +31,8 @@ async def callback_query_ytdl_audio(_, callback_query):
ydl.process_info(info_dict)
# upload
audio_file = ydl.prepare_filename(info_dict)
- task = asyncio.create_task(send_audio(message, info_dict,
- audio_file))
+ task = asyncio.create_task(
+ send_audio(message, info_dict, audio_file))
while not task.done():
await asyncio.sleep(3)
await message.reply_chat_action(enums.ChatAction.UPLOAD_DOCUMENT)
@@ -67,21 +45,29 @@ async def callback_query_ytdl_audio(_, callback_query):
async def send_audio(message: Message, info_dict, audio_file):
basename = audio_file.rsplit(".", 1)[-2]
- if info_dict['ext'] == 'webm':
+ if info_dict["ext"] == "webm":
audio_file_weba = f"{basename}.weba"
os.rename(audio_file, audio_file_weba)
audio_file = audio_file_weba
- thumbnail_url = info_dict['thumbnail']
+ thumbnail_url = info_dict["thumbnail"]
thumbnail_file = f"{basename}.{get_file_extension_from_url(thumbnail_url)}"
download_location = f"{Config.DOWNLOAD_LOCATION}/{message.from_user.id}.jpg"
thumb = download_location if os.path.isfile(
download_location) else None
- webpage_url = info_dict['webpage_url']
- title = info_dict['title'] or ''
- caption = f'{title}'
- duration = int(float(info_dict['duration']))
- performer = info_dict['uploader'] or ''
- await message.reply_audio(audio_file, caption=caption, duration=duration, performer=performer, title=title, parse_mode=enums.ParseMode.HTML, thumb=thumb)
+ webpage_url = info_dict["webpage_url"]
+ title = info_dict["title"] or ""
+ caption = f'{title}'
+ duration = int(float(info_dict["duration"]))
+ performer = info_dict["uploader"] or ""
+ await message.reply_audio(
+ audio_file,
+ caption=caption,
+ duration=duration,
+ performer=performer,
+ title=title,
+ parse_mode=enums.ParseMode.HTML,
+ thumb=thumb,
+ )
os.remove(audio_file)
os.remove(thumbnail_file)
@@ -89,18 +75,24 @@ async def send_audio(message: Message, info_dict, audio_file):
async def send_video(message: Message, info_dict, video_file):
basename = video_file.rsplit(".", 1)[-2]
- thumbnail_url = info_dict['thumbnail']
+ thumbnail_url = info_dict["thumbnail"]
thumbnail_file = f"{basename}.{get_file_extension_from_url(thumbnail_url)}"
download_location = f"{Config.DOWNLOAD_LOCATION}/{message.from_user.id}.jpg"
- thumb = download_location if os.path.isfile(
- download_location) else None
- webpage_url = info_dict['webpage_url']
- title = info_dict['title'] or ''
- caption = f'{title}'
- duration = int(float(info_dict['duration']))
+ thumb = download_location if os.path.isfile(download_location) else None
+ webpage_url = info_dict["webpage_url"]
+ title = info_dict["title"] or ""
+ caption = f'{title}'
+ duration = int(float(info_dict["duration"]))
width, height = get_resolution(info_dict)
- await message.reply_video(video_file, caption=caption, duration=duration, width=width, height=height,
- parse_mode=enums.ParseMode.HTML, thumb=thumb)
+ await message.reply_video(
+ video_file,
+ caption=caption,
+ duration=duration,
+ width=width,
+ height=height,
+ parse_mode=enums.ParseMode.HTML,
+ thumb=thumb,
+ )
os.remove(video_file)
os.remove(thumbnail_file)
@@ -112,9 +104,9 @@ async def callback_query_ytdl_video(_, callback_query):
# url = callback_query.message.text
url = callback_query.message.reply_to_message.text
ydl_opts = {
- 'format': 'best[ext=mp4]',
- 'outtmpl': '%(title)s - %(extractor)s-%(id)s.%(ext)s',
- 'writethumbnail': True
+ "format": "best[ext=mp4]",
+ "outtmpl": "%(title)s - %(extractor)s-%(id)s.%(ext)s",
+ "writethumbnail": True,
}
with YoutubeDL(ydl_opts) as ydl:
message = callback_query.message
@@ -125,8 +117,8 @@ async def callback_query_ytdl_video(_, callback_query):
ydl.process_info(info_dict)
# upload
video_file = ydl.prepare_filename(info_dict)
- task = asyncio.create_task(send_video(message, info_dict,
- video_file))
+ task = asyncio.create_task(
+ send_video(message, info_dict, video_file))
while not task.done():
await asyncio.sleep(3)
await message.reply_chat_action(enums.ChatAction.UPLOAD_DOCUMENT)
@@ -135,4 +127,4 @@ async def callback_query_ytdl_video(_, callback_query):
except Exception as e:
await message.reply_text(e)
await callback_query.message.reply_to_message.delete()
- await callback_query.message.delete()
\ No newline at end of file
+ await callback_query.message.delete()
diff --git a/app.py b/app.py
index 78fa71aa..d007f012 100644
--- a/app.py
+++ b/app.py
@@ -3,9 +3,9 @@
app = Flask(__name__)
-@app.route('/')
+@app.route("/")
def hello_world():
- return 'Hello from Koyeb'
+ return "Hello from Koyeb"
if __name__ == "__main__":
diff --git a/bot.py b/bot.py
index 9f616b20..4e2baa33 100644
--- a/bot.py
+++ b/bot.py
@@ -1,25 +1,3 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
import logging
from pyrogram.raw.all import layer
@@ -27,8 +5,9 @@
from config import Config
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+logging.basicConfig(
+ level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+)
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
@@ -50,17 +29,19 @@
bot = Client(
- 'All-Url-Uploader',
+ "All-Url-Uploader",
api_id=Config.API_ID,
api_hash=Config.API_HASH,
bot_token=Config.BOT_TOKEN,
workers=50,
- plugins=dict(root="Uploader")
+ plugins=dict(root="Uploader"),
)
bot.start()
logger.info("Bot has started.")
-logger.info(f"**Bot Started**\n\n**Pyrogram Version:** `{__version__}`\n**Layer:** `{layer}`")
+logger.info(
+ f"**Bot Started**\n\n**Pyrogram Version:** `{__version__}`\n**Layer:** `{layer}`"
+)
logger.info("Developed by github.com/kalanakt Sponsored by www.netronk.com")
idle()
bot.stop()
diff --git a/config.py b/config.py
index cb9fe22d..68230428 100644
--- a/config.py
+++ b/config.py
@@ -1,34 +1,11 @@
-# MIT License
-
-# Copyright (c) 2022 Hash Minner
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE
-
import os
from dotenv import load_dotenv
import logging
logging.basicConfig(
- format='%(name)s - %(levelname)s - %(message)s',
- handlers=[logging.FileHandler('log.txt'),
- logging.StreamHandler()],
- level=logging.INFO
+ format="%(name)s - %(levelname)s - %(message)s",
+ handlers=[logging.FileHandler("log.txt"), logging.StreamHandler()],
+ level=logging.INFO,
)
load_dotenv()
@@ -61,5 +38,5 @@ class Config(object):
OWNER_ID = os.environ.get("OWNER_ID")
ADL_BOT_RQ = {}
AUTH_USERS = list({int(x)
- for x in os.environ.get("AUTH_USERS", "0").split()})
+ for x in os.environ.get("AUTH_USERS", "0").split()})
AUTH_USERS.append(OWNER_ID)