Resolve external embed previews and keep their real MIME types

This commit is contained in:
Fisto
2026-09-16 12:52:44 +02:00
parent 7fa6118b6f
commit 1b5fcfed2f
11 changed files with 313 additions and 41 deletions
+9 -3
View File
@@ -86,9 +86,15 @@ media-scrape/db/
owns that path.
- Third-party embeds are **never downloaded as media**: YouTube, Instagram, X, TikTok, and every
other embed stays a link. Its thumbnail is cached (below); the video itself is never fetched.
- Previews are cached small (WebP, 320px) in `thumbs/` after every walk, in both modes: Discord
hosted images and GIFs, and third-party embed thumbnails (YouTube, X, TikTok, and so on), so the
grid does not depend on expiring CDN links. Previews count toward the storage limit.
- Previews are cached in `thumbs/` after every walk, in both modes: Discord-hosted images and GIFs
(resized to 320px WebP) and third-party embed thumbnails (YouTube, X, TikTok, and so on). The
stored bytes keep their real type (`preview_ext`), so JPEG provider thumbnails are served as
`image/jpeg`, not mislabeled WebP. Embeds without a thumbnail in Discord's data are resolved
through the provider's oEmbed/fxtwitter API and finally the page's `og:image`. Previews count
toward the storage limit.
- The grid never renders an embed's page URL as media. A direct video file without a preview shows
a first-frame `<video>` only for playable containers (mp4, webm, m4v); anything else shows a
labeled placeholder, and a failed image falls back to that placeholder.
- Every item records who posted it, when, and its dimensions: `author_id`, `author_name`,
`posted_at`, `width`, `height`, and `aspect_ratio`. In `download` mode a missing resolution is
filled in with `ffprobe` after the file lands.