Skip to content

Commit f941977

Browse files
committed
Add support for YouTube Shorts
1 parent 9694978 commit f941977

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

youtubevideotranscriptbot/youtube_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ def extract_video_id(url):
1313
r"(?:https?:\/\/)?(?:www\.)?youtu\.be\/([a-zA-Z0-9_-]+)", # Shortened links
1414
r"(?:https?:\/\/)?(?:www\.)?youtube\.com\/live\/([a-zA-Z0-9_-]+)", # Live stream links
1515
r"(?:https?:\/\/)?(?:www\.)?youtube\.com\/embed\/([a-zA-Z0-9_-]+)", # Embedded links
16-
r"(?:https?:\/\/)?(?:www\.)?youtube\.com\/v\/([a-zA-Z0-9_-]+)" # Deprecated /v/ links
16+
r"(?:https?:\/\/)?(?:www\.)?youtube\.com\/v\/([a-zA-Z0-9_-]+)",
17+
r"(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([a-zA-Z0-9_-]+)(?:[?&/]|$)" # Deprecated /v/ links
1718
]
1819
for pattern in patterns:
1920
match = re.search(pattern, url)
2021
if match:
22+
logger.info(f"Extracted video ID: {match.group(1)} from URL: {url}")
2123
return match.group(1)
2224
return None
2325

0 commit comments

Comments
 (0)