dt.iki.fi

Sailfish OS - Install yt-dlp

This article has a parent article. It contains some preliminaries to the topics here.
Also this article might be helpful.

yt-dlp1 is an extremely vesatile utility that can download or stream media from many, many sites, even if they lock their streams behind complex javascript and access tokens.

On my desktop, I never even access YouTube anymore, every YT link gets fed directly to mpv, which is able to call yt-dlp for direct playback.

Situation

That isn’t quite so easy in SFOS though.

  1. SFOS’ Python version (yt-dlp is a python script) is too old.
  2. yt-dlp needs constant updating because Google is playing a constant game of whack’a’mole with developers of alternative apps, and the community behind that program is about the only one that keeps up with it in near-realtime.

Solution

It wasn’t easy to find, but yt-dlp’s nightly builds work on SFOS. They get updated constantly, they come bundled with their own Python, and they don’t balk when I execute yt-dlp -U to update itself to the newest version.

Just to be very clear, I do not recommend to install any other version available in any SFOS store.

Here’s what I did:

Download the latest standalone version (one that does not rely on SFOS old Python version):

Move/rename it to ~/.local/bin/yt-dlp (also see this chapter):

chmod +x yt-dlp*
mv yt-dlp* ~/.local/bin/yt-dlp

After log out/in the yt-dlp command should be available on your command-line.

Make sure it gets updated regularly via systemd:

~/.config/systemd/user/yt-dlp.service

[Unit]
Description=Update yt-dlp

[Service]
ExecStart=/home/defaultuser/.local/bin/yt-dlp -U

~/.config/systemd/user/yt-dlp.timer

[Unit]
Description=Update yt-dlp

[Timer]
OnStartupSec=5m
WakeSystem=false
OnCalendar=daily
RandomizedDelaySec=5m
AccuracySec=5m
Persistent=true

[Install]
WantedBy=timers.target

And finally:

systemctl --user enable --now yt-dlp.timer

GUI app to watch videos via yt-dlp

Feeding URLs to yt-dlp or mpv on the command line is not trivial (but possible to automate). Thankfully an app now exists! It’s called SailTube and you can get it here. Make sure to get the newest version, currently 0.6.1.

It looks for yt-dlp in ~/.local/bin and uses that to search, display thumbnails, and play back video. It can also use Peertube or Inviduous without the need for yt-dlp.

Quotes from this forum topic:

Yt-dlp is not included, download current version of yt-dlp yt-dlp_linux_armv7l.zip or yt-dlp_linux_aarch64.zip from their github and extract the yt-dlp file and _internal folder to .local/bin/ and rename the file to yt-dlp.

I don’t even have that _internal folder. I’m also using a different version though.

It could be used with node.js 22 from openrepos

I’m not sure how mandatory this is but I installed it.


  1. Or youtube-dl. Since the DMCA takedown debacle I switched to yt-dlp and never looked back, but I understand that youtube-dl is alive and well.