Commit 15347d3

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-01-25 10:49:18
feat(douyin): support `iesdouyin.com`
1 parent 74c0eb9
Changed files (1)
src/networking.py
@@ -317,17 +317,14 @@ async def match_social_media_link(text: str, *, flatten_first: bool = False) ->
         text = await flatten_rediercts(text)
     matched_info = {"platform": ""}
     # https://www.douyin.com/video/7398813386827468041
-    if matched := re.search(r"(https?://)?(www\.)?douyin\.com/video/(\d+)", text):
-        matched_info = {"url": https_url(matched.group(0)), "db_key": bare_url(matched.group(0)), "platform": "douyin"}
-
+    # https://www.douyin.com/note/7458195074434846004
+    # https://www.iesdouyin.com/share/video/7454527270925946138/
+    # https://www.iesdouyin.com/share/note/7454527270925946138/
+    if matched := re.search(r"(https?://)?(www\.)?(ies)?douyin\.com/(share/)?(:?|video|note)/(\d+)", text):
+        matched_info = {"url": f"https://www.douyin.com/{matched.group(5)}/{matched.group(6)}", "db_key": f"www.douyin.com/{matched.group(5)}/{matched.group(6)}", "platform": "douyin"}
     # https://www.douyin.com/user/MS4wLjABAAAAXgBuOEcyavDhrRBqnD8x7d4pj7RIL5QFRlLehCnem8couoAg8yXR-MGhUK0i4riF?modal_id=7451543857952492810
     if matched := re.search(r"(https?://)?(www\.)?douyin\.com/user/(.*?)\?(.*?)modal_id=(\d+)", text):
         matched_info = {"url": f"https://www.douyin.com/video/{matched.group(5)}", "db_key": f"www.douyin.com/video/{matched.group(5)}", "platform": "douyin"}
-
-    # https://www.douyin.com/note/7458195074434846004
-    if matched := re.search(r"(https?://)?(www\.)?douyin\.com/note/(\d+)", text):
-        matched_info = {"url": f"https://www.douyin.com/note/{matched.group(3)}", "db_key": f"www.douyin.com/note/{matched.group(3)}", "platform": "douyin"}
-
     # https://www.tiktok.com/@baymermel/video/7460653893941267755\?_t\=ZS-8t8YbVWqv5k\&_r\=1
     if matched := re.search(r"(https?://)?(www\.)?tiktok\.com/(.*?)/(\d+)", text):
         matched_info = {"url": https_url(matched.group(0)), "db_key": bare_url(matched.group(0)), "platform": "tiktok"}
@@ -472,8 +469,10 @@ async def flatten_rediercts(texts: str | None = None, pattern: str | None = None
 if __name__ == "__main__":
     import asyncio
 
-    # asyncio.run(match_social_media_link("https://www.instagram.com/yifaer_chen/p/DEzv9x-vzOn/"))
-    asyncio.run(flatten_rediercts("http://t.cn/A6ukIuVn"))
+    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/"))
+    # 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://t.co/Wwo3x69CQz"))