Adventures with YouTube

Why?

I stopped using my Google account several years ago. This means that I can no longer subscribe to YouTube channels directly in YouTube.

I have been playing YouTube links that I find directly using the MPV player, which internally uses youtube-dl to fetch the video.

Y U No Use YouTube Website

Not using the YouTube website directly has several advantages. YouTube’s revenue is based on the number of advertisements you see on the website. So, the more time you spend on YouTube the more money they earn. It is easy to get around the advertisements by using ad-blockers, but the site itself is optimized for binge-watching with features such as auto-play being turned on by default. If your objective is to just watch one useful video and leave, YouTube’s website doesn’t make it easy.

Playing YouTube videos on the desktop

Over the years, I experimented with several solutions for playing YouTube videos without going to the YouTube website.

One of the oldest solutions in this category is SMTube + SMPlayer. SMPlayer is a GUI player based on MPlayer. SMTube is add-on for SMPlayer that can fetch YouTube videos from a proxy called Tonvid. On clicking on any of the videos in the interface, it launches the video in SMPlayer. It can also be configured to use other backends like MPV + youtube-dl (my personal favorite).

SMTube

There are two other YouTube proxies worth mentioning:

  1. HookTube
  2. Invidious

HookTube is a closed-source project with some amount of advertising. I used this till the better free software alternative Invidious was released. These proxies work by downloading the video to the server first and then streaming the video to the user. There is usually a noticeable lag in fetching the video unless it has already been cached. Sometimes, the YouTube API key used might run out of its daily allowed quota. This will be less of a problem if you self-host Invidious.

FreeTubeApp is an electron-based desktop app that allows subscriptions. It fetches its search results using an Invidious backend and subscriptions using RSS feeds. It is easy to import and export subscriptions, since they are basically just RSS feeds.

FreeTubeApp

For a while, I also used a bash script called ytview from the Bash-Snippets project to search and play YouTube videos from the commandline. However, over time I was dissatisfied with the limitations of this script. I extended some of its features, but writing bash is not fun. So, I ended up writing a commandline YouTube player called NimCoon. You can see the list of supported features in the project page. I keep adding features to this project as and when I need them.

RSS Feeds? 🤔

Once I exported and imported the list of subscriptions on my FreeTubeApp from one machine to another, I realized that I might as well import the subscriptions into my RSS feed reader. The feed reader I use is Tiny Tiny RSS. It is self-hosted on my FreedomBox. The file with the RSS feeds that I imported from FreeTubeApp was added as a separate category called “YouTube Subscriptions” in TT-RSS.

TT-RSS was able to fetch the videos from my YouTube subscriptions. All I need from the feed reader is just the video name and URL. However, TT-RSS decided to embed the YouTube video into the page itself which my Firefox extension uMatrix was happy to block. I ended up having pages that look like this:

YouTube feeds displayed in Tiny Tiny RSS

I needed a way of playing the video links from my feed reader in my preferred player (MPV, of course). I found a useful Firefox extension for this purpose called ff2mpv.

ff2mpv extension

ff2mpv makes use of the “native messaging hosts” feature in Firefox that allows you to invoke a system executable from Firefox. In this case, ff2mpv uses a Python script to invoke the MPV player with a YouTube URL.

A right-click option called “Play in MPV” is added to every hyperlink in Firefox, which when clicked loads the video in MPV. So far, so good.

But I found myself trying to play PeerTube video links that I find on the Fediverse the same way. Well, MPV + youtube-dl can still play PeerTube videos but it uses the HTTP stream instead of the WebTorrent stream and doesn’t always pick the highest resolution available. Fortunately, both of these problems have already been solved in NimCoon. All I had to do was to change the executable invoked by ff2mpv’s Python script from mpv to nimcoon.

Before:

    args = ["mpv", "--no-terminal", "--", url]

After:

    args = ["/home/joseph/.nimble/bin/nimcoon", url]

There isn’t much else to do in the RSS feed reader and the browser. Any improvements that I make to this setup will be in NimCoon.

What else?

While I was on this journey, many people recommended that I use elfeed in emacs for YouTube subscriptions and use MPV to play the videos. If I had taken that route, maybe most of NimCoon would’ve been implemented in emacs Lisp instead of the Nim language. Using a self-hosted RSS feed reader gives me the advantage of being able to use it from multiple devices. Also, I was already using TT-RSS well before I had heard of elfeed. ¯\(ツ)

If you’re interested in finding out what other tools I use for reasons of privacy and digital minimalism, please check out my Privacy Stack.

Comments

Please post your comments on this thread on Mastodon.