Cache audio waveforms and rescue oversized GIF previews

This commit is contained in:
Fisto
2026-09-16 23:48:17 +02:00
parent caf9b7db3a
commit 8f30ec14ad
7 changed files with 123 additions and 5 deletions
+6 -1
View File
@@ -130,7 +130,12 @@ Previews run after every walk:
10 s timeout, one attempt).
- Animated GIF previews are stored as a static first frame (`ffmpeg`, 480px WebP); the original
animated GIF URL stays in `preview_url` for hover playback. Tenor embeds without a thumbnail are
resolved through Tenor's oEmbed.
resolved through Tenor's oEmbed. An animated GIF over the size cap is framed by ffmpeg reading
the stream directly, so it is not lost to `too large`.
- Audio attachments and voice messages get a waveform strip
(`ffmpeg -filter_complex showwavespic`) as their preview, rendered by ffmpeg from the URL.
- Transient network failures are left pending for the next backfill pass; only skips (4xx, too
large, no source) are marked permanent.
- One attempt per row, no retries; a failure marks `preview_error` and never fails the scrape.
- Stored by hash in `thumbs/<sha256>.<ext>`, where the extension follows the response type
(`preview_ext`, default webp); `preview_hash` and `preview_bytes` land on the row, and the
+3 -2
View File
@@ -91,8 +91,9 @@ media-scrape/db/
- 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 in `thumbs/` after every walk, in both modes: Discord-hosted images, GIFs,
and video files (the proxy renders a frame, resized to 320px WebP) plus third-party embed
thumbnails (YouTube, X, TikTok, and so on). The
and video files (the proxy renders a frame, resized to 320px WebP), third-party embed thumbnails
(YouTube, X, TikTok, and so on), and audio, which gets a waveform strip so audio tiles are not
blank. 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