-
Notifications
You must be signed in to change notification settings - Fork 50
Sourcery refactored master branch #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| ss_img = await take_screen_shot(video_file, output_directory, current_ttl) | ||
| current_ttl = current_ttl + ttl_step | ||
| if is_watermarkable: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def DownLoadFile(url, file_name, chunk_size, client, ud_type, message_id, chat_id): | ||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return file_name | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ): |
||
| #TRChatBase(update.from_user.id, update.text, "c2v") | ||
| if update.reply_to_message is not None: | ||
|
|
||
|
|
@@ -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( | ||
|
|
@@ -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 | ||
|
|
||
| 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| # get a token from @BotFather | ||
| TG_BOT_TOKEN = os.environ.get("TG_BOT_TOKEN", "") | ||
| # The Telegram API things | ||
|
|
@@ -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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
thumbrefactored with the following changes:inline-immediately-returned-variable)