Compare commits

...

2 Commits

Author SHA1 Message Date
6735603e9c General cleanup 2026-02-03 04:35:40 +10:00
8e7eb4c534 DiscordRPC: Added internet radio station support 2026-02-02 15:26:15 +10:00
3 changed files with 36 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ Discord RPC Settings:
Enable ('enable') - 'true' to enable Discord RPC or 'false' to disable it
Method ('method'):
- Method '0' is the official local Discord RPC method, local application to local discord client
- Method '1' is a VERY buggy and in-development RPC method that uses a client-server model
- DO NOT USE: Method '1' is a VERY buggy and in-development RPC method that uses a client-server model
to allow Discord RPC from a mobile device securely
Show System Details ('showSystemDetails') - 'true' or 'false'
- Want to show off / Got bragging rights on your _unique_ system?? Well this is perfect for you!
@@ -25,3 +25,20 @@ Show System Details ('showSystemDetails') - 'true' or 'false'
Example: 'on Linux x86_64 6.17.1-arch1-1' will be shown in the RPC dialog
Go on, don't be shy, show everyone you somehow have Discord and OSSP running on fucking s390x!!!
- Setting this to 'false' will simply instead show what playlist you are playing.
Show Cover Art ('showCoverArt') - 'true' or 'false'
- If this is set to true, the cover art for the song playing will be shown on the Discord rich presence.
This can be disabled because the OpenSubsonic API does not have an unauthenticated way of accessing
album art from a server, which means you have to leak an authenticated server URL to Discord (Which
a lot of people would not feel comfortable doing, understandably).
- If this is set to false, Discord rich presence only shows the app icon, and does not leak any authenticated
URLs to Discord servers
Radio Sqlite3 Database Drafting:
Location: $HOME/.config/ossp/radio.db
Table: stations
- Int: id
- String: name
- String: url

View File

@@ -3,7 +3,6 @@
* Goldenkrew3000 2025
* License: GNU General Public License 3.0
* Discord Local RPC Handler
* Note: This provides server auth creds (encoded) directly to Discord, could use Spotify's API instead??
*/
#include <inttypes.h>
@@ -60,7 +59,7 @@ static void handleDiscordError(int errcode, const char* message)
}
int discordrpc_init() {
printf("[DiscordRPC] Initializing...\n");
printf("[DiscordRPC] Initializing.\n");
DiscordEventHandlers handlers;
memset(&handlers, 0, sizeof(handlers));
handlers.ready = handleDiscordReady;
@@ -87,7 +86,8 @@ void discordrpc_update(discordrpc_data** discordrpc_struct) {
if ((*discordrpc_struct)->state == DISCORDRPC_STATE_IDLE) {
asprintf(&detailsString, "Idle");
presence.details = detailsString;
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PLAYING) {
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PLAYING_SONG) {
// Playing a song
time_t currentTime = time(NULL);
asprintf(&detailsString, "%s", (*discordrpc_struct)->songTitle);
asprintf(&stateString, "by %s", (*discordrpc_struct)->songArtist);
@@ -99,6 +99,18 @@ void discordrpc_update(discordrpc_data** discordrpc_struct) {
if (configObj->discordrpc_showSysDetails) {
presence.largeImageText = discordrpc_osString;
}
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PLAYING_RADIO) {
// Playing an internet radio station
time_t currentTime = time(NULL);
asprintf(&detailsString, "%s", (*discordrpc_struct)->songTitle);
asprintf(&stateString, "Internet radio station");
presence.details = detailsString;
presence.state = stateString;
presence.largeImageKey = (*discordrpc_struct)->coverArtUrl;
presence.startTimestamp = (long)currentTime;
if (configObj->discordrpc_showSysDetails) {
presence.largeImageText = discordrpc_osString;
}
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PAUSED) {
}

View File

@@ -8,8 +8,9 @@
#define _DISCORDRPC_H
#define DISCORDRPC_STATE_IDLE 0
#define DISCORDRPC_STATE_PLAYING 1
#define DISCORDRPC_STATE_PAUSED 2
#define DISCORDRPC_STATE_PLAYING_SONG 1
#define DISCORDRPC_STATE_PLAYING_RADIO 2
#define DISCORDRPC_STATE_PAUSED 4
typedef struct {
int state;