Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async def del_thumb(id):

async def thumb(id):
try:
t = SESSION.query(Thumbnail).get(id)
return t
return SESSION.query(Thumbnail).get(id)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function thumb refactored with the following changes:

finally:
SESSION.close()
7 changes: 3 additions & 4 deletions helper_funcs/help_Nekmo_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,13 @@ async def generate_screen_shots(
):
metadata = extractMetadata(createParser(video_file))
duration = 0
if metadata is not None:
if metadata.has("duration"):
duration = metadata.get('duration').seconds
if metadata is not None and metadata.has("duration"):
duration = metadata.get('duration').seconds
if duration > min_duration:
images = []
ttl_step = duration // no_of_photos
current_ttl = ttl_step
for looper in range(0, no_of_photos):
for _ in range(no_of_photos):
Comment on lines -145 to +151
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function generate_screen_shots refactored with the following changes:

ss_img = await take_screen_shot(video_file, output_directory, current_ttl)
current_ttl = current_ttl + ttl_step
if is_watermarkable:
Expand Down
33 changes: 17 additions & 16 deletions helper_funcs/help_uploadbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

def DetectFileSize(url):
r = requests.get(url, allow_redirects=True, stream=True)
total_size = int(r.headers.get("content-length", 0))
return total_size
return int(r.headers.get("content-length", 0))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DetectFileSize refactored with the following changes:



def DownLoadFile(url, file_name, chunk_size, client, ud_type, message_id, chat_id):
Expand All @@ -31,19 +30,21 @@ def DownLoadFile(url, file_name, chunk_size, client, ud_type, message_id, chat_i
if chunk:
fd.write(chunk)
downloaded_size += chunk_size
if client is not None:
if ((total_size // downloaded_size) % 5) == 0:
time.sleep(0.3)
try:
client.edit_message_text(
chat_id,
message_id,
text="{}: {} of {}".format(
ud_type,
humanbytes(downloaded_size),
humanbytes(total_size)
)
if (
client is not None
and ((total_size // downloaded_size) % 5) == 0
):
time.sleep(0.3)
try:
client.edit_message_text(
chat_id,
message_id,
text="{}: {} of {}".format(
ud_type,
humanbytes(downloaded_size),
humanbytes(total_size)
)
except:
pass
)
except:
pass
Comment on lines -34 to +49
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DownLoadFile refactored with the following changes:

return file_name
20 changes: 4 additions & 16 deletions plugins/video_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def convert_to_video(bot, update):
[ InlineKeyboardButton(text="🔔Join My Updates Channel🔔", url=f"https://t.me/{update_channel}")]
])
)
return
return
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function convert_to_video refactored with the following changes:

This removes the following comments ( why? ):

#   chat_id=update.chat.id,
# ref: message from @Mo_Tech_Group
# get the correct width, height, and duration for videos greater than 10MB
#  text=Translation.UPLOAD_START,
# await bot.edit_message_text(
# don't care about the extension

#TRChatBase(update.from_user.id, update.text, "c2v")
if update.reply_to_message is not None:

Expand Down Expand Up @@ -81,21 +81,11 @@ async def convert_to_video(bot, update):
chat_id=update.chat.id,
message_id=a.message_id
)
# don't care about the extension
# await bot.edit_message_text(
# text=Translation.UPLOAD_START,
# chat_id=update.chat.id,
# message_id=a.message_id
# )
logger.info(the_real_download_location)
# get the correct width, height, and duration for videos greater than 10MB
# ref: message from @Mo_Tech_Group
width = 0
height = 0
duration = 0
metadata = extractMetadata(createParser(the_real_download_location))
if metadata.has("duration"):
duration = metadata.get('duration').seconds
duration = metadata.get('duration').seconds if metadata.has("duration") else 0
thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
if not os.path.exists(thumb_image_path):
thumb_image_path = await take_screen_shot(
Expand All @@ -109,10 +99,8 @@ async def convert_to_video(bot, update):
logger.info(thumb_image_path)
# 'thumb_image_path' will be available now
metadata = extractMetadata(createParser(thumb_image_path))
if metadata.has("width"):
width = metadata.get("width")
if metadata.has("height"):
height = metadata.get("height")
width = metadata.get("width") if metadata.has("width") else 0
height = metadata.get("height") if metadata.has("height") else 0
# get the correct width, height, and duration for videos greater than 10MB
# resize image
# ref: https://t.me/PyrogramChat/44663
Expand Down
6 changes: 4 additions & 2 deletions sample_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os

class Config(object):


class Config((object)):
Comment on lines -3 to +5
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 3-16 refactored with the following changes:

# get a token from @BotFather
TG_BOT_TOKEN = os.environ.get("TG_BOT_TOKEN", "")
# The Telegram API things
Expand All @@ -13,7 +15,7 @@ class Config(object):
# Get these values from my.telegram.org
CHAT_ID = os.environ.get("CHAT_ID", "")
# Array to store users who are authorized to use the bot
AUTH_USERS = set(int(x) for x in os.environ.get("AUTH_USERS", "").split())
AUTH_USERS = {int(x) for x in os.environ.get("AUTH_USERS", "").split()}
# Banned Unwanted Members..
BANNED_USERS = []
# the download location, where the HTTP Server runs
Expand Down