Skip to content

xenodium/ytr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

👉 Support this work via GitHub Sponsors

YouTube Radio (ytr)

An Emacs package to stream YouTube audio (powered by yt-dlp and mpv).

Install / Setup

(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.

Doom Emacs

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))

Usage

  • M-x ytr toggles 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…=
  • Press / to pick any track across all your channels, or s to pick a channel and play its first track.
  • SPC toggles play/pause, n / p move between tracks, and f / b seek.

Player key bindings

KeyCommandDescription
SPCytr-toggle-playToggle play/pause, or resume the last played track.
nytr-nextPlay the next track in the catalog.
pytr-previousPlay the previous track in the catalog.
fytr-seek-forwardSeek forward (5 seconds by default).
bytr-seek-backwardSeek backward (5 seconds by default).
/ytr-play-trackSelect a track from all channels and play it.
cytr-play-channelSelect a channel and play its first track.
+ytr-add-channelPrompt for a channel/playlist URL, add it, and play.
-ytr-remove-channelSelect a channel and remove it from the catalog.
oytr-open-in-browserOpen the current track in a web browser.
TABytr-forward-buttonMove point to the next button.
<backtab>ytr-backward-buttonMove point to the previous button.
qytr-quitHide the player (playback continues).
Qytr-exitStop 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.

External dependencies

ytr requires a graphical Emacs (it renders images in a child frame), plus two command line tools in your exec-path:

  • yt-dlp: fetches channel/playlist listings.
  • mpv: plays the audio.

On macOS:

brew install yt-dlp mpv

Customizations

Data directory

By 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/")

Buttons (macOS SF Symbols)

If you have SF symbol rendering in Emacs on macOS, enable them in the player’s buttons with:

(ytr-macos-use-sf-symbols)

Button icons

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 "◁◁")

Works on my machine ¯\_(ツ)_/¯

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.

Like this package? Please consider sponsoring

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.

About

An Emacs package to stream YouTube audio (powered by yt-dlp and mpv)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages