fix(share): self-host og:image so link previews stay reliable
A remote thumbnail as og:image is unreliable for the crawler — Facebook's signed
CDN URL expires (so an old shared link's image later vanishes) and cross-origin
hotlinking is flaky. Record a self-hosted poster for EVERY download (ensure_poster
returns the existing <base>.jpg thumbnail sidecar, or cuts a frame) and point
og:image at our own /api/public/watch/{token}/poster.jpg. Backfill now fills
poster_path for all existing downloads, not just thumbnail-less ones.
This commit is contained in:
parent
8b02b41059
commit
b63b3334d6
4 changed files with 17 additions and 11 deletions
|
|
@ -50,11 +50,14 @@ def _watch_tags(token: str, db: Session) -> str | None:
|
|||
return None
|
||||
title = (job.display_name or asset.title or "Video").strip()
|
||||
channel = (job.display_uploader or asset.uploader or "").strip()
|
||||
# Prefer the source thumbnail; fall back to our generated poster (absolute, token-gated URL) so
|
||||
# even a thumbnail-less video (e.g. a reddit clip) unfurls with an image. (This block only runs
|
||||
# for non-password links, so the poster needs no grant.)
|
||||
image = asset.thumbnail_url or (
|
||||
f"{settings.app_base}/api/public/watch/{token}/poster.jpg" if asset.poster_path else None
|
||||
# Prefer our self-hosted poster for the link-preview image: a remote thumbnail (Facebook's
|
||||
# signed CDN URL especially) expires and isn't reliably fetchable cross-origin by the crawler.
|
||||
# (This block only runs for non-password links, so the poster needs no grant.) Fall back to the
|
||||
# remote thumbnail only if we somehow have no poster.
|
||||
image = (
|
||||
f"{settings.app_base}/api/public/watch/{token}/poster.jpg"
|
||||
if asset.poster_path
|
||||
else asset.thumbnail_url
|
||||
)
|
||||
tags = [
|
||||
f"<title>{html.escape(title)}</title>",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue