👉 Support this work via GitHub Sponsors
An Emacs package to stream YouTube audio (powered by yt-dlp and mpv).
(use-package ytr
:vc (:url "https://github.com/xenodium/ytr" :rev :newest)
:commands (ytr))Then M-x ytr to open the player. The first time, you’ll be prompted for a channel or playlist URL.
Add the package to packages.el
(package! ytr
:recipe (:host github :repo "xenodium/ytr"))Configure ytr in config.el to work with the SPACE leader key and evil mode.
(use-package! ytr
:commands ytr
:hook (ytr-mode . evil-emacs-state)
:init
;; Optional: a leader binding to open the player
(map! :leader :desc "YouTube radio" "o y" #'ytr))M-x ytrtoggles player display.- Press
+to add a YouTube channel or playlist URL, for example:- A channel:
https://www.youtube.com/@TOKYOECHOSOUNDS - A playlist or mix:
https://www.youtube.com/playlist?list…=
- A channel:
- Press
/to pick any track across all your channels, orsto pick a channel and play its first track. SPCtoggles play/pause,n/pmove between tracks, andf/bseek.
| Key | Command | Description |
|---|---|---|
SPC | ytr-toggle-play | Toggle play/pause, or resume the last played track. |
n | ytr-next | Play the next track in the catalog. |
p | ytr-previous | Play the previous track in the catalog. |
f | ytr-seek-forward | Seek forward (5 seconds by default). |
b | ytr-seek-backward | Seek backward (5 seconds by default). |
/ | ytr-play-track | Select a track from all channels and play it. |
c | ytr-play-channel | Select a channel and play its first track. |
+ | ytr-add-channel | Prompt for a channel/playlist URL, add it, and play. |
- | ytr-remove-channel | Select a channel and remove it from the catalog. |
o | ytr-open-in-browser | Open the current track in a web browser. |
TAB | ytr-forward-button | Move point to the next button. |
<backtab> | ytr-backward-button | Move point to the previous button. |
q | ytr-quit | Hide the player (playback continues). |
Q | ytr-exit | Stop playback and close the player. |
With a numeric prefix, f / b seek that many seconds; with a plain prefix (C-u), they seek in minutes.
ytr requires a graphical Emacs (it renders images in a child frame), plus two command line tools in your exec-path:
On macOS:
brew install yt-dlp mpvBy default, ytr keeps its state file and cached thumbnails under ytr/ in your user-emacs-directory. Point ytr-data-directory elsewhere to keep things tidy:
(setq ytr-data-directory "~/.cache/ytr/")If you have SF symbol rendering in Emacs on macOS, enable them in the player’s buttons with:
(ytr-macos-use-sf-symbols)Each button icon is a variable you can set to any string, for example:
(setq ytr-play-icon "▶"
ytr-stop-icon "■"
ytr-next-icon "▷▷"
ytr-previous-icon "◁◁")While I’ve spent a bunch of time handling edge cases affecting my preferred flow, I’ve likely omitted addressing a wider range of usages. If you’d like me to extend it to those, please consider sponsoring the work.
As an indie dev, building Emacs packages takes time away from activities that help pay the bills. If you like this package, consider making the effort sustainable by sponsoring.