Commit 0c97b40
Changed files (2)
src/handler.py
@@ -306,7 +306,7 @@ async def handle_social_media(
if warn_msg:
await warn_msg.delete()
- if any(keyword in info["text"] for keyword in ["facebook.com", "threads.com"]):
+ if not sent_messages and any(keyword in info["text"] for keyword in ["facebook.com", "threads.com"]):
if kwargs.get("show_progress"):
warn_msg = await message.reply_text("⚠️该链接不被支持", quote=True)
await asyncio.sleep(10)
src/networking.py
@@ -347,14 +347,16 @@ async def match_social_media_link(text: str, *, flatten_first: bool = True) -> d
"platform": "xiaohongshu",
}
- # https://www.bilibili.com/video/BV1TC411J7PK
- # https://www.bilibili.com/BV1TC411J7PK
- if matched := re.search(r"(https?://)?(:?m\.|www\.)?bilibili\.com/(video/)?(BV1[a-zA-Z0-9]{9})", text):
+ # https://www.bilibili.com/video/BV1RSsNzDEQb
+ # https://www.bilibili.com/video/av115402113881975
+ # https://www.bilibili.com/BV1RSsNzDEQb
+ # https://www.bilibili.com/av115402113881975
+ if matched := re.search(r"(https?://)?(:?m\.|www\.)?bilibili\.com/(video/)?(?P<prefix>[aAbB][vV])(?P<id>[a-zA-Z0-9]+)", text):
base_url = matched.group(0).split("?")[0]
bvid = Path(base_url).stem
queries = parse_qs(urlparse(matched.group(0)).query)
pid = queries.get("p", ["1"])[0]
- url = f"https://www.bilibili.com/video/{bvid}?p={pid}".removesuffix("?p=1")
+ url = f"https://www.bilibili.com/video/{av2bv(bvid)}?p={pid}".removesuffix("?p=1")
return {"url": url, "db_key": bare_url(url), "bvid": av2bv(bvid), "pid": pid, "platform": "bilibili"}
# https://m.bilibili.com/opus/1048442220384878593
@@ -532,14 +534,13 @@ if __name__ == "__main__":
# asyncio.run(flatten_rediercts("https://v.douyin.com/CeiJfJMQG/"))
# asyncio.run(flatten_rediercts("https://www.tiktok.com/t/ZT2mcMA7f/"))
# asyncio.run(flatten_rediercts("https://t.co/Wwo3x69CQz"))
- print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/issues/14463")))
- print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/")))
- print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp")))
- print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/issues/14404#issuecomment-3323873708")))
- print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/pull/14467")))
- print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/pull/14417#issuecomment-3327344721")))
- print(asyncio.run(match_social_media_link("https://mapp.api.weibo.cn/fx/09ab955a1e0d406c9d6a74f5a2242b4a.html")))
-
+ # print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/issues/14463")))
+ # print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/")))
+ # print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp")))
+ # print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/issues/14404#issuecomment-3323873708")))
+ # print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/pull/14467")))
+ # print(asyncio.run(match_social_media_link("https://github.com/yt-dlp/yt-dlp/pull/14417#issuecomment-3327344721")))
+ # print(asyncio.run(match_social_media_link("https://mapp.api.weibo.cn/fx/09ab955a1e0d406c9d6a74f5a2242b4a.html")))
# print(asyncio.run(match_social_media_link("https://www.bilibili.com/video/BV1TC411J7PK")))
# print(asyncio.run(match_social_media_link("https://www.bilibili.com/BV1TC411J7PK")))
# print(asyncio.run(match_social_media_link("https://www.instagram.com/miyoshi.aa/p/DN5hFcUE8rS/")))