Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
Sourcery AI committed Aug 1, 2022
1 parent dc3422d commit b48460a
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions Uploader/button.py
Original file line number Diff line number Diff line change
@@ -105,13 +105,13 @@ async def youtube_dl_call_back(bot, update):
)
description = Translation.CUSTOM_CAPTION_UL_FILE
if "fulltitle" in response_json:
description = response_json["fulltitle"][0:1021]
# escape Markdown and special characters
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}'
if not os.path.isdir(tmp_directory_for_each_user):
os.makedirs(tmp_directory_for_each_user)
download_directory = tmp_directory_for_each_user + "/" + custom_file_name
download_directory = f"{tmp_directory_for_each_user}/{custom_file_name}"

command_to_exec = []
if tg_send_type == "audio":
@@ -285,7 +285,7 @@ async def youtube_dl_call_back(bot, update):
)
)
else:
logger.info("✅ " + custom_file_name)
logger.info(f"✅ {custom_file_name}")
end_two = datetime.now()
time_taken_for_upload = (end_two - end_one).seconds
try:
@@ -298,5 +298,5 @@ async def youtube_dl_call_back(bot, update):

)

logger.info("✅ Downloaded in: " + str(time_taken_for_download))
logger.info("✅ Uploaded in: " + str(time_taken_for_upload))
logger.info(f"✅ Downloaded in: {str(time_taken_for_download)}")
logger.info(f"✅ Uploaded in: {str(time_taken_for_upload)}")
5 changes: 3 additions & 2 deletions Uploader/config.py
Original file line number Diff line number Diff line change
@@ -32,6 +32,8 @@
)




class Config(object):
# get a token from @BotFather
BOT_TOKEN = os.environ.get("BOT_TOKEN", "")
@@ -70,6 +72,5 @@ class Config(object):
OWNER_ID = int(os.environ.get("OWNER_ID", ""))
BOT_USERNAME = os.environ.get("BOT_USERNAME", "")
ADL_BOT_RQ = {}
AUTH_USERS = list(set(int(x)
for x in os.environ.get("AUTH_USERS", "0").split()))
AUTH_USERS = list({int(x) for x in os.environ.get("AUTH_USERS", "0").split()})
AUTH_USERS.append(OWNER_ID)
13 changes: 6 additions & 7 deletions Uploader/dl_button.py
Original file line number Diff line number Diff line change
@@ -78,8 +78,8 @@ async def ddl_call_back(bot, update):
youtube_dl_url = youtube_dl_url[o:o + l]

description = custom_file_name
if not "." + youtube_dl_ext in custom_file_name:
custom_file_name += '.' + youtube_dl_ext
if f".{youtube_dl_ext}" not in custom_file_name:
custom_file_name += f'.{youtube_dl_ext}'
logger.info(youtube_dl_url)
logger.info(custom_file_name)

@@ -93,7 +93,7 @@ async def ddl_call_back(bot, update):
"/" + str(update.from_user.id)
if not os.path.isdir(tmp_directory_for_each_user):
os.makedirs(tmp_directory_for_each_user)
download_directory = tmp_directory_for_each_user + "/" + custom_file_name
download_directory = f"{tmp_directory_for_each_user}/{custom_file_name}"
command_to_exec = []
async with aiohttp.ClientSession() as session:
c_time = time.time()
@@ -218,7 +218,7 @@ async def ddl_call_back(bot, update):
)

else:
logger.info("✅ " + custom_file_name)
logger.info(f"✅ {custom_file_name}")
end_two = datetime.now()
try:
os.remove(download_directory)
@@ -235,8 +235,8 @@ async def ddl_call_back(bot, update):
disable_web_page_preview=True
)

logger.info("✅ Downloaded in: " + str(time_taken_for_download))
logger.info("✅ Uploaded in: " + str(time_taken_for_upload))
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"),
@@ -290,5 +290,4 @@ async def download_coroutine(bot, session, url, file_name, chat_id, message_id,
display_message = current_message
except Exception as e:
logger.info(str(e))
pass
return await response.release()
2 changes: 1 addition & 1 deletion Uploader/functions/ran_text.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@


def random_char(y):
return ''.join(random.choice(string.ascii_letters) for x in range(y))
return ''.join(random.choice(string.ascii_letters) for _ in range(y))


ran = (random_char(5))

0 comments on commit b48460a

Please sign in to comment.