Skip to content

Commit

Permalink
fix: ffile not found
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Gorn committed Jun 10, 2024
1 parent e8be45d commit 2684404
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 2 additions & 6 deletions Bot/functions/dl_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ async def ddl_call_back(bot: Client, update: CallbackQuery):
audio=download_directory,
caption=description,
duration=duration,
# performer=response_json["uploader"],
# title=response_json["title"],
# reply_markup=reply_markup,
thumb=thumb_image_path,
reply_to_message_id=update.message.reply_to_message.id,
progress=progress_for_pyrogram,
Expand All @@ -181,7 +178,6 @@ async def ddl_call_back(bot: Client, update: CallbackQuery):
document=download_directory,
thumb=thumb_image_path,
caption=description,
# reply_markup=reply_markup,
reply_to_message_id=update.message.reply_to_message.id,
progress=progress_for_pyrogram,
progress_args=(
Expand Down Expand Up @@ -214,7 +210,6 @@ async def ddl_call_back(bot: Client, update: CallbackQuery):
width=width,
height=height,
supports_streaming=True,
# reply_markup=reply_markup,
thumb=thumb_image_path,
reply_to_message_id=update.message.reply_to_message.id,
progress=progress_for_pyrogram,
Expand All @@ -229,7 +224,8 @@ async def ddl_call_back(bot: Client, update: CallbackQuery):
await media.copy(client.config.DUMP_ID, caption=f'User Name: {update.from_user.first_name}\nUser ID: {update.from_user.id}\nLink: {youtube_dl_url}')
os.remove(download_directory)
if not client.custom_thumbnail.get(update.from_user.id):
os.remove(thumb_image_path)
if thumb_image_path and os.path.isfile(thumb_image_path):
os.remove(thumb_image_path)
time_taken_for_download = (end_one - start).seconds
time_taken_for_upload = (end_two - end_one).seconds
await bot.edit_message_text(
Expand Down
13 changes: 9 additions & 4 deletions Bot/functions/youtube_dl_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ async def youtube_dl_call_back(bot: Client, update: CallbackQuery):
try:
file_size = os.stat(download_directory).st_size
except FileNotFoundError:
download_directory = download_directory + "." + "mkv"
if os.path.isfile(download_directory + "." + "mkv"):
download_directory = download_directory + "." + "mkv"
elif os.path.isfile(download_directory + "." + "webm"):
download_directory = download_directory + "." + "webm"
else:
return await update.message.edit(text='File not found in the directory.')
# https://stackoverflow.com/a/678242/4723940
file_size = os.stat(download_directory).st_size
if file_size > client.config.TG_MAX_FILE_SIZE:
Expand Down Expand Up @@ -313,14 +318,13 @@ async def youtube_dl_call_back(bot: Client, update: CallbackQuery):
media_album_p: list[InputMediaPhoto] = []
if images:
i = 0
caption = "@xurluploaderbot"
for image in images:
if os.path.exists(str(image)):
if i == 0:
media_album_p.append(
InputMediaPhoto(
media=image,
caption=caption,
caption=bot.me.first_name,
parse_mode=enums.ParseMode.HTML
)
)
Expand All @@ -343,7 +347,8 @@ async def youtube_dl_call_back(bot: Client, update: CallbackQuery):
os.remove(photo.media)
os.remove(download_directory)
if not client.custom_thumbnail.get(update.from_user.id):
os.remove(thumb_image_path)
if thumb_image_path and os.path.isfile(thumb_image_path):
os.remove(thumb_image_path)
await bot.edit_message_text(
text=client.translation.AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS.format(
time_taken_for_download, time_taken_for_upload),
Expand Down
3 changes: 1 addition & 2 deletions Bot/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ class Translation(object):
DOWNLOAD_START = "Downloading..."
UPLOAD_START = "Uploading..."
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 = "Thanks for using @xurluploaderbot)"
AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = "Downloaded in {} seconds.\nUploaded in {} seconds.\n\n@xurluploaderbot"
AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = "Downloaded in {} seconds.\nUploaded in {} seconds."
SAVED_CUSTOM_THUMB_NAIL = "Custom video / file thumbnail saved. This image will be used in the video / file."
DEL_ETED_CUSTOM_THUMB_NAIL = "✅ Custom thumbnail cleared succesfully."
CUSTOM_CAPTION_UL_FILE = "{}"
Expand Down

0 comments on commit 2684404

Please sign in to comment.