Modern browsers are very complicated programs, especially because they also need to be secure to protect users from countless threats on the interwebs. That means that the plugins functionality is necessarily quite limited. Firefox used to have XUL extensions, allowing to have the powerful
vimperator; but from Firefox 57, only WebExtensions API is supported. There is a replacement for
vimperator written with the WebExtensions API:
tridactyl, however it’s more limited.
Lots of websites now provide video content. But sometimes videos have ads, sometimes the player’s interface is inconvenient, or the video is blocked on the page even though it can be loaded if you know the link.
youtube-dl is an amazing program that can download videos from dozens of websites. How do you make it work with your current tab in Firefox?
My solution is to use tridactyl’s
exclaim_quiet command that allows to run a command in shell. It requires the native messenger to be installed, check with
:native; to install, run
mpv is the CLI media player nowadays (replacement for
mplayer) and it has built-in support for
youtube-dl. Make sure
mpv is installed, it will bring
youtube-dl as a dependency:
Put this into your
This command binds
,v to run the composite command: get the current tab’s URL, replace
ytdl:// to force
mpv to use
youtube-dl, escape the URL, prepend the
$PATH setting and the
mpv command, and launch the resulting command silently.
Having this in the file, either run
:source in the tridactyl’s command-line or restart Firefox.
Finally you can press
,v on any webpage that
youtube-dl knows about and
mpv should start playing the video, now you have all the power and options of
mpv to enjoy the video. Note that
youtube-dl will also attempt to get a video URL from domain that it doesn’t know about, it may work.
My first attempt was to run
mpv directly and avoid the shell:
but it didn’t work:
[ytdl_hook] [ytdl_hook] youtube-dl failed: not found or not enough permissions Failed to recognize file format.Exiting... (Errors when loading file).
I switched to creating the command-line for shell with the same result:
Enabling debug logs:
revealed the issue:
Hence the final command above that sets
$PATH to include