Endless YouTube radio for cliamp — auto-fills the queue with the current track's YouTube Mix.
This plugin was written with an AI assistant (Claude) and has only been lightly reviewed by a human. It is ~180 lines of Lua with no external dependencies beyond
yt-dlp.Read
yt-radio.luabefore you approve it. cliamp will ask you to grant it thecontrol(modify the play queue) andexec(runyt-dlp) permissions, and you should only do that if you are comfortable with the source. No warranty; use at your own risk.
yt-radio listens to cliamp's track.change / queue.change events. When fewer
than min_ahead tracks remain ahead in the queue, it takes the video ID of the
track currently playing, asks yt-dlp for that video's YouTube Mix
(RD<videoID> — the auto-generated radio YouTube builds for any video), and
appends up to batch fresh tracks to the queue.
Because every refill re-seeds from whatever is playing at that moment, the result is an endless radio that keeps drifting instead of a fixed playlist. It works for any YouTube / YouTube Music track played in cliamp.
- cliamp with the Lua plugin runtime. Plugins run in the TUI, not in
--daemonmode. yt-dlpon yourPATH— it is already in cliamp'scliamp.execallowlist by default, so no extra config is needed.- A working YouTube provider in cliamp so the queued tracks actually play:
ytmusic(runcliamp setup) or theytprovider. - Permissions granted on trust:
control(modify the queue) andexec(runyt-dlp).
mkdir -p ~/.config/cliamp/plugins/yt-radio
curl -fsSL https://raw.githubusercontent.com/Cache21/cliamp-plugin-yt-radio/main/yt-radio.lua \
-o ~/.config/cliamp/plugins/yt-radio/init.lua
cliamp plugins trust yt-radio # answer "y" at the promptThen start the cliamp TUI. cliamp plugins list should show yt-radio as
trusted.
Why a directory and not a single file? cliamp 1.63.x has a bug where single-file plugins (
plugins/yt-radio.lua) can never be trusted — they stayuntrustedand never load. Installing asplugins/yt-radio/init.luaworks around it. The bug is fixed in cliamp 2.0.0.
cliamp plugins install Cache21/cliamp-plugin-yt-radio
# or pin a version:
cliamp plugins install Cache21/cliamp-plugin-yt-radio@v0.2.0Accept the trust prompt (permissions control, exec), then restart the TUI.
Trust model: cliamp pins a hash of the approved contents in
~/.config/cliamp/plugins/.trust.json. If you edit the plugin afterwards you must re-runcliamp plugins trust yt-radio.
All keys are optional. Put them under [plugins.yt-radio] in
~/.config/cliamp/config.toml:
| Key | Default | Purpose |
|---|---|---|
start_on |
true |
Whether auto-refill is active when the plugin loads. Toggle at runtime with cliamp plugins call yt-radio toggle (the runtime state is remembered and overrides this). |
min_ahead |
3 |
Refill when fewer than N tracks remain ahead of the current one. |
batch |
10 |
How many tracks to add per refill. |
cooldown_secs |
20 |
Minimum seconds between automatic refills (guards against event storms). The start command ignores it. |
fetch_max |
batch * 3 |
How many Mix entries to request from yt-dlp (headroom for de-duplication). |
history_max |
300 |
How many recently-added video IDs to remember, to avoid repeats across refills and restarts. |
use_cookies |
false |
Pass --cookies-from-browser to yt-dlp (only needed for Mixes that require a signed-in session). |
cookie_browser |
chromium |
Which browser yt-dlp reads cookies from when use_cookies = true. |
enabled = falseunder[plugins.yt-radio]is cliamp's own switch to disable the whole plugin — different fromstart_on.
Example:
[plugins.yt-radio]
min_ahead = 3
batch = 10Automatic: just play any YouTube / YouTube Music track in cliamp. As the queue
drains it tops itself up — you'll see YT radio +N flash in the status bar.
Manual: cliamp plugins call yt-radio <command>
| Command | Effect |
|---|---|
start |
Force a refill right now, ignoring cooldown_secs, min_ahead and the on/off state. |
on / off |
Enable / disable automatic refills (persisted). |
toggle |
Flip the on/off state. |
status |
Print current state and settings. |
clear |
Reset the anti-repeat history. |
RD<videoID> is the "Mix" playlist YouTube auto-generates for any video.
yt-dlp --flat-playlist --dump-json lists that playlist cheaply (metadata only,
no per-video extraction). The plugin then:
- reads the current queue via
cliamp.queue.list()/cliamp.queue.current(); - extracts the seed video ID from the current track's
path; - runs
yt-dlponhttps://www.youtube.com/watch?v=<seed>&list=RD<seed>; - filters out the seed itself, IDs already in the queue, and IDs in the recent history;
- appends up to
batchof the remainder withcliamp.queue.add(...).
yt-dlp runs asynchronously off cliamp's UI thread; the queue is only touched in
the process's exit callback. A single-flight guard plus cooldown_secs keep the
track.change / queue.change event stream (including the plugin's own
queue.add calls) from triggering overlapping refills.
- Nothing gets added — tail the plugin log:
tail -f ~/.config/cliamp/plugins.logand look for[yt-radio]lines. cliamp plugins listshowsuntrustedand it never runs — you installed it as a single file on cliamp 1.63.x. Remove it (cliamp plugins remove yt-radio) and use the directory install above.plugins not enabled— you rancliamp --daemon. Plugins only run in the TUI.current track is not a YouTube id— you're playing internet radio, Navidrome, or a local file. The plugin only acts on YouTube tracks.yt-dlp exited with code N— tryuse_cookies = false, or updateyt-dlp.- It circles the same songs — raise
history_max, and runcliamp plugins call yt-radio clearto reset the history.
- The queue length stays around
min_ahead + batch; already-played tracks remain in the queue history (normal cliamp behavior). - cliamp sandbox constraints:
execis limited to the allowlist (yt-dlp,ffmpeg), 4 MiB combined output, 4 concurrent processes per plugin. This plugin does not usecliamp.http. - No data is collected or sent anywhere. The video-ID history is stored locally at
~/.local/share/cliamp/plugins/yt-radio/store.json(mode0600).
MIT © 2026 Manuel Artía. See LICENSE.