From: Joseph Nuthalapati Date: Sun, 2 Aug 2020 01:57:11 +0000 (+0530) Subject: youtube: Add new blog post X-Git-Url: http://njoseph.me/gitweb/blog.git/commitdiff_plain/2c707b05cb20da8a1cee7c70217f5e87138ab8ce youtube: Add new blog post Signed-off-by: Joseph Nuthalapati --- diff --git a/config.toml b/config.toml index 2b2aea3..03bcff6 100644 --- a/config.toml +++ b/config.toml @@ -5,6 +5,8 @@ languageCode = "en" title = "Blog" theme = "hyde" +staticDir = ["img"] + enableRobotsTXT = true [params] diff --git a/content/posts/youtube-adventures.md b/content/posts/youtube-adventures.md new file mode 100644 index 0000000..f09c305 --- /dev/null +++ b/content/posts/youtube-adventures.md @@ -0,0 +1,136 @@ +--- +title: "Adventures with YouTube" +date: 2020-08-02T05:40:09+05:30 +lastmod: 2019-11-04T15:40:09+05:30 +tags : [ "free-software", "YouTube", "privacy", "MPV", "NimCoon" ] +categories : [ "free-software", "privacy" ] +layout: post +type: "post" +highlight: false +--- + +## 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](https://mpv.io) player, +which internally uses [youtube-dl](https://youtube-dl.org) to fetch the video. + +![Y U No Use YouTube Website](/blog/youtube-yuno.png) + +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](https://www.smtube.org/) is add-on for +[SMPlayer](http://www.smplayer.info/) that can fetch YouTube videos from a proxy +called [Tonvid](https://tonvid.com). 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](/blog/smtube.png) + +There are two other YouTube proxies worth mentioning: +1. [HookTube](hooktube.com) +2. [Invidious](invidio.us) + +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](https://freetubeapp.io) 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](https://freetubeapp.io/images/FreeTube1.png) + +For a while, I also used a bash script called `ytview` from the +[Bash-Snippets](https://github.com/alexanderepstein/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](https://gitlab.com/njoseph/nimcoon). You can see +the list of supported features in the [project +page](https://gitlab.com/njoseph/nimcoon/-/blob/master/README.md#features). 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](https://tt-rss.org/). It is self-hosted on my +[FreedomBox](https://freedombox.org). 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](/blog/youtube-tt-rss.png) + +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](https://github.com/woodruffw/ff2mpv). + +![ff2mpv extension](/blog/ff2mpv.png) + +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](https://github.com/woodruffw/ff2mpv/blob/master/ff2mpv.py#L12) 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](https://joinpeertube.org/#/) video +links that I find on the [Fediverse](https://en.wikipedia.org/wiki/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: +```python + args = ["mpv", "--no-terminal", "--", url] +``` +After: +```python + 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](https://njoseph.me/mediawiki/Privacy_Stack). diff --git a/img/ff2mpv.png b/img/ff2mpv.png new file mode 100644 index 0000000..0f09576 Binary files /dev/null and b/img/ff2mpv.png differ diff --git a/img/smtube.png b/img/smtube.png new file mode 100644 index 0000000..aac5dd6 Binary files /dev/null and b/img/smtube.png differ diff --git a/img/youtube-tt-rss.png b/img/youtube-tt-rss.png new file mode 100644 index 0000000..2ccfacf Binary files /dev/null and b/img/youtube-tt-rss.png differ diff --git a/img/youtube-yuno.png b/img/youtube-yuno.png new file mode 100644 index 0000000..56c8bce Binary files /dev/null and b/img/youtube-yuno.png differ