Watch YouTube with Yeetube and mpv
I may hate YouTube as a service, but I even I can’t deny the quality of vlogs there. Even though I would strongly prefer to follow folks on PeerTube or Odysee, this will not happen anytime soon for most of the channels. Luckily, with the popularity of YouTube comes quite a few ways to use it in a better way
Yeetube
Yeetube1 is an Emacs wrapper around searching and viewing videos on Youtube.
The watching part happens via mpv
2.
You simply pass the video link (not the page) in the shell and mpv
will handle the rest.
Yeetube handles everything before we have the actual file, and running mpv
.
First, let’s install it:
(use-package yeetube)
And, assuming mpv
is already installed, you are ready to go.
Run yeetube-search
, type in whatever you want and press enter.
A table with top results will show up.
Now, select the one that interests you, run yeetube-play
, wait a few seconds and mpv window will show.
Yeetube also supports downloading videos via yt-dl
and saving videos for future reference.
My full config, with evil keybindings looks like:
(use-package yeetube
:general
(:states 'normal
:keymaps 'yeetube-mode-map
"RET" 'yeetube-play
"d" 'yeetube-download-video
"b" 'yeetube-play-saved-video
"B" 'yeetube-save-video
"x" 'yeetube-remove-saved-video
"/" 'yeetube-search
"0" 'yeetube-toggle-video
))
Note that this comes with no ads, and less tracking, but also less revenue to the creator. Being a patron is a good way to feel better about it.
Link handler
This is nice, but we can make it extra-nice. I subscribe to quite a few YouTube channels via RSS3 and want to use Yeetube fast. We can write a very simple elisp function:
(defun mms-open-yt-under-point ()
(interactive)
(setq url (thing-at-point 'url))
(string-match "youtube.com" url)
Now, move the pointer on a YT4 link and call this function. Yeetube interface will open, so just play the top result.
My (current) full function in use is:
(defun mms-open-link-under-point ()
(interactive)
(let (url (thing-at-point 'url))
(cond
((string-match "youtube.com" url) (yeetube-search url))
(t (eww url)))
))
So it will use eww
for anything that is not a YT link, and I can expand it further whenever I want.
Then, just add a simple keyboard navigation, and you’re done
(mms-leader-keys
"RET RET" '(lambda () (interactive) (mms-open-link-under-point) :wk "follow link"))
Errata
2024-02-26: Dave pointed me that using let
inside custom method is preferable to setq
-
“yeetube | Emacs Front-End for YouTube” blog post from the author ↩︎
-
The secret URL:
https://www.youtube.com/feeds/videos.xml?channel_id=<channel_id>
. You can find the channel ID using different online services, as it is not as straight forward as it should be. ↩︎ -
Only if the package registers itself as a provider for
thing-at-point
. In Elfeed it will for main item URL, but not for items embedded in the body. We need to useeww
to open the page and we can get the URL from there. ↩︎
Previous: Reading and automating email using Notmuch, Next: Play Interactive Fiction with Malyon, Up: Cool Emacs