Skip to content

Instantly share code, notes, and snippets.

@konfou
Last active July 2, 2020 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konfou/f3cf9260b563bdb3eae25455c4f13951 to your computer and use it in GitHub Desktop.
Save konfou/f3cf9260b563bdb3eae25455c4f13951 to your computer and use it in GitHub Desktop.
play-with-mpv youtube-dl compatible sites

The following files have been adapted from ViewTube userscript 'protocol' [1] instructions. But I find no reason using such a complex script just for opening a video to mpv, so instead I opted out to using a bookmarklet. The files may be installed as follows:

user$ mkdir -p $HOME/.local/{bin,share/applications}
user$ cp notube.desktop $HOME/.local/share/applications/notube.desktop
user$ install -D -m 755 notube.sh $HOME/.local/bin/notube.sh
user$ xdg-mime default notube.desktop x-scheme-handler/notube

After that, make a new bookmark naming it e.g. Play with MPV and set location to the body of notube.js. From there, on a supported from youtube-dl site click the bookmarklet.

Firefox users need to perform some additional steps. Goto about:config, make a new boolean type key named network.protocol-handler.expose.notube and set its value to false. Then associate the protocol using the following link:

>tfw the botnet wants me to starve

In case the url isn't working open this and click it there.

On another note, Firefox users don't even have to open the page and instead they can goto to the (as it is obvious from the bookmark) url notube:<url> replacing <url> of course with the site url or even a direct link to a video or audio.

[Desktop Entry]
Name=NoTube
Exec=/home/user/.local/bin/notube.sh %u
Type=Application
Terminal=false
MimeType=x-scheme-handler/notube
/* web browser bookmarklet */
javascript:location.href='notube:'+location.href
#!/bin/bash
#todo: allow external audio and sub files
#todo: play from/until a given time position
mpv "$(echo "$@" | sed "s/notube://")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment