Commit 4c043b8

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-02-27 09:57:40
fix(tiktok): add support for `tiktok.com/t/` short url
1 parent 8c57e09
Changed files (1)
src/networking.py
@@ -383,6 +383,9 @@ async def flatten_rediercts(texts: str | None = None, pattern: str | None = None
     # vt.tiktok.com
     if matched := re.search(r"(https?://)?vt\.tiktok\.com/([^.。,,?&/\s]+)", texts):
         url = matched.group(0)
+    # tiktok.com/t/
+    if matched := re.search(r"(https?://)?(www\.)?tiktok\.com/t/([^.。,,?&/\s]+)", texts):
+        url = matched.group(0)
     # b23.tv
     if matched := re.search(r"(https?://)?b23\.tv/([^.。,,?&/\s]+)", texts):
         url = matched.group(0)
@@ -439,9 +442,10 @@ if __name__ == "__main__":
     # asyncio.run(flatten_rediercts("http://t.cn/A6ukIuVn"))
     # asyncio.run(flatten_rediercts("shorturl.at/fuyrt"))
     # 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"))
     # 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))
+    # 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/status/404"))
     # asyncio.run(download_file("https://httpbin.org/image/jpeg", suffix=".jpg"))