Skip to content
프로젝트

Make-It-Goddamn-Work/ytgrab-rs has 16 GitHub stars and 2 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-25 05:26 UTC. Last push 2026-11-22.

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

소개

A fast YouTube downloader written in Rust. Speaks the InnerTube API directly — no browser, no HTML scraping, no JS engine.

창작 및 미디어

README.md

Original

ytgrab

A YouTube downloader written in Rust. Talks to YouTube's internal InnerTube JSON API directly — no browser, no HTML scraping, no JS interpreter.

ytgrab "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

Not affiliated with the yt-dlp project. This is an independent implementation written from scratch; yt-dlp is Python and stays the more feature-complete tool.

Why it's fast

  • No Chromium and no external JavaScript runtime. The binary is ~11 MB and starts instantly.
  • The ANDROID InnerTube client returns unciphered googlevideo.com URLs, so there is no signature deciphering and no PO token to obtain. (The WEB client requires both, which is why browser-based downloaders need a whole JS engine.)
  • Parallel byte-range downloads. YouTube throttles a single connection to roughly 250 kB/s but serves parallel Range requests at full speed, so large files are split into 8 ranges automatically.

Measured on the same machine, same videos, back to back:

yt-dlp ytgrab
720p (26 MB) 8.0 s 2.0 s
1080p (77 MB) 14.7 s 4.4 s
4K (342 MB) 25.1 s 15.9 s
1080p (944 MB), Android client refused 51.8 s 37.8 s

The last row is the interesting one: googlevideo refuses that video's high quality formats for the Android client, so ytgrab switches to the TV client, solves the challenge and still delivers the full 944 MB at 1080p.

Two things make the difference:

  • Parallel byte ranges. YouTube throttles a single connection to roughly 250 kB/s but serves parallel Range requests at full speed.
  • 8 MiB requests. The server shapes the bandwidth of a long request: 8 MiB chunks ran at 18.8 MB/s while 15 MiB chunks collapsed to 3.2 MB/s. The chunk size and the number of connections were measured against each other; 8 MiB with 8 connections is the optimum. --chunk-size and --fragments let you go further if your connection likes it.

The parallel path was verified to produce byte-identical output to the sequential one (sha256 match).

Install

cargo install --git https://github.com/fitzypopper/ytgrab-rs

Or from source:

cargo build --release
./target/release/ytgrab --help

Requires ffmpeg on PATH for muxing and audio extraction.

Usage

# best available (video + audio, muxed to mp4)
ytgrab "https://youtu.be/dQw4w9WgXcQ"

# pick a resolution
ytgrab -f "bestvideo[height<=1080]+bestaudio" URL

# audio only
ytgrab -x --audio-format mp3 URL

# inspect what is available
ytgrab --list-formats URL
ytgrab --get-url URL
ytgrab --dump-json URL

# sidecar files
ytgrab --write-subs --write-auto-subs --write-thumbnail --write-info-json URL

# output template (yt-dlp syntax)
ytgrab -o "%(playlist_index)s - %(title)s.%(ext)s" URL

# whole playlist
ytgrab --playlist "https://www.youtube.com/playlist?list=PL..."

# 8 parallel segments per stream
ytgrab --fragments 8 URL

Format selectors

Selector Meaning
best best video + best audio (default)
worst lowest quality
bestvideo / bv best video-only stream
bestaudio / ba best audio-only stream
137 a format id (itag), falling back to "at most 137p" if no such id exists
1080 best video at or below 1080p
bestvideo[height<=720] filters: height, fps, tbr, ext, vcodec, acodec, filesize
bv[ext=mp4][height<=1080]+ba parts are joined with +

Audio codec follows the video container: H.264 gets AAC (.mp4), VP9 gets Opus (.webm). --prefer-opus forces Opus everywhere.

How it gets the video URLs

YouTube serves different clients differently. ytgrab tries the Android client first because it needs no JavaScript and no PO token — but it only serves some formats.

