Commit 3dc371c

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-03-08 10:23:46
feat: support facebook short link
1 parent d20fe93
Changed files (1)
src/networking.py
@@ -369,6 +369,9 @@ async def flatten_rediercts(texts: str | None = None, pattern: str | None = None
     # tiktok.com/t/
     if matched := re.search(r"(https?://)?(www\.)?tiktok\.com/t/([^.。,,?&/\s]+)", texts):
         url = matched.group(0)
+    # facebook.com/
+    if matched := re.search(r"(https?://)?facebook\.com/share/r/([^.。,,?&/\s]+)", texts):
+        url = matched.group(0)
     # b23.tv
     if matched := re.search(r"(https?://)?b23\.tv/([^.。,,?&/\s]+)", texts):
         url = matched.group(0)
@@ -418,6 +421,7 @@ if __name__ == "__main__":
     import asyncio
 
     check_data(json.dumps({"foo": "bar", "baz": {"qux": "quux"}, "lst": ["1", "2", "3"]}), check_keys=["baz.qux"], check_kv={"foo": "bar", "baz.qux": "quux", "lst": ["1", "2", "3"]})
+    asyncio.run(match_social_media_link("https://www.facebook.com/share/r/19QGGp39T3/", flatten_first=True))
     # asyncio.run(match_social_media_link("https://www.douyin.com/video/7398813386827468041"))
     # asyncio.run(match_social_media_link("https://www.iesdouyin.com/share/note/7454527270925946138/"))
     # asyncio.run(match_social_media_link("https://www.instagram.com/yifaer_chen/p/DEzv9x-vzOn/"))
@@ -429,8 +433,8 @@ if __name__ == "__main__":
     # res = asyncio.run(hx_req("https://httpbin.org/delay/10"))
     # asyncio.run(hx_req("https://httpbin.org/get", check_kv={"url": "https://httpbin.org/get", "headers.Pragma": "no-cache1"}, max_retry=1))
     # resp = asyncio.run(hx_req("https://httpbin.org/get", check_kv={"headers": {"Accept-Language": "en-US,en;q=0.8"}}))
-    resp = asyncio.run(hx_req("https://httpbin.org/headers", headers={"referer": "https://www.xiaohongshu.com/"}))
+    # resp = asyncio.run(hx_req("https://httpbin.org/headers", headers={"referer": "https://www.xiaohongshu.com/"}))
+    # print(resp)
 
-    print(resp)
     # asyncio.run(download_file("https://httpbin.org/image/jpeg", suffix=".jpg"))
     # asyncio.run(match_social_media_link("https://www.instagram.com/p/C7P3jN8vmEN"))