INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: [release] JRiver Discord Rich Presence (Python)  (Read 505 times)

BerserkeR

  • Member
  • *
  • Posts: 4
[release] JRiver Discord Rich Presence (Python)
« on: March 18, 2025, 05:04:11 pm »

JRiver Discord Rich Presence Integration – Release & Setup Guide

I’m sharing a Python script that integrates JRiver Media Center with Discord Rich Presence. (Because the devs don't bother integrating discord, or vice versa /cry)
This script leverages Windows named pipes (raw IPC) to update your Discord status in real time, displaying what’s playing on JRiver.
Below you’ll find a comprehensive guide covering the features, prerequisites, file structure, environment setup, and execution instructions.



Prerequisites:

OS: Windows 10/11.

1. Discord Application Setup
You must create a Discord application via the Discord Developer Portal.

Why? The script requires a Client ID from your Discord application to connect via IPC, not your personal Discord account ID.
How to Create:
Go to the Developer Portal.
Click New Application and call it JRiver.
Under the General Information section, copy the Client ID.
Use this Client ID in your [.env] file (instructions below).

2. API Keys & Required Packages
You’ll need a Last.fm API key to retrieve album art. Register at Last.fm API and get your API key.

3. Enable JRiver MCWS
Tools > Media Network > Use Media Network to share this library and enable DLNA

Required Python packages:
requests
python-dotenv

File Structure & Content

You’ll need to create the following files in your project directory:

1. script.py
Copy and paste the complete Python script (shown below) into this file. This script connects to JRiver, fetches playback info, retrieves album art, and sends updates to Discord.
Code: [Select]
Code block for script.py removed due to character limit of forum post.
Attached as script.txt to forum post, change the file extension to .py
Updated script on 21/03/25 | DD/MM/YY
Improved album art searching.
Added waiting + clearing state, if playback stopped.


2. .env
Create a file named [.env] in the same directory with the following content (replace the placeholders with your actual keys):

Code: [Select]
LASTFM_API_KEY=your_lastfm_api_key_here
DISCORD_CLIENT_ID=your_discord_app_client_id_here


3. requirements.txt
Create a file named [requirements.txt] and add these lines:

Code: [Select]
requests
python-dotenv

Setting Up Your Python Environment

It’s best to run the script inside a Python virtual environment. Follow these steps:

1. Create the Virtual Environment:
Open your command prompt or terminal in the project directory and run:
Code: [Select]
python -m venv venv
2. Activate the Virtual Environment:
Code: [Select]
venv\Scripts\activate
3. Install the Required Packages:
With the virtual environment activated, run:

Code: [Select]
pip install -r requirements.txt
Creating the Startup Batch File (Windows)

For Windows users, you can create a batch file to run the script in a minimized window. Create a file named START.bat with the following content:

Code: [Select]
@echo off
REM Start the batch file in a minimized window
start /min cmd /c "call venv\Scripts\activate && python script.py && pause"

This batch file will:

Activate the virtual environment.
Run the script.
Keep the window open (so you can see any messages or errors).
Start minimized.

Discord Application Requirement:
Ensure you have created a Discord application and placed its Client ID in your [.env] file. This is essential since the script uses the Client ID (not your personal Discord account ID) to connect via IPC.

Configuration:
Verify that your [.env] file contains valid keys for LASTFM_API_KEY and DISCORD_CLIENT_ID before running the script.

Execution:
Run the script either directly from the command line (with the virtual environment activated) using:
Code: [Select]
python script.py
or by double-clicking START.bat to launch it in a minimized window.

Customization:
You can adjust settings such as the polling interval (POLL_INTERVAL) or the cache file (CACHE_FILE) in script.py to suit your preferences.

FYI:
You’re unable to see your own 'discord-rich-presence buttons' in your Discord client because Discord screwed something up on their end a while ago.
The button to MusicBrainz is still working.

Regarding the START.bat file (which starts the virtual python environment and launches the script minimized)
You can also make a shortcut of that file and call it something like 'JRiver notifs' and give it another icon, for example the icon of the JRiver .exe file and put it on your desktop.
Or come up with one of your own ideas that suit your needs, e.g. an auto launch/close when JRiver is runs, or run the script as a service in the background, etc...

Feel free to improve upon this script and share it with the community.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 73051
  • Where did I put my teeth?
Re: JRiver & Discord Rich Presence (Python)
« Reply #1 on: March 18, 2025, 05:23:55 pm »

Thanks!  Impressive documentation.
Logged
Pages: [1]   Go Up