Discord Rich Presence for ani-cli.
Rich Presence is the box on your Discord profile that shows what you are doing. This puts your anime there while you watch: the title, which episode you are on, whether it is subbed or dubbed, how much time is left, and the cover art.
An example of how the card looks.
You do not run anything alongside ani-cli. You install this once, then keep using ani-cli exactly the way you already do.
ani-cli is a bash script, so a Unix shell is required either way. On Windows that comes from Git for Windows, which ani-cli already needs.
| You need | Why |
|---|---|
| ani-cli 5.x | The program this attaches to |
| mpv | The video player ani-cli opens |
| Git for Windows | Provides the bash shell that ani-cli and this both run in |
| The Discord desktop app | Rich Presence does not exist in Discord in a browser |
| Python 3.8 or newer | Only if you install from source. The download below does not need it |
This is a Windows tool today. See Linux for where that stands.
1. Download anirpc-windows-x64.zip from
Releases.
2. Extract it anywhere, as long as the folder path has no spaces in it. This
matters more than it looks: ani-cli starts the player without quoting the path, so a
space in it breaks the launch. C:\Tools\anirpc is fine, C:\My Programs\anirpc is
not.
3. Double-click anirpc.exe. It changes one setting on your account and exits
straight away. That is the whole install.
4. Open a new terminal and run ani-cli the way you normally would.
That is it. Nothing sits running in the background until you play something, there is no extra command to remember, and you never hand over any Discord login details. The presence appears when playback starts.
Note
Windows will probably warn you the first time. You will see "Windows protected your PC". That happens because the file is not code-signed, which costs money, so Windows does not recognise it yet. Click More info and then Run anyway. If you would rather not, use Install from source instead. It does exactly the same job and is a short PowerShell script you can read first.
To undo everything, run anirpc.exe --uninstall.
| On the card | Comes from |
|---|---|
| Anime title and episode | The title ani-cli hands to mpv |
| Sub or Dub | The audio track language, falling back to the --dub flag |
| Time remaining | mpv's live position and total length |
| Resolution | mpv's video height |
| Cover art, episode count, AniList link | AniList, cached on your machine |
Sub or dub has to be worked out rather than read, because ani-cli never tells the player
which one you picked. The audio track's language tag is the most reliable answer, since
it describes what is actually playing. When a stream carries no language tag, the --dub
flag ani-cli was run with is used instead.
ani-cli lets you choose which player it opens, through a setting called
ANI_CLI_PLAYER. Installing points that setting at bin/anirpc-mpv, a small script
that starts the presence program and then opens the real mpv.
ani-cli itself is never modified. That is deliberate. ani-cli -U updates itself by
patching its own file, and an edited copy would make that fail.
ani-cli ──ANI_CLI_PLAYER──> bin/anirpc-mpv ──starts──> mpv.exe
│ │
run/session.json private connection
└──────> anirpc.exe <──┘
│
└──> Discord
Two details that look strange but are doing real work:
- The shim's filename has to contain
mpv. ani-cli looks at the player's name and only passes the media title along when the name looks like mpv. That title is where the anime name and episode number come from. - Cover art is a link, not an upload. The image is AniList's own URL, so there is nothing to upload or set up on the Discord side.
Everything lives in config.json, in the same folder as the exe. It works as shipped,
so all of this is optional.
| Setting | Default | What it does |
|---|---|---|
client_id |
(included) | The Discord application whose name shows as the heading. See below |
activity_type |
3 |
3 reads "Watching", 2 reads "Listening", 0 reads "Playing" |
timestamp_mode |
"remaining" |
remaining counts down, elapsed counts up |
show_cover_art |
true |
Show the AniList cover image |
show_anilist_button |
true |
Show a "View on AniList" button |
detect_dub_from_audio_track |
true |
Trust the audio language over the command line flag |
idle_exit_seconds |
300 |
Shut down after this many seconds with nothing playing |
debug |
false |
Print more detail while running |
If timestamp_mode is "remaining", then activity_type has to stay 2 or 3.
Discord refuses a countdown on any other type. With 0 (Playing), use "elapsed".
The bold line above the title is the name of a Discord application, not something this
tool sets. The included one is named Anime, which is why profiles read "Watching
Anime".
To change it, make your own application:
- Go to the Discord Developer Portal and click New Application.
- Name it whatever you want the heading to say.
- Copy the Application ID from General Information.
- Put it in
config.json:
{ "client_id": "1234567890123456789" }There is no bot and no login involved. An Application ID is a public identifier rather than a secret, which is why one can be included here at all. This tool never asks for your Discord account details.
Use this if Windows quarantined the exe, or if you would rather read the code you are about to run:
git clone https://github.com/KernelSpecter/anicli-rpc
cd anicli-rpc
powershell -ExecutionPolicy Bypass -File .\install.ps1Uninstall with -Uninstall. This route needs Python 3.8 or newer on your PATH, but
nothing to install with pip: it uses only what comes with Python.
Both routes can sit side by side. The shim uses anirpc.exe if it finds one and falls
back to Python if not.
Look at run/anirpc.log first. A healthy session looks like this, with one presence:
line each time something actually changes rather than a constant stream:
11:06:30 daemon: start
11:06:30 mpv: connected \\.\pipe\anirpc-mpv-1868-1786599389
11:06:31 discord: connected via \\.\pipe\discord-ipc-0
11:06:31 presence: Frieren: Beyond Journey's End | Episode 4 of 28 · Sub
Nothing appears on my profile at all
Discord has to be the installed desktop app, not Discord in a browser tab, and it has to be open before you start playing. Then check that Settings > Activity Privacy > Share your detected activities is turned on.
The log says discord: pipe closed during handshake
Discord was not running, or was in the middle of restarting, when this tried to connect. Start Discord, then start the next episode.
ani-cli says "Program ... not found"
Extracting a zip drops the permission that marks the shim as runnable. Re-run
anirpc.exe, which fixes and then checks it. Or do it yourself in git-bash:
chmod +x ./bin/anirpc-mpvThe buttons on the card do not show up
Discord never shows activity buttons on your own profile. Other people can see them.
It says Sub when it is Dub, or the other way round
Some streams carry no audio language tag to read. Set
"detect_dub_from_audio_track": false to use ani-cli's --dub flag instead.
I want to see what it would post, without involving Discord
anirpc.exe --dry-runThis prints each update as it happens, and can run at the same time as the real thing.
It never contacts Discord, so it cannot tell you whether your client_id or your
connection is good, only what would be sent.
I moved the folder and it stopped working
Run anirpc.exe again to update the path. The new path still cannot contain spaces.
The Linux code is here and installs with ./install.sh, but treat it as untested.
Windows and Linux need genuinely different plumbing for this. Windows uses named pipes, Linux uses Unix sockets, and one piece of code cannot open both. The Linux version is written, and an automated test of it runs on a real Linux machine in CI, which is good evidence that the connection logic works.
What nobody has checked is the part that test cannot cover: whether the presence really shows up on a Linux Discord client. If you use Linux, trying it and opening an issue with the result is the most useful thing you could contribute right now.
ani-cli by pystardust, which this hooks into without changing a line of it. Anime data and cover art from AniList.
MIT licensed, see LICENSE.
