From 686dabfc75bf974ab1db49a10824ef2b990002bd Mon Sep 17 00:00:00 2001 From: Michael Stahnke Date: Tue, 17 Feb 2026 22:19:25 -0600 Subject: [PATCH] fix: improve YouTube soft 404 detection Treat empty title after stripping " - YouTube" suffix as a soft 404. YouTube now returns " - YouTube" instead of "YouTube" for missing videos, bypassing the old check. --- internal/handler/preview_youtube.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/handler/preview_youtube.go b/internal/handler/preview_youtube.go index db185dc..7255e02 100644 --- a/internal/handler/preview_youtube.go +++ b/internal/handler/preview_youtube.go @@ -34,9 +34,15 @@ func (h *Handler) GetYouTubePreview(targetURL string) (map[string]string, error) title = strings.TrimSuffix(title, " - YouTube") meta["title"] = title - // If scrape yielded no real title or image, fall through to OEmbed + // Empty title after stripping suffix means the page had no real video title + // (e.g. " - YouTube"), which is another form of YouTube's soft 404. + if title == "" { + return nil, fmt.Errorf("status 404") + } + + // If scrape yielded no image, fall through to OEmbed // which is more reliable for YouTube - if title == "" || meta["image"] == "" { + if meta["image"] == "" { return nil, fmt.Errorf("incomplete scrape, falling back to oembed") } -- 2.51.2