dt.iki.fi

Video Streaming without a Browser

The advice is twofold but simple:

  • The python script youtube-dl is able to extract and download video and audio from many, many different sites
  • The media player mpv automatically looks for youtube-dl when passed an internet URL to extract the media and play it directly.

Additionally one can use a GUI mpv frontend; I believe celluloid (formerly known as Gnome-mpv) and smplayer are good choices.

It is important to understand that youtube-dl constantly fights the Good Fight against huge platforms that want to force us to consume their content only through their platforms, with all the data mining and exposure to all kinds of advertising that entails. "Constantly" because the platforms fight back by changing their site layout and generally making things harder.

In my opinion, youtube-dl is the only project that manages to stay abreast. And has done so for many years.

Therefore, if you use a release-based distribution (Debian, Ubuntu, Mint...) I do not recommend installing youtube-dl from your distro's repositories. This version is bound to be outdated and receive no updates at all, when really it needs updating constantly.

The instructions here are for UNIX-like systems, but both youtube-dl and mpv are available for many different platforms.

Install youtube-dl in your home folder-up-

Preliminaries-up-

echo "$PATH"

If this includes /home/yourusername/bin or /home/yourusername/.local/bin you're all set, If not, you should add one of these directories by editing ~/.profile or ~/.bash_profile, adding a line like this:

[ -d "$HOME/bin" ] && PATH="$HOME/bin${PATH+:}${PATH}"

Download & Install-up-

$> cd ~/bin # assuming this directory is in your PATH
$> wget https://yt-dl.org/downloads/latest/youtube-dl
$> chmod +x youtube-dl

And then update it thusly:

$> youtube-dl -U

It is possible that one of the GUI frontends for mpv has completely integrated all the above.

Usage-up-

A fairly recent version of mpv should be available for your platform/distro. It recognizes the presence of youtube-dl in your PATH and tries to apply it automatically when you pass it a web URL. It has some options pertaining specifically to youtube-dl and can also one option to pass raw options directly to youtube-dl.

Read the friendly man pages for both packages and marvel.

Once everything is installed & working it's easy to copy URL's and pass them to mpv, for example via a hotkey.
Openbox users could add this to their rc.xml:

<keybind key="W-y">
  <action name="Execute">
    <command>sh -c 'mpv "$(xclip -o)"'</command>
  </action>
</keybind>