Click on video thumbnail to play in MPV

Open videos in external player (mpv) by simply clicking on a thumbnail.

目前为 2021-06-13 提交的版本。查看 最新版本

作者
nsinister
评分
0 0 0
版本
0.1
创建于
2021-06-13
更新于
2021-06-13
大小
2.3 KB
许可证
MIT
适用于

Description

This userscript will allow you to open videos in external player mpv by simply clicking on a thumbnail without loading bloated video page with web player.

How it works

It simply replaces video thumbnail hyperlinks on a page, changing their protocol from https:// to mpv:// and coding the original URL as base64. The result string is then passed to mpv:// URI handler as base64 string.

Limitations

  • Live streams aren't supported by mpv + youtube-dl, thus you may want to avoid clicking on live stream thumnails.
  • No solution for Windows yet (will be added later)

Prerequisites in your system

Keep in mind that these instructions are valid for GNU/Linux operating system for now.

Supported sites

  • YouTube
  • Vimeo

Potentially it works with anything that mpv and its youtube-dl backend supports. But in order to add support for a certain website, one needs to find its DOM selector for site specific video thumnails and put it into the dictionary inside the userscript

Installation

Install this script, then follow instructions below

GNU/Linux

$ mkdir -p ~/.local/bin/ && touch ~/.local/bin/mpv-url-handler.sh
$ chmod +x ~/.local/bin/mpv-url-handler.sh
$ mkdir -p ~/.local/share/applications && touch ~/.local/share/applications/mpv-url-handler.desktop

Edit file ~/.local/bin/mpv-url-handler.sh with a text editor, put the following contents

#!/bin/sh
mpv `echo -n $1 | sed 's/mpv:\/\///' | base64 --decode`

Edit file ~/.local/share/applications/mpv-url-handler.desktop


[Desktop Entry]
Type=Application
Name=mpv-url-handler
GenericName=Multimedia player
Comment=Play web media content with mpv
NoDisplay=true
Icon=mpv
Terminal=false
Categories=AudioVideo;Audio;Video;Player;TV;
MimeType=x-scheme-handler/mpv;
X-KDE-Protocols=mpv

Finally, register mpv URL handler for mpv://

$ echo "Exec=$HOME/.local/bin/mpv-url-handler.sh %u" >> ~/.local/share/applications/mpv-url-handler.desktop
$ xdg-mime default mpv-url-handler.desktop x-scheme-handler/mpv

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址