Skip to content

Commit

Permalink
Adds support for quickly adding players
Browse files Browse the repository at this point in the history
Closes #96
Possibly resolves #95
  • Loading branch information
Smaltin committed May 21, 2024
1 parent 170e201 commit 651ea4d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 107 deletions.
3 changes: 3 additions & 0 deletions DiscordPresenceConfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ tidal=true=922625678271197215
amazon music=true=808571949227049000
mediamonkeyengine=true=1096929771511873587
foobar2000=true=1009193842211299428
musiccenter=true=1224842583340089424
msedge=false=1223074808540037310
amplibraryagent=true=868974911178285056

verbose=false
debug missing player=false
Expand Down
150 changes: 44 additions & 106 deletions MDRP/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,9 @@ internal partial class Program
new Uri("https://api.github.com/repos/jojo2357/Music-Discord-Rich-Presence/releases/latest");

//Player Name, client
private static readonly Dictionary<string, DiscordRpcClient> DefaultClients =
private static Dictionary<string, DiscordRpcClient> DefaultClients =
new Dictionary<string, DiscordRpcClient>
{
{ "music.ui", new DiscordRpcClient("807774172574253056", autoEvents: false) },
{ "microsoft.media.player", new DiscordRpcClient("807774172574253056", autoEvents: false) },
{ "wmplayer", new DiscordRpcClient("807774172574253056", autoEvents: false) },
{ "musicbee", new DiscordRpcClient("820837854385012766", autoEvents: false) },
{ "spotify", new DiscordRpcClient("802222525110812725", autoEvents: false) },
{ "tidal", new DiscordRpcClient("922625678271197215", autoEvents: false) },
{ "tidalplayer", new DiscordRpcClient("922625678271197215", autoEvents: false) },
{ "wavelink", new DiscordRpcClient("927328178618376212", autoEvents: false) },
{ "amazon music", new DiscordRpcClient("807774172574253056", autoEvents: false) },
{ "mediamonkeyengine", new DiscordRpcClient("1096929771511873587", autoEvents: false) },
{ "foobar2000", new DiscordRpcClient("1009193842211299428", autoEvents: false) },
{ "", new DiscordRpcClient("821398156905283585", autoEvents: false) }
};

Expand All @@ -74,110 +63,24 @@ internal partial class Program
{ "music.ui", true }
};

private static readonly Dictionary<string, ConsoleColor> PlayerColors = new Dictionary<string, ConsoleColor>
{
{ "music.ui", ConsoleColor.Blue },
{ "microsoft.media.player", ConsoleColor.Blue },
{ "wmplayer", ConsoleColor.Blue },
{ "spotify", ConsoleColor.DarkGreen },
{ "musicbee", ConsoleColor.Yellow },
{ "tidal", ConsoleColor.Gray },
{ "tidalplayer", ConsoleColor.Gray },
{ "wavelink", ConsoleColor.DarkBlue },
{ "amazon music", ConsoleColor.Gray },
{ "foobar2000", ConsoleColor.DarkCyan},
{"mediamonkeyengine", ConsoleColor.Yellow}
};
private static Dictionary<string, ConsoleColor> PlayerColors = new Dictionary<string, ConsoleColor>();

private static string _presenceDetails = string.Empty;

private static readonly string[] ValidPlayers =
{
"music.ui", "spotify", "musicbee", "microsoft.media.player", "wmplayer", "tidal", "tidalplayer", "wavelink", "amazon music", "foobar2000", "mediamonkeyengine"
};
private static List<string> ValidPlayers = new List<string>();

private static readonly string[] RequiresPipeline = { "musicbee" };

//For use in settings
private static readonly Dictionary<string, string> Aliases = new Dictionary<string, string>
{
{ "musicbee", "Music Bee" },
{ "spotify", "Spotify Music" },
{ "groove", "Groove Music Player" },
{ "microsoft.media.player", "Windows Media Player" },
{ "wmplayer", "Windows Media Player" },
{ "music.ui", "Groove Music Player" },
{ "tidal", "Tidal Music" },
{ "tidalplayer", "Tidal Music" },
{ "wavelink", "Wave Link" },
{ "amazon music", "Amazon Music" },
{ "foobar2000", "FooBar2000"},
{ "mediamonkeyengine", "MediaMonkey5"}
};
private static Dictionary<string, string> Aliases = new Dictionary<string, string> ();

