Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Players to File #97

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Smaltin marked this conversation as resolved.
Show resolved Hide resolved
string execName = explodedLine[0];
string displayName = explodedLine[1];
string appid = explodedLine[3];
ConsoleColor color = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), explodedLine[4], true);
Smaltin marked this conversation as resolved.
Show resolved Hide resolved
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
Binary file modified MDRP/bin/Release/MDRP.exe
Binary file not shown.
13 changes: 12 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
Smaltin marked this conversation as resolved.
Show resolved Hide resolved

## Setup
0. Download the [latest release](https://github.com/jojo2357/Music-Discord-Rich-Presence/releases/latest)
Expand Down Expand Up @@ -68,12 +69,22 @@ 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.
Smaltin marked this conversation as resolved.
Show resolved Hide resolved

`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.

To complete the process, open `DiscordPresenceConfig.ini` and follow the format `executable name=enabled=discord application id` in a similar style to the above.

If this doesn't work, either the formatting is not correct or the application does not output to WMC and will not work with MDRP.
### 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
32 changes: 16 additions & 16 deletions statistic.csv
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
File,Lines (% total),Code Lines,% Code,Comment Lines,% Comment,Blank Lines,% Blank
MDRPDebugTool.js,11 (100.0%),9,81.8%,0,0.0%,2,18.2%
Program.cs,1633 (99.3%),1406,86.1%,58,3.6%,169,10.3%
AssemblyInfo.cs,36 (2.1%),15,41.7%,17,47.2%,4,11.1%
FindGroove.bat,62 (3.6%),38,61.3%,1,1.6%,23,37.1%
FindSpotify.bat,54 (3.0%),33,61.1%,1,1.9%,20,37.0%
FindWMP.bat,54 (2.9%),33,61.1%,1,1.9%,20,37.0%
Program.cs,1571 (99.3%),1343,85.5%,58,3.7%,170,10.8%
AssemblyInfo.cs,36 (2.2%),15,41.7%,17,47.2%,4,11.1%
FindGroove.bat,62 (3.7%),38,61.3%,1,1.6%,23,37.1%
FindSpotify.bat,54 (3.1%),33,61.1%,1,1.9%,20,37.0%
FindWMP.bat,54 (3.0%),33,61.1%,1,1.9%,20,37.0%
KillHidden.bat,3 (0.2%),2,66.7%,0,0.0%,1,33.3%
KillHiddenSilent.bat,5 (0.3%),3,60.0%,0,0.0%,2,40.0%
LinkSystemStartAndMDRP.bat,17 (0.9%),11,64.7%,0,0.0%,6,35.3%
LinkWithGroove.bat,53 (2.7%),34,64.2%,2,3.8%,17,32.1%
LinkWithSpotify.bat,51 (2.6%),33,64.7%,2,3.9%,16,31.4%
LinkWithWMP.bat,51 (2.5%),33,64.7%,2,3.9%,16,31.4%
LinkWithGroove.bat,53 (2.8%),34,64.2%,2,3.8%,17,32.1%
LinkWithSpotify.bat,51 (2.7%),33,64.7%,2,3.9%,16,31.4%
LinkWithWMP.bat,51 (2.6%),33,64.7%,2,3.9%,16,31.4%
RunHidden.bat,10 (0.5%),6,60.0%,0,0.0%,4,40.0%
UnlinkFromGroove.bat,22 (1.1%),15,68.2%,0,0.0%,7,31.8%
UnlinkFromSpotify.bat,22 (1.1%),15,68.2%,0,0.0%,7,31.8%
UnlinkFromSystemStart.bat,21 (1.0%),14,66.7%,0,0.0%,7,33.3%
UnlinkFromWMP.bat,22 (1.0%),15,68.2%,0,0.0%,7,31.8%
UnlinkFromWMP.bat,22 (1.1%),15,68.2%,0,0.0%,7,31.8%
delete_sensitive_files.bat,1 (0.0%),1,100.0%,0,0.0%,0,0.0%
Album.cs,82 (3.7%),63,76.8%,8,9.8%,11,13.4%
ExternalArtManager.cs,245 (10.0%),220,89.8%,0,0.0%,25,10.2%
Functions.cs,250 (9.2%),213,85.2%,9,3.6%,28,11.2%
JsonResponse.cs,103 (3.7%),93,90.3%,1,1.0%,9,8.7%
LangHelper.cs,155 (5.2%),147,94.8%,0,0.0%,8,5.2%
Music_DRP_Launcher.bat,73 (2.4%),51,69.9%,21,28.8%,1,1.4%
Total,3036,2503,0.8,123,0.0,410,0.1
Album.cs,82 (3.8%),63,76.8%,8,9.8%,11,13.4%
ExternalArtManager.cs,245 (10.2%),220,89.8%,0,0.0%,25,10.2%
Functions.cs,250 (9.5%),213,85.2%,9,3.6%,28,11.2%
JsonResponse.cs,103 (3.8%),93,90.3%,1,1.0%,9,8.7%
LangHelper.cs,155 (5.3%),147,94.8%,0,0.0%,8,5.2%
Music_DRP_Launcher.bat,73 (2.5%),51,69.9%,21,28.8%,1,1.4%
Total,2974,2440,0.8,123,0.0,411,0.1
6 changes: 3 additions & 3 deletions statistic.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
|Lang (# files)|Lines (% total)|Code Lines|% Code|Comment Lines|% Comments|Blank Lines|% Blank|
| --- | --- | --- | --- | --- | --- | --- | --- |
|[c#](https://github.com/jojo2357/Music-Discord-Rich-Presence/tree/master/statistics/c%23/lines_descending.md) (7)|2504 (82.5%)|2157|86.1%|93|3.7%|254|10.1%|
|[batch](https://github.com/jojo2357/Music-Discord-Rich-Presence/tree/master/statistics/batch/lines_descending.md) (16)|521 (17.2%)|337|64.7%|30|5.8%|154|29.6%|
|[javascript](https://github.com/jojo2357/Music-Discord-Rich-Presence/tree/master/statistics/javascript/lines_descending.md) (1)|11 (0.4%)|9|81.8%|0|0.0%|2|18.2%|
|[c#](https://github.com/jojo2357/Music-Discord-Rich-Presence/tree/smaltin-supported-players/statistics/c%23/lines_descending.md) (7)|2442 (82.1%)|2094|85.7%|93|3.8%|255|10.4%|
|[batch](https://github.com/jojo2357/Music-Discord-Rich-Presence/tree/smaltin-supported-players/statistics/batch/lines_descending.md) (16)|521 (17.5%)|337|64.7%|30|5.8%|154|29.6%|
|[javascript](https://github.com/jojo2357/Music-Discord-Rich-Presence/tree/smaltin-supported-players/statistics/javascript/lines_descending.md) (1)|11 (0.4%)|9|81.8%|0|0.0%|2|18.2%|
Loading
Loading