Skip to main content

Official Python SDK for the VidPickr API — download YouTube videos with one function call.

Project description

vidpickr

Official Python SDK for the VidPickr API. Download YouTube videos with a single function call.

from vidpickr import VidPickr

vp = VidPickr(api_key="vpk_live_...")
vp.download(
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    out="video.mp4",
    quality=1080,
)

That's it. The SDK:

  1. Resolves the URL through /api/v1/info
  2. Picks the best 1080p video track and the highest-bitrate audio track
  3. Exchanges the merge token via /api/v1/split_token
  4. Streams both tracks in parallel from /api/v1/stream
  5. Muxes them into one MP4 with ffmpeg -c copy (no re-encoding)
  6. Writes the result to video.mp4 and cleans up temp files

Requirements

  • Python 3.9+
  • A VidPickr Plus subscription ($1/mo) and an API key, minted at vidpickr.com/account/api-keys
  • ffmpeg on PATH — or use the bundled-ffmpeg extra below

Install

pip install vidpickr

If you don't have ffmpeg installed system-wide and don't want to:

pip install 'vidpickr[bundled-ffmpeg]'

That pulls imageio-ffmpeg, which ships a pre-built ffmpeg binary inside the wheel (~50 MB extra disk).

API

VidPickr(api_key, *, base_url=None, session=None)

Construct the client. session accepts a requests.Session if you want to share connection pooling or pin a User-Agent.

vp.download(url, *, out, quality='best', video_codec=None, on_progress=None) -> str

Resolve, stream, mux, and write to disk. Returns the output path.

Argument Type Default Description
out str Output MP4 path. Parent directory must exist.
quality 'best' | 'highest' | 'lowest' | int 'best' Target height (e.g. 1080) or preset.
video_codec 'av1' | 'vp9' | 'avc' | 'hevc' | None None Preferred codec when multiple are available at the same height.
on_progress Callable[[dict], None] | None None Called between phases with {"phase": ..., "video_bytes": ..., ...}.

vp.info(url) -> dict

Resolve only. Returns the VideoInfo JSON. Use when you want to inspect formats before deciding.

vp.raw

Access the low-level VidPickrClient for custom pipelines (e.g. piping audio bytes into Whisper without writing to disk).

Errors

from vidpickr import APIError, FFmpegMissingError, NoFormatError

try:
    vp.download(url, out="x.mp4")
except APIError as e:
    if e.code == "rate_limited":
        print(f"Retry in {e.retry_after}s")
    elif e.code == "plus_required":
        print("Subscribe to Plus first.")
    else:
        raise
except FFmpegMissingError as e:
    print(e)  # tells you exactly how to install ffmpeg
except NoFormatError as e:
    print(f"Requested format unavailable: {e}")

Subtitles

info = vp.info(url)
en_track = next(s for s in info["subtitles"] if s["code"] == "en" and not s["is_auto"])
srt = vp.raw.subtitle(en_track["download_token"], fmt="srt")
with open("captions.srt", "w", encoding="utf-8") as f:
    f.write(srt)

Why no Rust extension yet?

The 0.1.0 release uses ffmpeg as a subprocess — fastest path to a working SDK. A future release will ship a tiny Rust extension via PyO3 for in-process MP4 muxing, dropping the ffmpeg dependency entirely (target install footprint ~500 KB instead of 50 MB).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vidpickr-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vidpickr-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file vidpickr-0.1.0.tar.gz.

File metadata

  • Download URL: vidpickr-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for vidpickr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 615aa2175ac4f0e19b48fcc223afe0e1d61287ca8f82baf8e81c1873360e1334
MD5 1b1be919e858b92a6a8aa7de38e01a26
BLAKE2b-256 beedac3def618ff15d3a585963524f3f8baf93c9a4a371b4c87f84d5e37c287f

See more details on using hashes here.

File details

Details for the file vidpickr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vidpickr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for vidpickr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8c8d951558f4203c2f58a402deb0de01a1847b6256efdea6858ba00558b2b4f
MD5 64675a544a93d77b066ef522565a6b90
BLAKE2b-256 33149c295d5602ddacc500527ae9a8abe028f6dd1e42933441a4859e44e1f9d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page