private static readonly Dictionary<string, string> BigAssets = new Dictionary<string, string>
{
{ "musicbee", "https://cdn.discordapp.com/app-assets/820837854385012766/820838584617009222.png" },
{ "music.ui", "https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png" },
{ "amazon music", "https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png" },
{
"microsoft.media.player",
"https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png"
},
{ "spotify", "https://cdn.discordapp.com/app-assets/802222525110812725/802222954821582869.png" },
{ "tidal", "https://cdn.discordapp.com/app-assets/922625678271197215/978018192393920562.png" },
{ "tidalplayer", "https://cdn.discordapp.com/app-assets/922625678271197215/978018192393920562.png" },
{ "wavelink", "https://cdn.discordapp.com/app-assets/927328178618376212/927329727180574760.png" },
{ "foobar2000", "https://cdn.discordapp.com/app-assets/1009193842211299428/1009196080853950464.png" },
{"mediamonkeyengine", "https://cdn.discordapp.com/app-assets/1096929771511873587/1096930933325713519.png"}
};
private static Dictionary<string, string> BigAssets = new Dictionary<string, string>();

//might just combine these later
private static readonly Dictionary<string, string> LittleAssets = new Dictionary<string, string>
{
{ "musicbee", "https://cdn.discordapp.com/app-assets/820837854385012766/820838635703500810.png" },
{ "music.ui", "https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png" },
{ "amazon music", "https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png" },
{
"microsoft.media.player",
"https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png"
},
{ "spotify", "https://cdn.discordapp.com/app-assets/802222525110812725/802222992683827200.png" },
{ "tidal", "https://cdn.discordapp.com/app-assets/922625678271197215/978018192637198406.png" },
{ "tidalplayer", "https://cdn.discordapp.com/app-assets/922625678271197215/978018192637198406.png" },
{ "wavelink", "https://cdn.discordapp.com/app-assets/927328178618376212/927329727218319410.png" },
{ "foobar2000", "https://cdn.discordapp.com/app-assets/1009193842211299428/1009196080950423563.png" },
{"mediamonkeyengine", "https://cdn.discordapp.com/app-assets/1096929771511873587/1096930933325713519.png"}
};
private static Dictionary<string, string> LittleAssets = new Dictionary<string, string>();

private static readonly Dictionary<string, string> Whatpeoplecallthisplayer = new Dictionary<string, string>
{
{ "musicbee", "Music Bee" },
{ "music.ui", "Groove Music" },
{ "microsoft.media.player", "Windows Media Player" },
{ "wmplayer", "Windows Media Player" },
{ "spotify", "Spotify" },
{ "tidal", "Tidal Music" },
{ "tidalplayer", "Tidal Music" },
{ "wavelink", "Wave Link" },
{ "amazon music", "Amazon Music" },
{ "foobar2000", "FooBar2000"},
{"mediamonkeyengine", "MediaMonkey5"}
};
private static Dictionary<string, string> Whatpeoplecallthisplayer = new Dictionary<string, string>();

private static readonly Dictionary<string, string> InverseWhatpeoplecallthisplayer =
new Dictionary<string, string>
{
{ "musicbee", "musicbee" },
{ "groove", "music.ui" },
{ "Microsoft.Media.Player", "microsoft.media.player" },
{ "spotify", "spotify" },
{ "Tidal Music", "tidal" },
{ "Wave Link", "wavelink" },
{ "Amazon Music", "anazon music" },
{ "FooBar2000", "foobar2000"},
{"MediaMonkey5", "mediamonkeyengine"}
};
private static Dictionary<string, string> InverseWhatpeoplecallthisplayer = new Dictionary<string, string>();

private static readonly string defaultPlayer = "groove";
private static readonly int timeout_seconds = 60;
Expand Down Expand Up @@ -1266,6 +1169,41 @@ private static bool IsUsingAudio()

private static void LoadSettings()
{
try
{
string[] lines = File.ReadAllLines("../../../SupportedPlayers.dat");
foreach (string line in lines)
{
if (!line.StartsWith("#"))
{
string[] explodedLine = Regex.Split(line, @"==");
if (bool.Parse(explodedLine[2]))
{
//Format: executable name==display name==enabled==discord application id==console color==asset link
string execName = explodedLine[0];
string displayName = explodedLine[1];
string appid = explodedLine[3];
ConsoleColor color = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), explodedLine[4], true);
string assetLink = explodedLine[5];

DefaultClients.Add(execName, new DiscordRpcClient(appid, autoEvents: false));
PlayerColors.Add(execName, color);
Aliases.Add(execName, displayName);
BigAssets.Add(execName, assetLink);
LittleAssets.Add(execName, assetLink);
Whatpeoplecallthisplayer.Add(execName, displayName);
if (!InverseWhatpeoplecallthisplayer.ContainsKey(displayName))
InverseWhatpeoplecallthisplayer.Add(displayName, execName);
ValidPlayers.Add(execName);
}
}
}
}
catch (Exception e)
{
Functions.SendToDebugServer("SupportedPlayers.dat INVALID"); //either no perms or formatted incorrectly
Functions.SendToDebugServer(e);
}
try
{
string[] lines = File.ReadAllLines("../../../DiscordPresenceConfig.ini");
Expand Down Expand Up @@ -1506,7 +1444,7 @@ private static void parseWildcardKeying(string[] lines)
}

