Clean resond from yt-dlp download errror (#328)

This commit is contained in:
cpanel10x 2023-12-30 20:59:25 +07:00 committed by GitHub
parent 6c37e82b3d
commit 882b313a18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -118,6 +118,10 @@ def ytdl_download_task(chat_id: int, message_id: int, url: str):
else: else:
bot_msg.edit_text(f"{e}\nBig file download is not available now. Please /buy or try again later ") bot_msg.edit_text(f"{e}\nBig file download is not available now. Please /buy or try again later ")
except Exception: except Exception:
error_msg = traceback.format_exc().split("yt_dlp.utils.DownloadError: ERROR: ")
if len(error_msg) > 1:
bot_msg.edit_text(f"Download failed!❌\n\n`{error_msg[-1]}", disable_web_page_preview=True)
else:
bot_msg.edit_text(f"Download failed!❌\n\n`{traceback.format_exc()[-2000:]}`", disable_web_page_preview=True) bot_msg.edit_text(f"Download failed!❌\n\n`{traceback.format_exc()[-2000:]}`", disable_web_page_preview=True)
logging.info("YouTube celery tasks ended.") logging.info("YouTube celery tasks ended.")
@ -191,6 +195,10 @@ def ytdl_download_entrance(client: Client, bot_msg: types.Message, url: str, mod
bot_msg.edit_text(f"{e}\nBig file download is not available now. Please /buy or try again later ") bot_msg.edit_text(f"{e}\nBig file download is not available now. Please /buy or try again later ")
except Exception as e: except Exception as e:
logging.error("Failed to download %s, error: %s", url, e) logging.error("Failed to download %s, error: %s", url, e)
error_msg = traceback.format_exc().split("yt_dlp.utils.DownloadError: ERROR: ")
if len(error_msg) > 1:
bot_msg.edit_text(f"Download failed!❌\n\n`{error_msg[-1]}", disable_web_page_preview=True)
else:
bot_msg.edit_text(f"Download failed!❌\n\n`{traceback.format_exc()[-2000:]}`", disable_web_page_preview=True) bot_msg.edit_text(f"Download failed!❌\n\n`{traceback.format_exc()[-2000:]}`", disable_web_page_preview=True)