fixed regex

This commit is contained in:
tcsenpai 2025-05-23 10:17:52 +02:00
parent 5418b3b1e6
commit 5d41615a40

View File

@ -8,11 +8,7 @@ from urllib.parse import urlparse, parse_qs
def is_youtube_url(url: str) -> bool:
"""Check if the URL is a valid YouTube URL."""
youtube_regex = (
r"(https?://)?(www\.)?"
"(youtube|youtu|youtube-nocookie)\.(com|be)/"
"(watch\?v=|embed/|v/|.+\?v=)?([^&=%\?]{11})"
)
youtube_regex = r"(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/(watch\?v=|embed/|v/|.+\?v=)?([^&=%\?]{11})"
return bool(re.match(youtube_regex, url))