When googlevideo refuses a format (a 403 that means "range too large", not "expired"), ytgrab switches to the TV client. That client's URLs carry a throttling challenge (n=) which is a puzzle solved by a function inside YouTube's player JavaScript. ytgrab downloads base.js and runs it in an embedded QuickJS engine — the same solver yt-dlp uses, vendored from yt-dlp/ejs (Unlicense) — so deno, node and bun do not need to be installed.

$ ytgrab -f 137 "https://youtu.be/JBoUwElRFVM"
googlevideo refused format 137 (HTTP 403); retrying through the TV client
Saved tv137.mp4                                  # 944 MB, 1080p

Interrupted downloads

Downloads are resumable. The bytes land in a .part file first and are renamed when the file is complete, so an interrupted run leaves a partial file behind instead of a broken one:

$ ytgrab -f 137 "https://youtu.be/JBoUwElRFVM"      # killed halfway
$ ytgrab -f 137 "https://youtu.be/JBoUwElRFVM"      # picks up where it stopped

The restart continues with a Range request from the byte it already has. A connection that dies mid-transfer is retried the same way, and the chunk size is halved if the server refuses the request.

There are tests for this in tests/resume.rs: a local server that drops every third connection, a download that starts with half the file already on disk, and a check that the parallel and sequential paths produce identical bytes.

What gets cached

The TV client needs a watch page, the player script and a parse of it before it can be used. None of that changes between runs, so it is cached in ~/.cache/ytgrab/:

$ ytgrab -f 137 "https://youtu.be/JBoUwElRFVM"     # 39.7s (cold)
$ ytgrab -f 137 "https://youtu.be/JBoUwElRFVM"     # 33.4s (warm cache)

A cached visitor id that has gone stale is detected (the server answers LOGIN_REQUIRED) and refreshed automatically.

Keeping track of what you already have

ytgrab --download-archive archive.txt --playlist "https://youtube.com/playlist?list=..."

The archive is a plain text file, one line per video:

youtube dQw4w9WgXcQ Never Gonna Give You Up

Videos already in it are skipped before a single request is made, and new ones are appended as they finish.

Picking videos and formats

ytgrab --match-filter "Minecraft" --playlist "https://youtube.com/playlist?list=..."
ytgrab --match-filter "!Trailer" --playlist "..."        # invert it
ytgrab --max-filesize 100M "https://youtu.be/..."        # skip the 4K versions
ytgrab --min-filesize 10M "https://youtu.be/..."
ytgrab --no-overwrites "https://youtu.be/..."            # keep what is there
ytgrab --sleep-requests 2 --playlist "..."              # be nice to the server

Looking without downloading

ytgrab --list-formats "https://youtu.be/..."       # what is on offer
ytgrab --get-title --playlist "https://..."        # just the titles
ytgrab --get-duration --skip-download "https://..."
ytgrab --print "%(id)s\t%(title)s\t%(duration)s" --playlist "..."
ytgrab --dump-json "https://youtu.be/..."          # everything, as JSON

%(duration)s is in seconds and %(duration_string)s is formatted (3:33), the same as yt-dlp.

Cookies

ytgrab --cookies cookies.txt URL              # Netscape export
ytgrab --cookies-from-browser brave URL       # chrome, brave, chromium, edge, firefox

Browser cookies on Linux live in the OS keyring, so a running D-Bus session and an unlocked keyring are required (secret-tool is used under the hood).

Current state

Working: format listing and selection, segmented/resumable downloads, ffmpeg muxing, audio extraction, subtitles (SRT/VTT), thumbnails, info JSON, playlists, output templates.

Not yet: cookie support (the file is parsed, but browser cookie extraction is missing), format-specific rate limiting, DASH manifest support, DRM.

See PROJECT_NOTES.md for the InnerTube details and the remaining work.

관련 프로젝트 살펴보기

불러오는 중…