# cniw/mpv-discordrpc architecture

> Architecture diagram of the GitHub repository cniw/mpv-discordrpc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cniw/mpv-discordrpc
- Repository: https://github.com/cniw/mpv-discordrpc

## Overview

mpv-discordRPC is an mpv script that publishes playback information as Discord Rich Presence. The documented workflow is mpv playback and settings → the main script’s status and presence features → a selected RPC wrapper → Discord. The README also describes playlist/loop information, cover art, URL detections, and active/inactive toggling. Source evidence is limited to the Python wrapper; relationships involving the main Lua script and other unsampled files are based only on README statements, so unverified connections are omitted.

Main entry points: [`mpv-discordRPC/main.lua`](https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/main.lua) (Playback integration), [`mpv-discordRPC/python-pypresence.py`](https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/python-pypresence.py) (Python RPC adapter), [`mpv-discordRPC/lua-discordRPC.lua`](https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/lua-discordRPC.lua) (Lua RPC adapter), [`mpv_discordRPC.conf`](https://github.com/cniw/mpv-discordrpc/blob/master/mpv_discordRPC.conf) (Runtime settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mpv["mpv integration"]
  node_main["Playback integration<br/>[main.lua]"]
  node_config["Runtime settings"]
  node_status["Status line<br/>[status-line.lua]"]
end

subgraph group_presence["Presence features"]
  node_features["Presence details<br/>[main.lua]"]
  node_catalogs["Presence catalogs<br/>[catalogs.lua]"]
end

subgraph group_rpc["RPC adapters"]
  node_lua_rpc["Lua RPC adapter<br/>[lua-discordRPC.lua]"]
  node_python_rpc["Python RPC adapter"]
end

node_player(("mpv player"))
node_pypresence["pypresence library"]
node_discord(("Discord"))

node_player -->|"runs script"| node_main
node_config -->|"configures"| node_main
node_main -->|"uses status"| node_status
node_main -->|"selects wrapper"| node_lua_rpc
node_main -->|"selects wrapper"| node_python_rpc
node_main -->|"provides features"| node_features
node_python_rpc -->|"connects and updates"| node_pypresence
node_python_rpc -->|"updates presence"| node_discord
node_lua_rpc -->|"publishes presence"| node_discord

click node_main "https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/main.lua"
click node_config "https://github.com/cniw/mpv-discordrpc/blob/master/mpv_discordRPC.conf"
click node_status "https://github.com/cniw/mpv-discordrpc/blob/master/status-line.lua"
click node_features "https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/main.lua"
click node_catalogs "https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/catalogs.lua"
click node_lua_rpc "https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/lua-discordRPC.lua"
click node_python_rpc "https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/python-pypresence.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_config,node_status toneBlue
class node_features,node_catalogs toneAmber
class node_lua_rpc,node_python_rpc toneMint
class node_player,node_pypresence,node_discord toneIndigo
```

## Components

### mpv integration

- [Playback integration](https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/main.lua): `mpv-discordRPC/main.lua`
- [Runtime settings](https://github.com/cniw/mpv-discordrpc/blob/master/mpv_discordRPC.conf): `mpv_discordRPC.conf`
- [Status line](https://github.com/cniw/mpv-discordrpc/blob/master/status-line.lua): `status-line.lua`

### Presence features

- [Presence details](https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/main.lua): `mpv-discordRPC/main.lua`
- [Presence catalogs](https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/catalogs.lua): `mpv-discordRPC/catalogs.lua`

### RPC adapters

- [Lua RPC adapter](https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/lua-discordRPC.lua): `mpv-discordRPC/lua-discordRPC.lua`
- [Python RPC adapter](https://github.com/cniw/mpv-discordrpc/blob/master/mpv-discordRPC/python-pypresence.py): `mpv-discordRPC/python-pypresence.py`

### Other components

- **mpv player**
- **pypresence library**
- **Discord**

## Connections

- mpv player → Playback integration: runs script (evidence: `README.md`)
- Runtime settings → Playback integration: configures (evidence: `README.md`)
- Playback integration → Status line: uses status (evidence: `README.md`)
- Playback integration → Lua RPC adapter: selects wrapper (evidence: `README.md`)
- Playback integration → Python RPC adapter: selects wrapper (evidence: `README.md`)
- Playback integration → Presence details: provides features (evidence: `README.md`)
- Python RPC adapter → pypresence library: connects and updates (evidence: `mpv-discordRPC/python-pypresence.py`)
- Python RPC adapter → Discord: updates presence (evidence: `mpv-discordRPC/python-pypresence.py`)
- Lua RPC adapter → Discord: publishes presence (evidence: `README.md`)
