Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tnychn/mpv-discord
đ A cross-platform Discord Rich Presence integration for mpv with no external dependencies.
https://github.com/tnychn/mpv-discord
discord discord-rich-presence golang lua mpv rich-presence
Last synced: 15 days ago
JSON representation
đ A cross-platform Discord Rich Presence integration for mpv with no external dependencies.
- Host: GitHub
- URL: https://github.com/tnychn/mpv-discord
- Owner: tnychn
- License: mit
- Created: 2020-11-22T07:31:41.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-28T13:56:48.000Z (8 months ago)
- Last Synced: 2024-08-02T05:11:13.375Z (4 months ago)
- Topics: discord, discord-rich-presence, golang, lua, mpv, rich-presence
- Language: Go
- Homepage:
- Size: 32.6 MB
- Stars: 170
- Watchers: 6
- Forks: 14
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-discord-activities - mpv-discord - A cross-platform Discord Rich Presence integration for [mpv](https://mpv.io) with no external dependencies. (Media)
- awesome-mpv - discord - A cross-platform Discord Rich Presence integration for mpv with no external dependencies. Consists of a Go binary for updating the presence and a Lua script for launching it. (Social)
README
mpv-discord
Discord Rich Presence Integration for MPV Media Player
Left: looping song in playlist (mouse hovering on small icon)
Right: paused in movie## Features
* đ Easy configuration
* đĻ No third-party dependencies
* đ¸ Simple installation (installer scripts included)
* đ Cross-platform (embrace my beloved Golang!)
* âšī¸ Displays song metadata (title, artist, album)
* âŗ Displays real time player state and timestamps
* đ Toggle activation on the fly by key binding
* đģ Automatically hide when player is paused
* đŧ Customizable image assets## Why?
Currently, there are two alternatives I found on GitHub.
1. [cniw/mpv-discordRPC](https://github.com/cniw/mpv-discordRPC)
2. [noaione/mpv-discordRPC](https://github.com/noaione/mpv-discordRPC)**Discord RPC**
In order to interact with Discord Rich Presence using RPC, the client needs to connect to Discord's IPC socket.
However, both of the above alternatives do not keep a connection with Discord's IPC socket, which I think is rather unreliable.See also: [how _mpv-discord_ works](#how-it-works).
**Third-party Dependencies**
Both of the above alternatives require users to install third-party dependencies such as `python-pypresence` or `lua-discordRPC`.
I found it hard to set up the dependencies and I also don't want to mess up my environment.## Installation
Installer scripts for Windows, Linux and OSX are provided.
1. Download .zip from [the latest release](https://github.com/tnychn/mpv-discord/releases/latest) and extract it.
* or you can download .zip by clicking on the green download button in GitHub
* or you can also use `git clone https://github.com/tnychn/mpv-discord.git`
2. Run the installer script of your platform.
* run `install_darwin.sh` in Terminal for OSX
* run `install_linux.sh` in Terminal for Linux
* run `install_windows.bat` by double clicking on it for Windows
3. Before using, you must specify `binary_path` in the config file first.## Configurations
For OSX and Linux, config file is located in `~/.config/mpv/script-opts`.
For Windows, config file is located in where the `mpv.exe` executable is.
* **key** (default: `D`): key binding to toggle activation on the fly
* **active** (default: `yes`): whether to activate at launch
* **client_id**: specify your own client ID to [customize](#customization) the images shown in Rich Presence
* **binary_path**: full path to mpv-discord's binary file
* **socket_path** (default: `/tmp/mpvsocket`):
* `use_static_socket_path=yes`: set the full path to the static IPC socket path
* `use_static_socket_path=no`: set the full path to the directory placing the IPC socket with a *dynamic name*
* **use_static_socket_path** (default: `yes`): whether to use static IPC socket path or *dynamic name* in the path
* **autohide_threshold** (default: `0`): time in seconds before hiding the presence once player is paused (`0` is off)*dynamic name* is in the format of `mpv-discord-1234` where `1234` will be the PID of the mpv instance.
## Customization
Go to [Discord Developer Portal](https://discord.com/developers/applications),
create an application and upload the following art assets with their corresponding asset keys:
* `mpv`: large image (app logo)
* `play`: small image used when playing
* `pause`: small image used when paused
* `loop`: small image used when playing and looping
* `buffer`: small image used when bufferingThen, set the `client_id` option in the config to the application ID.
You can also find the already provided client ids and their image assets [here](./assets/).
Using mpv-discord with IINA, a media player based on mpv.
Client ID: 834116350884577280## How It Works
This plugin consists of 3 files.
1. [`discord.lua`](./scripts/discord.lua) -- mpv user script
2. [`discord.conf`](./script-opts/discord.conf) -- configuration file
3. [`mpv-discord` binary](./mpv-discord/main.go) -- backend binary of the pluginWhen mpv launches, mpv will run all the user scripts including `discord.lua`.
Then `discord.lua` will read the configurations from `discord.conf` and do two things:
(1) create an `input-ipc-server` socket of mpv. (2) start a subprocess of the `mpv-discord` binary.
Then, `mpv-discord` will interact with the `input-ipc-server` to get the player state and properties of mpv.
Finally, `mpv-discord` will update Discord's Rich Presence with the properties through Discord's IPC socket.## Contributing
If you have any ideas on how to improve this project or if you think there is a lack of features,
feel free to open an issue, or even better, open a pull request. All contributions are welcome!---
~ crafted with âĨī¸ by tnychn ~
MIT Š 2024 Tony Chan