___________________________________________

              HOW I USE EMACS FOR YOUTUBE SUBSCRIPTIONS
             ___________________________________________


1 Problem
=========

 I daily  consume youtube content  but I  don't like the  bloated web
 interface. If possible  I want to view videos in  my preferred video
 player and not  the browser. Also I don't want  to create an youtube
 account for my subscriptions to reduce tracking. If I think about it
 I  hate nearly  everything about  youtube  ;_; Luckily  there is  an
 alternative  front-end  which  is  lightweight  and  free  software:
 invidio.us (official site[1], github[2]).


2 Elfeed
========

 Every youtube channel has a RSS feed which youtube in their absolute
 curtesy hides  from us. Still we  can get the url  directly from the
 corresponding invidio.us channel page. So  the only thing we need is
 a RSS feed viewer for emacs. For this I use elfeed[3]

 I put this in my .emacs file to add my feeds:

 ,----
 | (setq elfeed-feeds
 |       (quote
 |       ("https://www.invidiuo.us/feed/channel/ID1" youtube)
 |       ("https://www.invidiuo.us/feed/channel/ID2" youtube)))
 `----

 Now I add a search filter:

 ,----
 | (setq-default elfeed-search-filter "youtube #50")
 `----

 This means: show the last 50 entries tagged "youtube".

 Feed reader usage:

 - open the feed reader: M-x elfeed
 - update feeds: G
 - change filter on the fly: s
 - view entry: ENTER
 - close entry: q

 Easy.


3 Youtube-dl
============

 To download  the video I  use youtube-dl[4]. To directly  download a
 video from the feed-entry I wrote this function:

 ,----
 | (defun ytdl ()
 |   "Download URL with youtube-dl"
 |   (interactive)
 |   (beginning-of-buffer)
 |   (search-forward "http") ;; this is the channel url
 |   (search-forward "http") ;; this is the video url
 |   (setq yt-url (thing-at-point 'url))
 |   (shell-command
 |    (format "cd ~/ && youtube-dl '%s' &" yt-url))
 |   (kill-buffer "*elfeed-entry*"))
 `----

 Now I can call this function  by name ("M-x ytdl"), locate the video
 with dired and open it from within emacs. Check my other writings on
 emacs to learn more.



Footnotes
_________

[1] <https://invidio.us>

[2] <https://github.com/omarroth/invidious>

[3] <https://github.com/skeeto/elfeed>

[4] <https://github.com/ytdl-org/youtube-dl/>