Assemble video-link import: async pipeline, premium gate, cost controls#89
Merged
Conversation
Wire the merged video foundation (cache/quota/config #86, ScrapeCreators client #87, ffmpeg frame sampler #88) into a working end-to-end import: - VisionProvider.ExtractRecipesFromMedia now takes a contextText arg so a video's transcript+caption are extracted alongside the sampled frames. - ImportService.StartVideoImport accepts a social/video URL, creates an async VideoImport job, and processes it in a goroutine: fetch meta -> per-video cache check -> daily-budget kill switch -> SSRF-guard the scraper media URL -> sample frames -> multimodal extract (frames + transcript/caption) -> save recipe -> cache for the next importer. - Cost controls: process-once VideoExtractionCache (viral videos cost $0 after the first), per-user monthly quota (free 2 / premium 20), a global daily-budget kill switch, and a feature flag that keeps the endpoint dark until SCRAPECREATORS_API_KEY is set. - Endpoints: POST /v1/recipes/import/video (premium-gated, returns a queued job) and GET /v1/recipes/import/video/:id (owner-only status poll). - Fix: monthly usage reset now also zeroes VideoImportsUsed in-memory; mock user repo handles the video_imports_used column for parity with prod. Tests: service-level orchestration (fresh/cache-hit/budget/fetch-fail) and handler-level (gate 403, unconfigured 503, bad platform 400, accept+poll 202->done, non-owner 404), all offline and race-clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BU4UWZutHd1AnK3XAf7H19
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
PR2c — the final assembly of the video-link import feature (Phase 2.5). It wires the three merged foundation PRs into a working end-to-end pipeline behind a paywall:
A user pastes a TikTok/Instagram/YouTube/Facebook/Pinterest link; we pull the caption + transcript + a downloadable copy of the video, sample representative frames, and run a single multimodal Claude extraction over frames + transcript/caption together to reconstruct the recipe.
Pipeline (async)
POST /v1/recipes/import/video→ premium gate → create job → return202 {job}.Goroutine:
FetchVideo→ per-video cache check → daily-budget kill switch → SSRF-guard the scraper media URL →Sampleframes →ExtractRecipesFromMedia(frames, transcript+caption)→ save recipe → cache the extraction.GET /v1/recipes/import/video/:id→ owner-only status poll (returnsrecipe_idwhen done).Cost controls ("don't let users bleed me")
VideoExtractionCache, keyedplatform:video_id): a viral video is extracted once; every later importer is served from cache at $0.CanUseVideoImport).SUM(cost_usd)since UTC-midnight reachesVIDEO_IMPORT_DAILY_BUDGET_USD(default $25).503untilSCRAPECREATORS_API_KEYis configured — ships dark.Notable decisions
VisionProvider.ExtractRecipesFromMediagained acontextTextarg (transcript/caption);ImportFromFilespasses"".ValidateExternalURLbefore the sampler fetches it. Follow-up: harden the sampler's HTTP client against redirect-hop rebinding (the validator is TOCTOU-imperfect on its own).VideoImportsUsedin-memory.Tests
All offline and race-clean (
go test ./... -race):403, unconfigured503, bad platform400, accept202+ poll →done, non-owner404.Deploy note (not in this PR)
At deploy, add
SCRAPECREATORS_API_KEYto the prod ECS task definition to switch the feature on, then run a real TikTok end-to-end check. Only TikTok is implemented in the client so far; IG/YouTube/Facebook/Pinterest detect but return "not yet supported".🤖 Generated with Claude Code
https://claude.ai/code/session_01BU4UWZutHd1AnK3XAf7H19