foreach (string playerCandidate in lines[0].Split('=')[1] == "*"
? ValidPlayers
? ValidPlayers.ToArray()
: lines[0].Split('=')[1].ToLower().Split(','))
{
if (useDefaults)
Expand Down
9 changes: 8 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ There may be more to come, time will tell.
- Includes batch scripts to run MDRP when your music player is started, and will close MDRP when your player closes
- Can toggle on or off certain music players
- Can change the default name of the application in Discord, so you could have `Playing Music` instead of `Playing Groove Music`
- Ability to add your own music player support, assuming the player outputs to WMC properly

## Setup
0. Download the [latest release](https://github.com/jojo2357/Music-Discord-Rich-Presence/releases/latest)
Expand Down Expand Up @@ -68,12 +69,18 @@ You can set in the settings file `get remote artwork` and `create cache file`. T
Right now you can only use the old library, so don't use this for now.

### The Spotify Way
If you would like to key all of your Spotify playlists, go to the [MDRP website](https://mdrp.tech/fetchalbumart) (under construction, please be patient) and click `Regenerate Token`, then select either `Include Artists` (recommended) or `Exclude Artists` and then download the dat (may take up to 5 minutes if you have a ton of songs) and place it in your clientdata folder.
If you would like to key all of your Spotify playlists, go to the [MDRP website](https://smaltin.dev/fetchalbumart) (under construction, please be patient) and click `Regenerate Token`, then select either `Include Artists` (recommended) or `Exclude Artists` and then download the dat (may take up to 5 minutes if you have a ton of songs) and place it in your clientdata folder.

## Changing MDRP Settings
To change any MDRP settings, they will all be located in your `DiscordPresenceConfig.ini` file.\
Data in this file is in `key=value` pairs so any line that does not have a `=` will be ignored.

## Adding a custom player
Assuming the player outputs properly to WMC, it can be added as a new player. Open `SupportedPlayers.dat`, and following the schema below, fill out the information.

`executable name==display name==enabled==discord application id==console color==asset link`

Discord application id can be created by navigating to the [Discord developer dashboard](https://discord.com/developers/applications) and creating an application. The asset link should be a link to the player's icon, this is what you'll see as both the small icon and the large one if no album art is keyed. The console color should be a valid C# ConsoleColor.
### Changing default background
In the ini config file, there is the option to change the default background on a per-player setting. The schema is `large <player> asset=url/application asset`. For example, to change the default background of MusicBee to the album cover of "My Head is an Animal", you would put:

Expand Down
15 changes: 15 additions & 0 deletions SupportedPlayers.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Format: executable name==display name==enabled==discord application id==console color==asset link
musicbee==Music Bee==true==820837854385012766==Yellow==https://cdn.discordapp.com/app-assets/820837854385012766/820838584617009222.png
groove==Groove Music==true==807774172574253056==Blue==https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png
music.ui==Groove Music==true==807774172574253056==Blue==https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png
microsoft.media.player==Windows Media Player==true==807774172574253056==Blue==https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png
wmplayer==Windows Media Player==true==807774172574253056==Blue==https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png
spotify==Spotify==true==802222525110812725==DarkGreen==https://cdn.discordapp.com/app-assets/802222525110812725/802222954821582869.png
tidal==Tidal Music==true==922625678271197215==Gray==https://cdn.discordapp.com/app-assets/922625678271197215/978018192393920562.png
tidalplayer==Tidal Music==true==922625678271197215==Gray==https://cdn.discordapp.com/app-assets/922625678271197215/978018192393920562.png
wavelink==Wave Link==true==927328178618376212==DarkBlue==https://cdn.discordapp.com/app-assets/927328178618376212/927329727180574760.png
amazon music==Amazon Music==true==807774172574253056==Gray==https://cdn.discordapp.com/app-assets/801209905020272681/801224923547959376.png
foobar2000==FooBar2000==true==1009193842211299428==DarkCyan==https://cdn.discordapp.com/app-assets/1009193842211299428/1009196080853950464.png
mediamonkeyengine==MediaMonkey5==true==1096929771511873587==Yellow==https://cdn.discordapp.com/app-assets/1096929771511873587/1096930933325713519.png
msedge==Soundcloud==false==1223074808540037310==Red==https://cdn.discordapp.com/app-assets/1223074808540037310/1223076877313376346.png
amplibraryagent==Apple Music==true==868974911178285056==Red==https://cdn.discordapp.com/app-assets/868974911178285056/868975029411545128.png

0 comments on commit 651ea4d

Please sign in to comment.