Skip to content

Media and download pipeline

Pinchana Web deliberately keeps normal scrape media and YouTube DLP as two different pipelines.

API v1 returns one ordered data.media array. Each item has a type (image, video, or audio), a semantic role (content, soundtrack, or cover), an index, and optional preview/dimension/duration/title/artist metadata.

Web rewrites protected API /web/media/... paths to same-origin /api/media/.... Preview elements use ordinary <img>, <video>, and <audio> requests against those routes.

Next.js image optimization is intentionally not used for authenticated media: an optimizer-side fetch would not carry the visitor’s HttpOnly Pinchana web-session cookie to the upstream API.

For normal scrape results, Web derives files from the normalized media list rather than depending on platform-specific response shapes.

  • Track-like music results become ordered audio downloads.
  • Carousels retain ordered image/video content.
  • Slideshow soundtracks and cover art retain their semantic roles.
  • A single result prefers its primary content media.

The same normalized contract is used across TikTok, Instagram, Shorts, SoundCloud, YouTube Music, Spotify, Deezer, Threads, and Twitter/X.

Pinchana Web bundles FFmpeg WebAssembly assets locally under public/ffmpeg/. For normal scrape Audio mode it can fetch an authenticated media asset, select its first audio stream, remove video, and encode MP3 entirely in the browser.

Temporary FFmpeg virtual files and object URLs are cleaned after use. If no audio stream is available, Web falls back to the original Media mode instead of producing an invalid file.

No external FFmpeg CDN is needed at runtime.

When multiple normal-pipeline files are selected and ZIP is enabled, client-zip is loaded dynamically and builds an archive in browser memory. With ZIP disabled, each item triggers its own save.

Object URLs used for browser saves are temporary and revoked after the download handoff.

The API models animated Twitter/X posts as efficient looping video. If Convert Twitter GIFs is enabled, Web asks the authenticated API conversion route to convert an already-cached media asset to GIF under bounded FFmpeg limits.

The conversion endpoint does not accept arbitrary uploads or remote URLs; it operates on authenticated cached media.

Ordinary YouTube URLs bypass the normal preview/Blob pipeline when DLP v2 is available.

Web allocates/submits a DLP job through /api/dlp/jobs, polls state, and when ready exposes /api/dlp/jobs/{jobId}/file to the browser download manager. The same-origin file route forwards range requests and preserves download metadata such as content length, content range, type, disposition, ETag, and last-modified.

This lets a large completed DLP artifact stream through the server instead of being fully loaded into browser JavaScript memory.

Cookie Vault data, when explicitly selected, is encrypted to the job worker before the BFF receives the submission. See DLP protocol v2 for that cryptographic flow.