Commit 92388da
Changed files (2)
src
preview
subtitles
src/preview/ytdlp.py
@@ -93,7 +93,7 @@ async def preview_ytdlp(
delete_files (bool, optional): Whether to delete video & audio after uploading.
"""
logger.trace(f"{url=} {kwargs=}")
- if kwargs.get("show_progress") and "progress" not in kwargs:
+ if kwargs.get("show_progress") and not kwargs.get("progress"):
res = await send2tg(client, message, texts=f"🔗正在解析链接\n{url}", **kwargs)
kwargs["progress"] = res[0]
db_key = url
src/subtitles/subtitle.py
@@ -69,8 +69,8 @@ async def get_subtitle(
caption = f"{vinfo['emoji']}[{vinfo['author']}]({vinfo['channel']})\n🕒{vinfo['date']:%Y-%m-%d %H:%M:%S}\n📝[{vinfo['title']}]({url})"
msg = f"🔍**正在获取字幕:**\n{caption}"[:TEXT_LENGTH]
if kwargs.get("show_progress"):
- res = await send2tg(client, message, texts=msg, **kwargs)
- kwargs["progress"] = res[0]
+ status_msg = (await send2tg(client, message, texts=msg, **kwargs))[0]
+ kwargs["progress"] = status_msg
this_info = parse_msg(message, silent=True)
reply_info = parse_msg(message.reply_to_message, silent=True) if message.reply_to_message else {}
@@ -95,7 +95,7 @@ async def get_subtitle(
else:
await modify_progress(text=error + "\n正在通过下载音频后ASR识别字幕", force_update=True, **kwargs)
kwargs |= {
- "show_progress": False,
+ "progress": None,
"url": url,
"append_transcription": True,
"transcription_only": True,
@@ -146,4 +146,4 @@ async def get_subtitle(
await gpt_response(client, ai_msg, **kwargs)
with contextlib.suppress(Exception):
[await modify_progress(msg, del_status=True) for msg in res.get("sent_messages", [])]
- await modify_progress(del_status=True, **kwargs)
+ await modify_progress(status_msg, del_status=True)