rstube
A terminal app for playing YouTube videos through mpv, with per-video
position tracking and playlist-aware pickers.
What it does
- Reads one or more YouTube playlists and/or individually-configured videos you’ve set up.
- Shows a TUI picker to pick something to watch — filtered by what you haven’t seen yet, or unfiltered, or only videos you were partway through.
- Launches
mpvwith the right resume position. - Records where you left off so you can resume next time.
- Lets you forget a video you’ve watched so it cycles back into the “new” pool.
What it doesn’t do
- Download videos. It streams through mpv via
yt-dlp. - Talk to the YouTube API for authenticated data. Your YouTube account’s per-video watch progress isn’t accessible; rstube tracks positions locally from mpv sessions only.
- Manage mpv itself. Keybindings, output config, subs — that lives in your
~/.config/mpv/. See mpv configuration.
How it works
yt-dlp --flat-playlistfetches a playlist’s video list in ~1s. Cached to$XDG_STATE_HOME/rstube/playlist_cache.jsonfor 24 hours.- The TUI picker (ratatui + crossterm) shows the filtered list.
- On Enter, rstube spawns
mpv <url> --start=<resume-secs>and streams mpv’s IPC to write the current position to$XDG_STATE_HOME/rstube/positions.redb. - On mpv exit, a line is appended to
history.jsonl.
Requirements
mpv(system package)yt-dlp(Python package)
Run rstube install-deps to install whichever is missing.
Installation
Download a pre-built binary
Pre-built binaries are published for each tagged release on GitHub.
# x86_64 linux
gh release download --repo veltzer/rstube \
--pattern 'rstube-linux-x86_64' --output rstube --clobber
# aarch64 linux
gh release download --repo veltzer/rstube \
--pattern 'rstube-linux-aarch64' --output rstube --clobber
chmod +x rstube
sudo mv rstube /usr/local/bin/
Build from source
git clone https://github.com/veltzer/rstube.git
cd rstube
cargo build --release
sudo install -m 755 target/release/rstube /usr/local/bin/
Requires a reasonably recent stable Rust (see rust-toolchain.toml).
Install runtime dependencies
rstube shells out to two tools:
mpv— video playeryt-dlp— fetches the playlist and resolves video URLs
Install whatever is missing:
rstube install-deps
This auto-detects your package manager (apt-get, dnf, pacman, or
zypper) for mpv, and prefers pipx over pip --user for
yt-dlp. Already-installed tools are left alone.
If you’d rather install manually:
# Debian/Ubuntu
sudo apt-get install -y mpv
pipx install yt-dlp
# Arch
sudo pacman -S --noconfirm mpv
pipx install yt-dlp
Install shell completion
Bash:
rstube complete bash > ~/.local/share/bash-completion/completions/rstube
Or source it on the fly:
source <(rstube complete bash)
Other shells — zsh, fish, elvish, powershell — are supported the same way. See shell completion.
Getting Started
A five-minute walkthrough.
1. Add a playlist
Grab a YouTube playlist URL (must be public or unlisted — rstube doesn’t do authenticated fetches) and add it under a short name:
rstube playlists add chess "https://www.youtube.com/playlist?list=PLABCDEF..."
You can pass a bare playlist id instead of a full URL:
rstube playlists add chess PLABCDEF...
List what you’ve got:
rstube playlists list
2. Play something new
rstube play new
This fetches the playlist (first run — cached afterwards), filters out videos you’ve already watched, and opens a TUI picker. Pick one with Enter, and mpv launches.
If every configured playlist has nothing unseen, you’ll get a clear message rather than a silent no-op.
3. Resume a video you started
rstube play partial
Shows videos in your watch history where you’re partway through (at least 10 seconds in, and not within 30 seconds of the end). Enter resumes at your last position.
4. Browse anything
rstube play any
Every video from every configured playlist in one picker — no history filtering. Useful for rewatching, or when you can’t remember which playlist a video was in.
5. See what’s where, as text
show mirrors play but prints to stdout instead of opening a picker —
pipeable to grep, wc, anything:
rstube show new # every unwatched video
rstube show partial # every partially-watched video
rstube show finished # titles of finished videos (add -d for details)
6. Forget a video
If you want a video to re-appear as “new” (e.g. to rewatch from scratch):
rstube forget partial # picker over partial videos
rstube forget finished # picker over finished videos
Select with Enter; the video’s history lines and saved position are
removed. It’ll show up in play new again next time.
7. Useful extras
--refreshonplay neworplay anybypasses the 24h cache and refetches from YouTube.rstube playlists fetchpre-warms the cache for all configured playlists. Nice as a cron/systemd-timer job.rstube videos add <url-or-id>bookmarks a single video so it shows up inplay new,play any, andshow newalongside your playlists. Passing a URL with?t=178(or--start 2:58) seeds it as a partial starting at that offset. See Videos.- In any picker:
/to filter,ato toggle audio-only playback,dto delete the current row from history,qto quit. - Pass
-v/--verboseto anyplaysubcommand to see mpv’s terminal status line and verbose log — useful for debugging a stream that isn’t playing.
Commands
Top-level commands in rstube.
| Command | Description |
|---|---|
rstube play partial [-v] | Pick a partially-watched video from history |
rstube play new [--refresh] [-v] | Pick an unwatched video from anywhere in your configured playlists and videos |
rstube play any [--refresh] [-v] | Pick any video across all configured playlists and videos |
rstube show finished [-d] | Print videos watched to the end (-d adds timing/percentage) |
rstube show partial | Print videos partially watched (same set as play partial) |
rstube show new [--refresh] | Print videos in your playlists/videos list that you haven’t started |
rstube forget partial | Pick a partial video and forget it (reappears as “new”) |
rstube forget finished | Pick a finished video and forget it (reappears as “new”) |
rstube history show [-n N] | Show the last N history entries (default 20) |
rstube playlists ... | Manage configured playlists (see Playlists) |
rstube videos ... | Manage individually configured videos, with optional start offsets (see Videos) |
rstube install-deps | Install missing mpv / yt-dlp |
rstube complete <shell> | Print shell completion script |
rstube version | Print build info (git sha, rustc, build time) |
play subcommands
play partial
Opens the partial picker with partially-watched videos — defined as any history entry where the saved position is ≥ 10 seconds and more than 30 seconds before the end. If there are no such entries, prints a clear message and exits.
play new
- Merges every video from every configured playlist and every configured
video into one picker, filtered to show only videos not in your watch
history. Same underlying set as
show new. --refresh— bypass the 24h cache and refetch all sources.- If nothing is unseen, prints a message and exits.
play any
- Merges every video from every configured playlist and every configured video into one picker (deduplicated by video id).
- Does not filter by watch history — useful for rewatching.
--refresh— bypass the cache.
-v / --verbose (all three play subcommands)
By default rstube silences mpv’s stdout — no status line, no chatter. mpv’s stderr stays connected so real errors (yt-dlp failures, network issues) are still visible.
Pass -v to reconnect stdout and add --msg-level=all=v to the mpv
command, giving you the full status line and verbose log. Use it when
you’re debugging a stream that isn’t working.
show subcommands
Text-only siblings of the play pickers — same data, no TUI, pipeable.
show finished
Prints every video you’ve watched to within 30 seconds of the end. One line per video, deduped by video id (most recent session kept), most recent first. Default format is just the title:
<title>
Pass -d / --details to include the video id, timing, and percentage:
[pos/dur (pct%)] <id> <title>
show partial
Same set of videos play partial would show — partially watched (≥10s
in, >30s before the end).
show new
Every video across all configured playlists and individually configured
videos that isn’t yet in your history. Uses the 24h cache by default;
pass --refresh to refetch. Format:
[duration] title
Note: new counts any history entry as “seen”, including phase-1
open-session lines. If you started a video (even briefly), show new
will not list it again.
forget subcommands
Destructive: removes history and saved positions so a video re-appears as “new”. Useful when you want to rewatch something from scratch, or when a partial got “stuck” and you’d rather start over.
forget partial
Opens the same picker as play partial. Pressing Enter on a row
forgets that video (no confirmation prompt — the deliberate selection is
the confirmation). Pressing q / Esc quits without changes.
What gets deleted:
- Every line in
history.jsonlwith the selected video id. - The entry in
positions.redbfor that video.
Afterwards: the video disappears from show partial / play partial
and reappears in show new / play new (assuming it’s in a configured
playlist or videos list).
forget finished
Same mechanism, operating on the show finished set. Useful for
“I finished this but I want to watch it again later.”
Pickers — keys
↑/↓orj/k— movePgUp/PgDn— jump by 10Home/End— first / last row/— focus the filter input;EscorEnterreturns focus to the lista— toggle audio-only playback for the selected itemd— delete the selected row from history (and its saved position)Enter— play the selected itemqorEsc— quit without playing
history
Prints a compact one-line-per-entry view of recent plays:
[12:34/45:00 (27%)] Video title
-n controls the count (default 20, most recent first).
Playlists
rstube supports one or more configured YouTube playlists. Each is stored under a short name you choose.
Commands
# add
rstube playlists add <name> <url-or-id>
# remove
rstube playlists remove <name>
# show URL
rstube playlists show <name>
# list all
rstube playlists list
# refetch from YouTube (updates local cache)
rstube playlists fetch # all configured playlists
rstube playlists fetch <name> # just one
A “url-or-id” can be any of:
- A full playlist URL:
https://www.youtube.com/playlist?list=PLABCDEF - A URL with
list=...and other junk: also fine - A bare playlist id:
PLABCDEF→ normalized into a canonical URL
No duplicates
playlists add rejects a URL that’s already configured under another
name, even if you pass it in a different form (bare id vs full URL —
both normalize to the same canonical URL). The identity is the
canonical URL, not the name you choose.
Ordering
Playlists are stored as an ordered list. That order determines:
- The order
rstube playlists listprints them. - The order items appear in merged views (
play new,play any,show new) — items from the first playlist come first, then the second, and so on, with duplicates (same video id across playlists) deduped keeping the first occurrence. Individually-configured videos (see Videos) are appended after all playlists.
Since play new and friends merge everything into one picker, order
only affects presentation, not what you can reach.
Visibility
For rstube to read a playlist without authentication, it must be public or unlisted on YouTube. Private playlists are not accessible. Unlisted is usually what you want: hidden from search and your channel, but still fetchable by anyone with the link.
To change: YouTube Studio → Content → Playlists → pencil icon → Visibility.
Storage
The configured list lives in a TOML config file:
$RSTUBE_CONFIG_DIR/config.tomlif set- else
$XDG_CONFIG_HOME/rstube/config.toml - else
~/.config/rstube/config.toml
Format:
[[playlists]]
name = "chess"
url = "https://www.youtube.com/playlist?list=PLABCDEF"
[[playlists]]
name = "tutorials"
url = "https://www.youtube.com/playlist?list=PLXYZ123"
You can hand-edit this file; rstube will re-read it on every invocation.
Videos
Alongside playlists, rstube supports adding individual videos by id. A configured video is just a 1-item “source” that feeds into the same pickers and filters as playlists.
When to use videos vs playlists
- Playlist — you want every video from a YouTube playlist URL, and the list grows/shrinks as the creator updates it.
- Video — you want a specific single video to stay in your rotation regardless of which playlist (if any) it came from. Handy for one-off recommendations a friend sent you, or a video you plan to rewatch.
Both types coexist. A video id that appears in both a configured playlist and a configured videos entry is deduped on merge — you’ll only see it once.
Commands
# add (looks up title + validates the id via yt-dlp by default)
rstube videos add <url-or-id>
rstube videos add <url-or-id> --start 1:23 # override/set start offset
rstube videos add <url-or-id> --no-fetch # skip the yt-dlp lookup
# remove (accepts any URL shape or the bare id)
rstube videos remove <url-or-id>
# list all (shows cached titles if fetched)
rstube videos list
# refetch title/duration from YouTube (updates local cache)
rstube videos fetch # all configured videos
rstube videos fetch <url-or-id> # just one
A “url-or-id” can be any of:
- Full watch URL:
https://www.youtube.com/watch?v=dQw4w9WgXcQ - Watch URL with
&t=...:https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=10s - Short URL:
https://youtu.be/dQw4w9WgXcQ - Short URL with
?t=...:https://youtu.be/gl2GaCDt8BE?t=178 - Bare 11-char id:
dQw4w9WgXcQ
All shapes normalize to the same 11-char id, which is both the config identity and how you refer to a configured video later.
No duplicates
rstube rejects a videos add if the video id is already configured,
regardless of URL shape. Error:
Error: video id dQw4w9WgXcQ already configured —
remove it first if you want to re-add
To re-add (e.g. to change the offset), remove first:
rstube videos remove dQw4w9WgXcQ
rstube videos add "https://youtu.be/dQw4w9WgXcQ?t=90"
Start offsets
If the URL includes a t=... query parameter, rstube extracts the
offset and treats the video as already in progress — it will show
up in rstube play partial / show partial immediately, and when you
play it mpv starts at that offset instead of zero.
Offset values accept seconds (178, 178s), YouTube’s compound form
(2m58s, 1h2m3s), and colon form (2:58, 1:02:03).
You can also set an offset explicitly:
rstube videos add "https://youtu.be/abc..." --start 1m23s
rstube videos add "https://youtu.be/abc..." --start 1:23
rstube videos add "https://youtu.be/abc..." --start 83
If both --start and a URL t= are present, --start wins.
How to copy a timestamped URL from YouTube
- From the web UI: pause the video at the moment you want; right-click on the video itself → “Copy video URL at current time”.
- From the Share button: click Share, tick “Start at [current time]”, copy the URL shown.
- From the mobile app: Share sheet has a “Start at” toggle.
What happens at play time
- If there’s no saved position yet, playback starts at the configured offset.
- If there’s already a saved position (because you’ve played the video past the offset), the saved position wins — rstube’s own progress always beats a fresh-start hint.
- Removing a configured video clears the seeded position only if you
never played it past the offset. Real watch progress is preserved (use
rstube forget partialto wipe that too).
How configured videos flow through commands
Configured videos are appended to the merged pool after playlists:
rstube play new— one picker of every unseen video across all playlists and individually-configured videos.rstube play any— one picker of every video across the same sources, history-filtering disabled.rstube show new— text-only equivalent ofplay new.
If a configured video has already been played (appears in history), it
counts as “seen” and is filtered out of play new / show new. Use
play any or the partial/finished flow to get to it again.
Metadata fetching
By default videos add calls yt-dlp -j --no-playlist <url> to
validate the id and fetch the title and duration. This takes 1–3
seconds per add; if the id is invalid (malformed, removed, region-
locked for your network) videos add aborts and nothing is written
to config. On success the title shows up in the success line, and
videos list prints it alongside the id afterwards.
Pass --no-fetch to skip the lookup — useful for bulk-importing from
a script, or for private/unlisted videos that yt-dlp can’t reach
without cookies.
rstube videos add "https://youtu.be/abc..." # fetches + validates
rstube videos add "https://youtu.be/abc..." --no-fetch # skips, adds unconditionally
Results are cached in playlist_cache.json under a synthetic key
rstube:video:<id> for 24 hours, same TTL as the playlist cache.
Force a refresh with:
rstube videos fetch
# or
rstube play new --refresh
Storage
Stored in your TOML config alongside playlists:
[[playlists]]
name = "chess"
url = "https://www.youtube.com/playlist?list=PLABCDEF"
[[videos]]
video_id = "dQw4w9WgXcQ"
# Video with a start offset — added via `videos add ... ?t=178`
# or `--start 2:58`. Shows up as partial from 2:58.
[[videos]]
video_id = "kxopViU98Xo"
start_offset_secs = 178
Playlists still use names because YouTube playlist ids are ugly 34-char strings; videos don’t need them because the 11-char video id is memorable enough and unambiguous.
Same config file as playlists — see Playlists for the location rules.
Behavior summary
A few things about configured videos that are worth calling out explicitly, because they differ from playlists:
- No names. A configured video is identified solely by its
11-char YouTube id. There is no
videos show—videos listprints everything.removeandfetchaccept any URL shape (not just the bare id), which makes paste-from-browser work naturally. - Duplicates are rejected.
videos addbails if the resolved id is already in the config. Different URL shapes of the same video count as the same video. - Adding validates. By default
videos addcalls yt-dlp to confirm the id is real and to populate the title/duration cache. Pass--no-fetchto skip that. ?t=Nmeans “seed as partial.” A URL timestamp doesn’t just set mpv’s start flag; it also writes a position record intopositions.redb, so the video is classified as partial from the moment you add it.--startdoes the same. Remove clears the seeded position only if you never played past it — real watch progress is preserved.- Merge semantics. Configured videos are appended after
playlists in the merged pool for
play new/play any/show new. A video id that appears both in a configured playlist and in the videos list shows up once (first occurrence wins; playlists come first).
Shell completion
Bash completion for videos remove <TAB> and videos fetch <TAB>
suggests the configured video ids (read from config.toml at tab
time). See Shell completion for install details.
Watch history and resume
rstube maintains two pieces of per-video state:
- positions — where you left off on a given video id. Updated live as mpv plays, so killing the terminal doesn’t lose progress.
- history — a JSON-lines log of every playback session. Append-only.
What counts as “partial” vs “finished”
Classification is based on each video’s most recent meaningful session — “meaningful” meaning position ≥ 10 seconds, so an accidental reopen-and-immediately-quit can’t shadow a real session.
A session is:
- Partial — position ≥ 10s, and more than 30s before the end (or duration is unknown).
- Finished — duration is known and position is within 30s of the end.
- Trivial — less than 10s watched. Ignored for classification.
Each video appears in exactly one bucket at a time, based on its most recent non-trivial session. If you finish a video and then start watching it again, the new partial session immediately moves it out of the finished bucket and into partial.
rstube show partial / play partial read from the partial bucket;
show finished reads from the finished bucket.
Commands that interact with history
rstube history show [-n N]— print the last N entries. Unclean-exit sessions appear with a[unclean exit]marker.rstube play partial— pick an in-progress video to resume.rstube show partial/show finished— print text-only lists of videos classified from history + positions.rstube forget partial/forget finished— pick a video to forget. Removes all of its history lines (phase-1 and phase-2) plus the entry inpositions.redb, so the video reappears as “new”. The rewrite ofhistory.jsonlis atomic (tmp-then-rename).- Inside any picker,
dremoves only the selected entry’s saved position (leaves history intact). Lighter-weight thanforget— useful if you want the video to stop resuming but still count as “seen”.
Crash and power-loss safety
You will not lose your position if mpv crashes, your terminal is killed, or your laptop runs out of battery mid-video.
While mpv is playing, a background thread polls the current position over
mpv’s IPC socket every 30 seconds and upserts it into positions.redb.
redb commits use MVCC + fsync, so even a power cut mid-write cannot
corrupt the file — the commit either lands fully or not at all.
Worst case: you lose up to 30 seconds of progress — the time since
the last tick. rstube play partial will still show the video, and it
will start where the last tick landed.
There’s one narrow exception: if playback is killed within the first 30 seconds of starting, no tick has happened yet, so nothing new is saved. Any previous saved position for that video is left untouched — you’d resume from there, not from zero.
Unclean-exit sessions (mpv killed by crash or power loss) do appear
in rstube history show — flagged with a [unclean exit] marker. See
“Two-phase history writes” below for how.
How the tracker stays in sync with mpv
rstube does not drive mpv’s playback. mpv owns the playhead, and rstube just snapshots it.
When rstube spawns mpv it passes --input-ipc-server=<socket>, which
makes mpv expose a JSON-over-unix-socket interface. A background thread
in rstube connects to that socket and, once every 30 seconds, asks mpv
for two properties:
time-pos— the current playhead, in secondsduration— the video’s total length, in seconds (if known)
Whatever mpv reports is compared bit-for-bit against the last value
written to positions.redb. If the (time-pos, duration) pair is
unchanged, the tick is a no-op — no write transaction fires. Otherwise
the new value is upserted. The tracker doesn’t model
playing/paused/buffering state itself; the dedup naturally falls out of
“did the playhead actually move?”. That means:
- Paused: ticks keep firing, but
time-posdoesn’t move, so the bit-fingerprint matches and no redb write happens. A multi-hour pause costs zero writes. - Scrubbed: the next tick picks up the new position, the fingerprint differs, a single write fires.
- Buffering / not yet loaded: mpv returns
nullfortime-pos, and the tracker silently skips that tick — no write happens.
The comparison uses f64::to_bits equality, not a floating-point
tolerance. We only skip if mpv reported the identical float — not an
“approximately same” value — which sidesteps any question of what
counts as a meaningful move. During normal playback time-pos advances
by roughly the tick interval between samples, so bit equality never
false-positive skips a real update.
When mpv exits normally, rstube takes one final snapshot and writes the last known position and the full history entry. When mpv dies uncleanly, the last periodic snapshot is what survives.
Where positions are saved
A single local file, resolved in this order:
$RSTUBE_STATE_DIR/positions.redbif that env var is set$XDG_STATE_HOME/rstube/positions.redb$HOME/.local/state/rstube/positions.redb
On most Linux systems that’s ~/.local/state/rstube/positions.redb.
Storage is a redb key/value database. Keys are YouTube video ids (strings); values are JSON-serialized records with these fields:
position_secs— where the playhead was at the last tick (seconds).duration_secs— the total length if mpv has reported it yet, else null. Used by the partial picker to hide near-finished videos.updated_at— unix timestamp of the last tick. Not used for anything user-visible; useful when debugging.
Each tick performs a single per-key update inside a redb write transaction. redb uses MVCC + copy-on-write B-trees with an fsync’d commit, so a write either lands fully or not at all; a crash or power cut never leaves the file in a torn state.
The file isn’t human-readable, so cat won’t work. To inspect, use
redb dump (from the redb-cli crate) or any small Rust program that
opens the same table definition.
Two-phase history writes
history.jsonl uses a two-phase append scheme so that even an unclean
exit (SIGKILL, OOM kill, power loss) still leaves a record of the
session.
Phase 1 — at spawn. Before calling child.wait(), rstube appends an
open-session line: ts_start is the current time, ts_end is 0, and
position_on_exit is 0.0. The rest of the fields (video id, URL,
title, audio-only flag) are all known at spawn time. This write happens
in the first few milliseconds of a session.
Phase 2 — at clean exit. When mpv exits cleanly, rstube appends a
second line with the same (video_id, ts_start) key, this time with a
real ts_end and the final position_on_exit pulled from the last
tracker snapshot.
Read-side. load_history_sessions() in state.rs groups lines by
(video_id, ts_start) and keeps the line with the greater ts_end.
Phase-2 always replaces phase-1 for a clean session; phase-1-only
sessions (rstube/mpv died before reaching phase-2) survive as-is.
User-visible effect. rstube history show shows unclean-exit sessions
with a [unclean exit] suffix, and pulls the last-known position from
positions.redb so you can still see roughly where you were.
Why not a SIGINT / SIGTERM handler?
A signal handler would help with Ctrl-C or SIGTERM from your terminal
closing, but it is the wrong tool for the job:
- SIGKILL and SIGSTOP are unmaskable. Kernel kills (OOM), power
loss, and
kill -9bypass any handler. - Power loss gives you zero cycles. No signal at all fires.
- Real signal handlers are restricted to async-signal-safe calls — you
cannot call
serde_jsonorfs::writefrom them, which means you’d need a pipe-based wake-up pattern and a reserved writer thread. Significant complexity for partial coverage.
The two-phase approach catches all three failure modes (SIGTERM, hard kills, power loss) with no concurrency new code and no signal handling.
Why not fsync(2) after each write?
Skipped intentionally.
A write(2) to an O_APPEND file puts the data in the kernel’s page
cache. That data survives the rstube process dying for any reason
(SIGKILL, OOM kill, panic) — the kernel keeps flushing it out on its
own schedule (every 5–30s on Linux, driven by vm.dirty_*). fsync
only protects the narrow window of a kernel crash or sudden power
loss between write returning and the kernel’s flush.
For rstube specifically:
- We already tolerate ~30 seconds of position loss from the tracker’s 30s poll interval.
- A lost phase-1 line for a session whose
positions.redbentry did flush means the session is missing fromrstube history show— butplay resumestill works, because resume reads frompositions.redb. fsyncserializes IO, costing 5–50ms per write on a spinning disk; cheap on SSD but not free.
The durability we actually want — phase-1 surviving an rstube crash —
is delivered by plain write(2). Adding fsync would only close the
“power cut in the 30-second flush window” gap, which is less impactful
than the gap we just closed (unclean exit leaves no record at all).
Storage — all state files
| File | Contents |
|---|---|
positions.redb | Resume positions (see above) |
history.jsonl | One JSON line per playback session; forget rewrites to remove matching lines |
playlist_cache.json | Cached playlist item lists, keyed by URL |
All three live under the same state directory (RSTUBE_STATE_DIR →
XDG_STATE_HOME/rstube → ~/.local/state/rstube). See File layout and
environment for the full env-var story.
Safe to delete any of these — rstube recreates them on demand. Deleting
positions.redb just means play partial will be empty until you watch
something; deleting history.jsonl clears the log.
Syncing across machines
rstube doesn’t sync anywhere. If you want the same positions on another
machine, sync the state directory yourself — syncthing pointed at
~/.local/state/rstube, or a periodic rsync, or just scp ~/.local/state/rstube/positions.redb before switching machines.
Nothing rstube writes is tied to a machine or user account; the file is portable.
Playlist and video cache
yt-dlp fetches are fast but hit the network. rstube caches both
playlist item lists and single-video metadata locally, and only
refetches when the cache is more than 24 hours old.
Where
$XDG_STATE_HOME/rstube/playlist_cache.json — a single JSON file keyed
by URL.
{
"entries": {
"https://www.youtube.com/playlist?list=PL...": {
"fetched_at": 1760000000,
"items": [ { "id": "...", "title": "...", "duration": 1234 }, ... ]
},
"rstube:video:dQw4w9WgXcQ": {
"fetched_at": 1760000000,
"items": [ { "id": "dQw4w9WgXcQ", "title": "...", "duration": 213 } ]
}
}
}
Playlists live under their real YouTube URL. Individually-configured
videos (see Videos) live under a synthetic
rstube:video:<id> key — reusing the same file format keeps things
simple.
When rstube refetches
- On any
play new/play any/show newrun where the cached entry is ≥ 24 hours old or missing. - On every run when
--refreshis passed. - On every
rstube playlists fetchorrstube videos fetch.
Cache hits print a one-line note including the item count and age:
Using cached playlist for <url> (217 items, 42m old).
Forcing a refresh
rstube play new --refresh
rstube playlists fetch # refresh all playlists
rstube playlists fetch chess # refresh one playlist
rstube videos fetch # refresh all single videos
rstube videos fetch dQw4w9WgXcQ # refresh one video
Pre-warming
Put the fetch commands in a cron job or systemd timer to always have
fresh data without paying the latency at play time:
# every 6 hours
0 */6 * * * /usr/local/bin/rstube playlists fetch >/dev/null 2>&1
0 */6 * * * /usr/local/bin/rstube videos fetch >/dev/null 2>&1
Shell completion
rstube complete <shell> prints a completion script to stdout. Supported
shells: bash, zsh, fish, elvish, powershell.
Bash
Install once:
rstube complete bash > ~/.local/share/bash-completion/completions/rstube
Or source on the fly in your ~/.bashrc:
source <(rstube complete bash)
Name completion for playlists and videos
The bash script injects small helpers that read your config at tab time. Completion is scoped by section — playlist names never bleed into video slots and vice versa.
Playlist names (configured via playlists add) complete in:
rstube playlists show <TAB>rstube playlists remove <TAB>rstube playlists fetch <TAB>
Video ids (configured via videos add) complete in:
rstube videos remove <TAB>rstube videos fetch <TAB>
The helpers read $RSTUBE_CONFIG_DIR/config.toml, falling back to the
XDG default.
Zsh
rstube complete zsh > ~/.zfunc/_rstube
# ensure ~/.zfunc is in fpath; e.g. in .zshrc:
# fpath=(~/.zfunc $fpath)
# autoload -U compinit && compinit
Fish
rstube complete fish > ~/.config/fish/completions/rstube.fish
Elvish / PowerShell
See the respective shells’ documentation for where to install generated completion scripts. rstube just prints to stdout — installation location is up to you.
Notes
- The bash playlist-name injection is bash-specific. Other shells get standard clap-generated completion (subcommands, flags, enums) but not playlist-name completion.
- Re-run
rstube complete bash > ...whenever you upgrade rstube — the flag set may have changed.
mpv configuration
rstube shells out to mpv to play videos — it doesn’t manage mpv’s settings.
Customize mpv by editing its config files directly. On Linux these live under
~/.config/mpv/.
Position save/restore
rstube tracks positions itself (in $XDG_STATE_HOME/rstube/positions.redb) and
passes --start=<secs> to mpv when resuming. You don’t need mpv’s own
save-position-on-quit for rstube’s resume flow.
If you also use mpv outside rstube and want mpv to remember positions on its
own, add this to ~/.config/mpv/mpv.conf:
save-position-on-quit=yes
The two mechanisms don’t conflict, but only rstube’s is visible to rstube play resume.
Mouse bindings (click to pause, etc.)
mpv has no mouse bindings by default beyond the on-screen controller. To make
left-click pause/play, add these to ~/.config/mpv/input.conf (create the file
if it doesn’t exist):
MBTN_LEFT cycle pause
MBTN_RIGHT cycle mute
WHEEL_UP seek 10
WHEEL_DOWN seek -10
F11 cycle fullscreen
MBTN_LEFT→ single-click pauses/resumes. Double-click still goes fullscreen — mpv disambiguates single vs double on its own.MBTN_RIGHT→ toggles mute.WHEEL_UP/WHEEL_DOWN→ seek ±10s.F11→ toggle fullscreen. mpv’s default is lowercasef; adding F11 matches the fullscreen key most desktop apps use. Both work at once.
Restart mpv (close and reopen) for changes to take effect. No rstube restart
needed — rstube just spawns mpv, so it picks up whatever config is on disk at
spawn time.
Common built-in bindings
These are mpv defaults (no config needed). Useful to know before customizing:
| Key | Action |
|---|---|
space / p | Pause / resume |
f | Toggle fullscreen |
Esc | Exit fullscreen (doesn’t quit) |
q | Quit (saves position if save-position-on-quit is set) |
← / → | Seek ±5s |
↑ / ↓ | Seek ±1m |
9 / 0 | Volume down / up |
m | Mute |
j / J | Cycle subtitles (forward / backward) |
# | Cycle audio tracks |
T | Toggle always-on-top |
s | Take a screenshot |
Run mpv --input-keylist to see every bindable key name, and mpv --input-cmdlist for every command. The online reference is at
mpv.io/manual.
Why rstube doesn’t ship mpv config
Two reasons:
- Your mpv, your rules. Baking bindings into rstube would override
whatever you have in
input.confwhen launched via rstube, but not otherwise — inconsistent and surprising. - mpv’s config is already the right place for mpv settings. Anyone using mpv already has a workflow for managing it; rstube duplicating that as command-line flags would be friction for no gain.
File layout and environment variables
Config
| Location | Contents |
|---|---|
$RSTUBE_CONFIG_DIR/config.toml | Configured playlists and videos (TOML) |
Fallbacks, in order:
$RSTUBE_CONFIG_DIR/config.tomlif the env var is set$XDG_CONFIG_HOME/rstube/config.toml$HOME/.config/rstube/config.toml
State
| Location | Contents |
|---|---|
$RSTUBE_STATE_DIR/positions.redb | Per-video resume positions (redb key/value store) |
$RSTUBE_STATE_DIR/history.jsonl | Playback history (JSON-lines, append on play, rewritten on forget) |
$RSTUBE_STATE_DIR/playlist_cache.json | Cached playlist and single-video metadata (JSON) |
Fallbacks:
$RSTUBE_STATE_DIR/...if the env var is set$XDG_STATE_HOME/rstube/...$HOME/.local/state/rstube/...
Env vars
| Var | Effect |
|---|---|
RSTUBE_CONFIG_DIR | Override the config directory |
RSTUBE_STATE_DIR | Override the state directory |
XDG_CONFIG_HOME | Standard XDG var; respected if RSTUBE_CONFIG_DIR is unset |
XDG_STATE_HOME | Standard XDG var; respected if RSTUBE_STATE_DIR is unset |
Both RSTUBE_* env vars are useful for testing — point rstube at a
temp directory without touching your real config or history.
Safe to delete
Every file under these directories is regenerated on demand. If you want a clean slate:
# nuke everything
rm -rf ~/.config/rstube ~/.local/state/rstube
# keep config, reset state
rm -rf ~/.local/state/rstube
# keep history, refresh the playlist cache
rm ~/.local/state/rstube/playlist_cache.json
Release Info
This page is generated automatically by the docs deployment workflow.
- Version:
0.3.9 - Git tag:
v0.3.9 - Git commit:
28035d956d8582e38d6214380070e3df9f60d91b - Released at:
2026-11-21 08:16:29 UTC - Workflow:
CIrun #87