fix(youtube): support shorts urls

This commit is contained in:
Loker
2026-05-26 17:13:28 +08:00
parent f2d8ece0c1
commit 7d4573f84e
3 changed files with 53 additions and 3 deletions

View File

@@ -23,8 +23,8 @@ def extract_video_id(url: str, platform: str) -> Optional[str]:
return f"BV{match.group(1)}" if match else None
elif platform == "youtube":
# 匹配 v=xxxxxyoutu.be/xxxxxID 长度通常为 11
match = re.search(r"(?:v=|youtu\.be/)([0-9A-Za-z_-]{11})", url)
# 匹配 v=xxxxxyoutu.be/xxxxx 或 shorts/xxxxxID 长度通常为 11
match = re.search(r"(?:v=|youtu\.be/|shorts/)([0-9A-Za-z_-]{11})", url)
return match.group(1) if match else None
elif platform == "douyin":