YouTube Subscriptions in Emacs with elfeed
Goal
To be able to get all newly uploaded videos from your subscribed channels in elfeed, and have them downloaded if so desired.
Dependencies
- Emacs
- elfeed
- youtube-dl
Preparation
Download the xml
file of your subscriptions from subscrition manager. The link should be near the bottom of the page, saying “Export subscriptions”.
Add the URLs to elfeed-feeds
:
(setq elfeed-feeds
'("https://www.youtube.com/feeds/videos.xml?channel_id=UC0sytTpk1adR_cfjHhiJ08Q"))
Update your init
file
;; Set executable path
(setq youtube-dl-path "/usr/bin/youtube-dl")
;; Set video storage path
(setq youtube-dl-output-dir "~/Videos/")
(defun elfeed-download-video ()
"Download a video using youtube-dl."
(interactive)
(async-shell-command (format "%s -o \"%s%s\" -f bestvideo+bestaudio %s"
youtube-dl-path
youtube-dl-output-dir
"%(title)s.%(ext)s"
(elfeed-entry-link elfeed-show-entry))))
;; Add `youtube` tag to all videos
(add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :feed-url "youtube\\.com"
:add '(video youtube)))
Use
After updating your feeds, you will see the videos from your subscriptions. <ret>
on one of the videos, and do M-x elfeed-download-video <ret>
. Wait for the command to finish, and you will have the video stored locally.