mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-07-07 07:31:24 +08:00
Merge pull request #381 from Loker-Choi/fix/youtube-shorts-url
fix(youtube): 支持 Shorts 链接
This commit is contained in:
@@ -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=xxxxx 或 youtu.be/xxxxx,ID 长度通常为 11
|
||||
match = re.search(r"(?:v=|youtu\.be/)([0-9A-Za-z_-]{11})", url)
|
||||
# 匹配 v=xxxxx、youtu.be/xxxxx 或 shorts/xxxxx,ID 长度通常为 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":
|
||||
|
||||
@@ -4,7 +4,7 @@ from urllib.parse import urlparse
|
||||
|
||||
SUPPORTED_PLATFORMS = {
|
||||
"bilibili": r"(https?://)?(www\.)?bilibili\.com/video/[a-zA-Z0-9]+",
|
||||
"youtube": r"(https?://)?(www\.)?(youtube\.com/watch\?v=|youtu\.be/)[\w\-]+",
|
||||
"youtube": r"(https?://)?(www\.)?(youtube\.com/(watch\?v=|shorts/)|youtu\.be/)[\w\-]+",
|
||||
"douyin": "douyin",
|
||||
"kuaishou": "kuaishou"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user