fix: extract_youtube_id crashes on a non-string url instead of returning None (#1689)
This commit is contained in:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user