mirror of
https://github.com/Andre-Bzk/Rezept0r.git
synced 2026-11-15 09:33:05 +01:00
23 lines
550 B
Python
23 lines
550 B
Python
"""Platform detection: decides whether a URL is a video or a website."""
|
|
import re
|
|
|
|
VIDEO_PATTERNS = [
|
|
r"youtube\.com/watch",
|
|
r"youtu\.be/",
|
|
r"tiktok\.com/",
|
|
r"instagram\.com/reel",
|
|
r"instagram\.com/p/",
|
|
r"vimeo\.com/",
|
|
r"twitch\.tv/",
|
|
r"twitter\.com/.+/status",
|
|
r"x\.com/.+/status",
|
|
r"facebook\.com/.*video",
|
|
r"reddit\.com/r/.*/comments", # reddit video posts
|
|
]
|
|
|
|
_VIDEO_RE = re.compile("|".join(VIDEO_PATTERNS), re.IGNORECASE)
|
|
|
|
|
|
def is_video_url(url: str) -> bool:
|
|
return bool(_VIDEO_RE.search(url))
|