Skip to content

Play videos and songs on the website via mpv-handler, without any background service.

License

Notifications You must be signed in to change notification settings

mofanx/mpv-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c2f2c5c · Jul 26, 2021

History

45 Commits
Jul 25, 2021
Jul 26, 2021
Jul 26, 2021
Jul 26, 2021
Mar 3, 2021
Mar 3, 2021
Jul 25, 2021
Jul 25, 2021
Mar 3, 2021
Jul 26, 2021
Jul 26, 2021
Jul 26, 2021

Repository files navigation

mpv handler

A protocol handler for mpv, written by Rust.

Please use with userscript:

play-with-mpv

Installation

Linux

  • Arch Linux

    mpv-handler
    mpv-handler-git

Manual installation

  1. Download latest/mpv-handler-linux-x64.zip
  2. Unzip the archive
  3. Copy mpv-handler to $HOME/.local/bin
  4. Copy mpv-handler.desktop to $HOME/.local/share/applications/
  5. Copy config.toml to $HOME/.config/mpv-handler/
  6. Add $HOME/.local/bin to your environment variable PATH (if it not lists in your PATH)
  7. Register xdg-mime (thanks for the linuxuprising reminder)
$ xdg-mime default mpv-handler.desktop x-scheme-handler/mpv
  1. Create $HOME/.config/mpv-handler/custom.toml and edit it, if needed

Windows

Windows users need to install mpv-handler manually.

Manual installation

  1. Download latest/mpv-handler-windows-x64.zip
  2. Unzip the archive to the directory you want (since v0.2.x, not requires to install in the same directory with mpv anymore)
  3. Run handler-install.bat register protocol handler
  4. Create custom.toml in the same directory as mpv-handler.exe and edit it

Protocol URL

Base URL:

mpv://BASE64_ENCODE_VIDEO_URL/

Optional parameters:

cookies     = [ www.domain.com.txt ]
downloader  = [ mpv, ytdl, you-get, streamlink, and more...] (default: mpv)
quality     = [ best, 2160p, 1440p, 1080p, 720p, 480p, 360p, and more... ]

c = cookies
d = downloader
q = quality

Example:

mpv://aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj01cWFwNWFPNGk5QQ==/?cookies=www.youtube.com.txt&downloader=mpv&quality=best

mpv://aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1wNVFmeUY5cGtIVQ==/?c=www.youtube.com.txt&d=mpv&q=best

Custom Configuration

The default config.toml configuration is like this:

# Don't edit this file!
# This is default settings, It will be overwritten when update mpv-handler.
#
# For customize settings, create and edit file:
# - Linux:
#     - $HOME/.config/mpv-handler/custom.toml
#     - /etc/mpv-handler/custom.toml
#   If the first one is found, the second one will not be loaded.
# - Windows: custom.toml (in the same directory as mpv-handler.exe)

### Player ###
player = "/usr/bin/mpv"

### Video Downloader ###
[mpv]
bin = "/usr/bin/mpv"
cookies = "--ytdl-raw-options-append=cookies="
cookies_prefix = true
play_mode = "direct"
quality.best = "--ytdl-format=bestvideo+bestaudio/best"
quality.2160p = "--ytdl-format=bestvideo[height<=2160]+bestaudio/best[height<=2160]/best"
quality.1440p = "--ytdl-format=bestvideo[height<=1440]+bestaudio/best[height<=1440]/best"
quality.1080p = "--ytdl-format=bestvideo[height<=1080]+bestaudio/best[height<=1080]/best"
quality.720p = "--ytdl-format=bestvideo[height<=720]+bestaudio/best[height<=720]/best"
quality.480p = "--ytdl-format=bestvideo[height<=480]+bestaudio/best[height<=480]/best"
quality.360p = "--ytdl-format=bestvideo[height<=360]+bestaudio/best[height<=360]/best"

[ytdl]
bin = "/usr/bin/youtube-dl"
cookies = "--cookies"
play_mode = "pipe"
options = ["--quiet", "--output", "-"]

[you-get]
bin = "/usr/bin/you-get"
cookies = "--cookies"
options = ["--player"]

[streamlink]
bin = "/usr/bin/streamlink"
require_quality = true
options = ["--player"]
quality.best = "--default-stream=best"
quality.worst = "--default-stream=worst"

Generally, users only need to edit player and downloader bin to corresponding executable binary.

For this, users can create custom.toml to overwrite default settings:

# For Windows users,
# The path format can be "C:\\folder\\some.exe" or "C:/folder/some.exe"
player = "/usr/bin/vlc"

[ytdl]
bin = "/usr/local/bin/youtube-dl"
options = ["-o", "-"]

# Warning:
# Developer isn't recommend users change default downloader settings except "bin".
#
# If you've changed "quality.LEVEL" for default downloader,
# You will lost other "quality.LEVEL" from default settings.
# Here, you will be lost "quality.worst".
[streamlink]
quality.best = "bestvideo"

# For advanced user, you can add other downloader manually.
#
# Example:
[example]
bin = "/usr/bin/example"
cookies = "--cookies"
cookies_prefix = false
require_quality = false
play_mode = "normal"
options = ["--player"]
player_options = ["--http-header-fields='referer: https://www.domain.com'"]
quality.best = "--quality=best"
quality.worst = "--quality=worst"

# [example]       Required, Type: String
#                     The value "example" is downloader table name
# bin             Required, Type: String
#                     The downloader executable binary path
# cookies         Optional, Type: String (default: "")
#                     The downloader parameter of passthorgh cookies
# cookies_prefix  Optional, Type: Boolen (default: false)
#                     Set to true to mark cookies parameter as prefix
# require_quality Optional, Type: Boolen (default: false)
#                     Set to true to mark the downloader requires a quality LEVEL given
# play_mode       Optional, Type: String [normal, direct, pipe] (default: "normal")
#                     The mode of downloader to run player
# options         Optional, Type: Array of Strings (default: [])
#                     The parameters of downloader to set player or output
# player_options  Optional, Type: Array of Strings (default: [])
#                     The parameters of player for some special purposes
# quality.LEVEL   Optional, Type: String
#                     The LEVEL is a key name
#                     The value is parameter of downloader to choose quality/format

About

Play videos and songs on the website via mpv-handler, without any background service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 85.3%
  • Batchfile 14.7%