Files
Andre 94965512fe fix: detect youtube shorts and live urls as video sources
Only the classic watch URL was recognised, so a shorts link fell through
to the website extractor. That path fetches the page, finds no recipe
markup in what is a JavaScript shell, and hands the raw text to the
language model, which returns an empty recipe titled "null" — stored in
the history as an apparently successful extraction rather than an error.

Shorts are among the most common formats for recipe clips, so the
failure mode was both frequent and silent. Live URLs share the pattern.
2026-08-14 16:32:27 +02:00

25 lines
606 B
Python

"""Platform detection: decides whether a URL is a video or a website."""
import re
VIDEO_PATTERNS = [
r"youtube\.com/watch",
r"youtube\.com/shorts/",
r"youtube\.com/live/",
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))