[Emacs] Better options when opening a YouTube video

This commit is contained in:
Lucien Cartier-Tilet 2022-02-05 12:42:33 +01:00
parent 5e51cba460
commit ae075d044d
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -1367,7 +1367,9 @@ database is to be stored.
I dont want YouTube videos to be open with my web browser when I
invoke ~elfeed-show-visit~, so Ill advise this function so I can modify
the behavior of said function.
the behavior of said function. Oh, and I already made [[#Packages-Configuration-Misc-Ytplay-wxm9weq0r4j0][a neat package]]
for playing YouTube videos and friends through [[https://ytdl-org.github.io/youtube-dl/][youtube-dl]] or its
superior fork [[https://github.com/yt-dlp/yt-dlp][yt-dlp]] in mpv.
#+name: elfeed-open-youtube-with-mpv
#+begin_src emacs-lisp
(defun my/elfeed-filter-youtube-videos (orig-fun &rest args)
@ -1376,7 +1378,9 @@ the behavior of said function.
(when link
(if (string-match-p ".*youtube\.com.*watch.*" link)
;; This is a YouTube video, open it with mpv
(async-shell-command (format "mpv \"%s\"" link) (current-buffer) (current-buffer))
(progn
(require 'ytplay)
(ytplay link))
(apply orig-fun args)))))
(advice-add 'elfeed-show-visit :around #'my/elfeed-filter-youtube-videos)