fix: extract_youtube_id crashes on a non-string url instead of returning None (#1689)

This commit is contained in:
Afonso Coutinho
2026-06-03 05:38:11 +01:00
committed by GitHub
parent 35b9509da3
commit 13f0171ce8
2 changed files with 17 additions and 0 deletions

View File

@@ -66,6 +66,8 @@ def is_youtube_url(url: str) -> bool:
def extract_youtube_id(url: str) -> Optional[str]:
"""Extract YouTube video ID from various URL formats."""
if not isinstance(url, str):
return None
parsed = urllib.parse.urlparse(url)
if parsed.hostname in ("www.youtube.com", "youtube.com", "m.youtube.com"):
if parsed.path == "/watch":