Python bindings for ytdown: extract, select, and download media (yt-dlp core in Rust).
Project description
ytdown (Python bindings)
Python bindings for the ytdown Rust
crate: extract, select, and download media — yt-dlp's core, library only.
Built with maturin / PyO3. The API is synchronous; blocking calls release the GIL and run on a shared tokio runtime.
Install
pip install maturin
maturin develop --release # from this directory, inside a venv
# or build a wheel:
maturin build --release
Quickstart
from ytdown import Ytdown, VideoInfo
yt = Ytdown()
info = yt.resolve("https://youtu.be/dQw4w9WgXcQ")
if isinstance(info, VideoInfo):
fmt = info.select().best_progressive()
yt.download(
fmt,
"out.mp4",
progress=lambda p: print(f"{p.percent():.1f}%" if p.percent() else "..."),
)
Format selection
VideoInfo.select() returns a chainable FormatSelector mirroring the Rust
API:
fmt = info.select().progressive().max_height(720).best_video()
audio = info.select().audio_only().best_audio()
video, audio = info.select().best_video_audio()
fmt = info.select().by_itag(22)
Playlists, channels, search
Collections are lazy iterators; pages are fetched on demand:
from ytdown import Collection
result = yt.resolve("ytsearch:rust programming")
if isinstance(result, Collection):
for entry in result:
print(entry.id, entry.title)
full = yt.resolve(entry.url) # resolve the full item
break
Merged (split-stream) downloads
Requires ffmpeg on PATH (or pass ffmpeg_binary= to Ytdown):
video, audio = info.select().best_video_audio()
yt.download_merged(video, audio, "out.mp4")
Download options
yt.download(
fmt,
"out.mp4",
progress=on_progress, # callable(Progress) -> None
concurrency=4, # parallel range-chunk connections
chunk_size=10 * 1024 * 1024, # bytes per chunk (parallel mode)
retries=3,
resume=True, # resume from existing partial file
)
Errors
All errors derive from ytdown.YtdownError:
UnsupportedUrlError, NetworkError, ExtractionError, UnavailableError,
CipherError, FormatNotFoundError, IoError, PostprocessError.
from ytdown import YtdownError, FormatNotFoundError
try:
fmt = info.select().audio_only().by_itag(9999)
except FormatNotFoundError:
...
Releasing to PyPI
Releases are automated. When a release-please PR is merged on master:
- release-please tags the release and bumps the version in both
Cargo.tomlfiles (ytdown-py/Cargo.tomlis synced via thex-release-please-versionannotation). .github/workflows/release-please.yamlpublishes the crate to crates.io, then builds wheels (Linux x86_64, macOS aarch64) viaPyO3/maturin-actionand publishes them to PyPI.
No sdist is published (maturin can't vendor the path = ".." dependency
cleanly). On platforms without a wheel, install from git instead:
pip install "git+https://github.com/4thel00z/ytdown#subdirectory=ytdown-py"
Authentication uses PyPI Trusted Publishing
(OIDC) — no token secret. One-time setup on pypi.org for the ytdown project:
- Owner:
4thel00zRepository:ytdown - Workflow name:
release-please.yaml - Environment: (leave empty)
License
MIT OR Apache-2.0, same as the Rust crate.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ytdown_py-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ytdown_py-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a10cc00116a87acfc0668a01890de5a25d94060212f3d37ea0633722d64827e3
|
|
| MD5 |
1d9613355860bc6881f655d90a01cdb3
|
|
| BLAKE2b-256 |
65993779451b7009f965dc3f87d0ad5df34b7d961316c6320f3ce92d876e77c1
|
Provenance
The following attestation bundles were made for ytdown_py-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-please.yaml on 4thel00z/ytdown
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ytdown_py-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
a10cc00116a87acfc0668a01890de5a25d94060212f3d37ea0633722d64827e3 - Sigstore transparency entry: 1734562428
- Sigstore integration time:
-
Permalink:
4thel00z/ytdown@e9b872b5973435b692bb4c677793e5008de8aaf8 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/4thel00z
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yaml@e9b872b5973435b692bb4c677793e5008de8aaf8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ytdown_py-0.3.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: ytdown_py-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70a22be5f8b2a8b7268aab003924c0f073afe0716e95e268e4c34cd16f9e85d9
|
|
| MD5 |
5c2a6ee0d1eeb169fb9a5cfd669f3e4e
|
|
| BLAKE2b-256 |
354e433b947d9efc1e6376dbd4d3a717a83c916eb136de163f3a05b445903bd4
|
Provenance
The following attestation bundles were made for ytdown_py-0.3.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release-please.yaml on 4thel00z/ytdown
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ytdown_py-0.3.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
70a22be5f8b2a8b7268aab003924c0f073afe0716e95e268e4c34cd16f9e85d9 - Sigstore transparency entry: 1734562456
- Sigstore integration time:
-
Permalink:
4thel00z/ytdown@e9b872b5973435b692bb4c677793e5008de8aaf8 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/4thel00z
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yaml@e9b872b5973435b692bb4c677793e5008de8aaf8 -
Trigger Event:
workflow_dispatch
-
Statement type: