From 9b8ea5417fa1e13dda26be0e3c7205dfc04bd1d3 Mon Sep 17 00:00:00 2001 From: hollc <380460708@qq.com> Date: Sun, 9 Jun 2024 09:19:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E4=BC=A0=E6=8D=9F?= =?UTF-8?q?=E5=9D=8F=E7=9A=84=E6=96=87=E4=BB=B6=E9=80=A0=E6=88=90=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=BB=88=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/upload_file.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tools/upload_file.py b/tools/upload_file.py index ac69507..7ad9767 100644 --- a/tools/upload_file.py +++ b/tools/upload_file.py @@ -71,15 +71,18 @@ async def upload_file(client: TelegramClient, chat_id, path: str, del_after_uplo except Exception as e: print(f'上传出错,错误原因{e.__class__.__name__},跳过{filename}') continue - await client.send_file( - peo, - result, - caption=filename_without_ext if addtag is None else str2join(f'#{addtag} ', filename_without_ext), - thumb=thumb_input, - progress_callback=bar.update_to, - attributes=[video_attr]) - if del_after_upload: - os.remove(file_path) + try: + await client.send_file( + entity=peo, + file=result, + caption=filename_without_ext if addtag is None else str2join(f'#{addtag} ', filename_without_ext), + thumb=thumb_input, + progress_callback=bar.update_to, + attributes=[video_attr]) + if del_after_upload: + os.remove(file_path) + except Exception: + print(f'上传出错,疑似文件损坏,跳过{filename}') if isDir and not os.listdir(path): os.rmdir(path) # except Exception as e: