Commit f89cc34
Changed files (9)
src/preview/bilibili.py
@@ -47,14 +47,14 @@ async def preview_bilibili(
db_key (str, optional): The cache key.
post_id (str, optional): bilibili post ID
"""
- if kwargs.get("show_progress") and "progress" not in kwargs:
- res = await send2tg(client, message, texts=f"🔗正在解析B站链接\n{url}", **kwargs)
- kwargs["progress"] = res[0]
if kv := await get_db(db_key):
logger.debug(f"Bilibili preview {DB.ENGINE} cache hit for key={url}")
if await copy_messages_from_db(client, message, key=url, kv=kv, **kwargs):
return
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+ if kwargs.get("show_progress") and "progress" not in kwargs:
+ res = await send2tg(client, message, texts=f"🔗正在解析B站链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
if platform == "bilibili-opus":
post_info = await parse_bilibili_opus(post_id, **kwargs)
else:
src/preview/douyin.py
@@ -51,14 +51,14 @@ async def preview_douyin(
douyin_provider (str, optional): The douyin extractor: "direct", "free", "tikhub", "bridge", or combined strings.
douyin_comments_provider (str, optional): The douyin comments extractor: "free", "tikhub" or "free-tikhub".
"""
- if kwargs.get("show_progress") and "progress" not in kwargs:
- res = await send2tg(client, message, texts=f"🔗正在解析抖音链接\n{url}", **kwargs)
- kwargs["progress"] = res[0]
if kv := await get_db(db_key):
logger.debug(f"{platform} preview {DB.ENGINE} cache hit for key={db_key}")
if await copy_messages_from_db(client, message, key=db_key, kv=kv, **kwargs):
return
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+ if kwargs.get("show_progress") and "progress" not in kwargs:
+ res = await send2tg(client, message, texts=f"🔗正在解析抖音链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
proxy = PROXY.DOUYIN if platform == "douyin" else PROXY.TIKTOK
logger.info(f"{platform} link preview for {url}")
src/preview/instagram.py
@@ -47,15 +47,16 @@ async def preview_instagram(
instagram_provider (str, optional): The instagram extractor: tikhub, ddinstagram, bridge
instagram_comments (bool, optional): Add instagram comments. Defaults to True.
"""
- if kwargs.get("show_progress") and "progress" not in kwargs:
- res = await send2tg(client, message, texts=f"🔗正在解析Instagram链接\n{url}", **kwargs)
- kwargs["progress"] = res[0]
-
if kv := await get_db(db_key):
logger.debug(f"Instagram preview {DB.ENGINE} cache hit for key={db_key}")
if await copy_messages_from_db(client, message, key=db_key, kv=kv, **kwargs):
return
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+
+ if kwargs.get("show_progress") and "progress" not in kwargs:
+ res = await send2tg(client, message, texts=f"🔗正在解析Instagram链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
+
succ = False
resp = {}
if "tikhub" in instagram_provider: # try tikhub
src/preview/reddit.py
@@ -30,15 +30,14 @@ async def preview_reddit(client: Client, message: Message, url: str = "", db_key
url (str, optional): Reddit link
db_key (str, optional): The cache key.
"""
- if kwargs.get("show_progress") and "progress" not in kwargs:
- res = await send2tg(client, message, texts=f"🔗正在解析Reddit链接\n{url}", **kwargs)
- kwargs["progress"] = res[0]
if kv := await get_db(db_key):
logger.debug(f"Reddit preview {DB.ENGINE} cache hit for key={db_key}")
if await copy_messages_from_db(client, message, key=db_key, kv=kv, **kwargs):
return
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
- logger.info(f"Reddit link preview for {url}")
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+ if kwargs.get("show_progress") and "progress" not in kwargs:
+ res = await send2tg(client, message, texts=f"🔗正在解析Reddit链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
post_info = await get_reddit_info(url)
if error := post_info.get("error"):
src/preview/twitter.py
@@ -51,15 +51,15 @@ async def preview_twitter(
twitter_provider (str): The extractor to use: fxtwitter or tikhub.
twitter_comments (bool, optional): Add twitter comments. Defaults to True
"""
- if kwargs.get("show_progress") and "progress" not in kwargs:
- res = await send2tg(client, message, texts=f"🔗正在解析推特链接\n{url}", **kwargs)
- kwargs["progress"] = res[0]
-
if kv := await get_db(db_key):
logger.debug(f"Twitter preview {DB.ENGINE} cache hit for key={db_key}")
if await copy_messages_from_db(client, message, key=db_key, kv=kv, **kwargs):
return
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+ if kwargs.get("show_progress") and "progress" not in kwargs:
+ res = await send2tg(client, message, texts=f"🔗正在解析推特链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
+
succ = False
master_info = {}
this_info = {}
src/preview/wechat.py
@@ -28,14 +28,14 @@ async def preview_wechat(client: Client, message: Message, url: str = "", db_key
url (str, optional): wechat link
db_key (str, optional): The cache key.
"""
- if kwargs.get("show_progress") and "progress" not in kwargs:
- res = await send2tg(client, message, texts=f"🔗正在解析微信链接\n{url}", **kwargs)
- kwargs["progress"] = res[0]
if kv := await get_db(db_key):
logger.debug(f"WeChat preview {DB.ENGINE} cache hit for key={db_key}")
if await copy_messages_from_db(client, message, key=db_key, kv=kv, **kwargs):
return
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+ if kwargs.get("show_progress") and "progress" not in kwargs:
+ res = await send2tg(client, message, texts=f"🔗正在解析微信链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
logger.info(f"WeChat link preview for {url}")
post_info = await get_wechat_info(url)
src/preview/weibo.py
@@ -58,14 +58,14 @@ async def preview_weibo(
real_post_id = real_weibo_post_id(post_id)
db_key = db_key.replace(post_id, real_post_id)
- if kwargs.get("show_progress") and "progress" not in kwargs:
- res = await send2tg(client, message, texts=f"🔗正在解析微博链接\n{url}", **kwargs)
- kwargs["progress"] = res[0]
if kv := await get_db(db_key):
logger.debug(f"Weibo preview {DB.ENGINE} cache hit for key={url}")
if await copy_messages_from_db(client, message, key=url, kv=kv, **kwargs):
return
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+ if kwargs.get("show_progress") and "progress" not in kwargs:
+ res = await send2tg(client, message, texts=f"🔗正在解析微博链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
this_info = await parse_weibo_info(post_id, **kwargs)
if error_msg := this_info.get("error_msg"):
if "bridge" in weibo_provider and not this_info.get("force_stop"):
src/preview/xiaohongshu.py
@@ -50,14 +50,14 @@ async def preview_xhs(
is_xhs_link (bool, optional): Whether the link is a share link from APP.
xhs_provider (str, optional): The xiaohongshu provider.
"""
- if kwargs.get("show_progress") and "progress" not in kwargs:
- res = await send2tg(client, message, texts=f"🔗正在解析小红书链接\n{url}", **kwargs)
- kwargs["progress"] = res[0]
if kv := await get_db(db_key):
logger.debug(f"Xiaohongshu preview {DB.ENGINE} cache hit for key={db_key}")
if await copy_messages_from_db(client, message, key=db_key, kv=kv, **kwargs):
return
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+ if kwargs.get("show_progress") and "progress" not in kwargs:
+ res = await send2tg(client, message, texts=f"🔗正在解析小红书链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
if not is_xhs_link and "xsec_token" not in url:
msg = "链接格式错误: 缺少 xsec_token 参数, 请发送完整链接"
src/ytdlp/main.py
@@ -81,9 +81,6 @@ async def preview_ytdlp(
to_telegraph (bool, optional): Whether to publish the subtitle or transcription to telegraph.
"""
logger.trace(f"{url=} {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]
# try cache
db_key = url
if true(use_db) and (kv := await get_db(db_key)):
@@ -91,7 +88,11 @@ async def preview_ytdlp(
kwargs |= {"copy_video_msg": kwargs.get("copy_video_msg", ytdlp_send_video), "copy_audio_msg": kwargs.get("copy_audio_msg", ytdlp_send_audio)}
if db_msgs := await copy_messages_from_db(client, message, key=db_key, kv=kv, **kwargs):
return db_msgs
- await modify_progress(text=f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...", **kwargs)
+ logger.warning(f"❌从{DB.ENGINE}缓存中转发失败, 尝试重新解析...")
+
+ if kwargs.get("show_progress") and not kwargs.get("progress"):
+ res = await send2tg(client, message, texts=f"🔗正在解析链接\n{url}", **kwargs)
+ kwargs["progress"] = res[0]
# get video info from API first
if platform == "youtube":