💾 Archived View for spool-five.com › gemlog › 2022-12-08-emacs_youtube.gmi captured on 2024-05-26 at 14:42:03. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
One of my goals for 2023 is to use YouTube as little as possible.
However, I still want to be able to watch videos occasionally, I just don't want the 'time-suck' element of youtube, where you end up with an endless stream of (admittedly interesting) content thanks to the suggestions provided by the algorithm.
There are lots of alternatives to visiting youtube directly, but I wanted a way to subscribe to channels and still watch videos from people I am interested in. As usual, Emacs provided a good solution.
Basically, I used a script (not essential, just because I'm lazy) to automate the process of getting the rss feed for a channel and append it to my list of elfeed subscriptions. It takes the url of a youtube channel page as an argument. I just wrote this so it needs a lot of tidying up/error checking, it's supposed to be temporary anyway.
_elfeed_list="/home/eoin/.config/doom/elfeed.org" _url=$1 _channel_id=$(curl -s "$_url" | grep -o -P 'channel_id=.{0,24}' | awk -F "=" '{print $2}' | head -n 1) _rss_feed="https://www.youtube.com/feeds/videos.xml?channel_id=$_channel_id" _channel_name=$(curl -s "$_rss_feed" | grep "title" | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1) echo "*** [[$_rss_feed][$_channel_name]]" >> "$_elfeed_list"
Then, I can see the list of videos in my elfeed view (all the channels are tagged :youtube: so can be easily narrowed with elfeed's search). I've only just started adding subscriptions to it.
Finally, I added some code to my emacs config so that it opens youtube urls with mpv by default.
;; adapted from EmacsWiki/Browse-url https://www.emacswiki.org/emacs/BrowseUrl (defcustom youtube-viewer-program "youtube-viewer" "Progam path to youtube-viewer") (defcustom youtube-viewer-args nil "Extra arguments for youtube-viewer") (defun view-youtube-url (url &rest _) "Open Youtube-Viewer to browse the given URL." (interactive (browse-url-interactive-arg "URL: ")) (setq url (browse-url-encode-url url)) (let* ((process-environment (browse-url-process-environment))) (apply #'start-process (concat "youtube-viewer " url) nil youtube-viewer-program (append youtube-viewer-args (list url))))) (with-eval-after-load 'browse-url (add-to-list 'browse-url-handlers (cons "youtu\\.?be" #'view-youtube-url)))
I used youtube-viewer as the default program to open the links since mpv on its own seemed very slow (connection wise). Presumably youtube-viewer works better because it uses an API key.
Now I have a simple way to watch my youtube subscriptions without actually going to youtube.