Added stuff
- Now displays "Jellyfin Discord RPC - Your Jellyfin Servers URL" in the title - Now only shows "Rich Presence updated!" once
This commit is contained in:
parent
b1cbe1988d
commit
3752368156
8 changed files with 44 additions and 12 deletions
4
.editorconfig
Normal file
4
.editorconfig
Normal file
|
@ -0,0 +1,4 @@
|
|||
[*.cs]
|
||||
|
||||
# Default severity for all analyzer diagnostics
|
||||
dotnet_analyzer_diagnostic.severity = silent
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -24,7 +24,7 @@
|
|||
"RelativeDocumentMoniker": "JellyfinDiscordRPC\\Program.cs",
|
||||
"ToolTip": "C:\\Users\\joshua\\Documents\\GitHub\\jellyfin-discord-rpc\\JellyfinDiscordRPC\\Program.cs",
|
||||
"RelativeToolTip": "JellyfinDiscordRPC\\Program.cs",
|
||||
"ViewState": "AgIAAEEAAAAAAAAAAAAswGQAAAAFAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAgAAAANAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-11-30T05:30:39.706Z",
|
||||
"EditorCaption": ""
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"RelativeDocumentMoniker": "JellyfinDiscordRPC\\Program.cs",
|
||||
"ToolTip": "C:\\Users\\joshua\\Documents\\GitHub\\jellyfin-discord-rpc\\JellyfinDiscordRPC\\Program.cs",
|
||||
"RelativeToolTip": "JellyfinDiscordRPC\\Program.cs",
|
||||
"ViewState": "AgIAADUAAAAAAAAAAAAswGQAAAAFAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAgAAAANAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-11-30T05:30:39.706Z",
|
||||
"EditorCaption": ""
|
||||
|
|
|
@ -5,6 +5,11 @@ VisualStudioVersion = 17.12.35514.174
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JellyfinDiscordRPC", "JellyfinDiscordRPC\JellyfinDiscordRPC.csproj", "{06FF6B5D-B070-4DB7-9A87-9B6E280A794D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B615520C-ED8E-4BBE-A88B-96812A61C61F}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
|
@ -11,31 +11,54 @@ class Program
|
|||
private const string ConfigFilePath = "config.json";
|
||||
private static DiscordRpcClient _discordClient;
|
||||
private static Config _config;
|
||||
private static bool isScreenSharing = false; // Track screen sharing status
|
||||
|
||||
// Hard-code the Discord Client ID here
|
||||
private const string DiscordClientId = "1312264302601834578"; // Discord client ID
|
||||
// Hard-coded the Discord Client ID
|
||||
private const string DiscordClientId = "1312264302601834578";
|
||||
|
||||
static bool presenceUpdated = false; // Flag to track initial rich presence update
|
||||
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Starting Jellyfin Discord Rich Presence...");
|
||||
// Load or create configuration first
|
||||
LoadOrCreateConfig(); // Initialize _config first
|
||||
|
||||
// Load or create configuration
|
||||
LoadOrCreateConfig();
|
||||
// Now we can safely access _config for the console title
|
||||
Console.WriteLine("Starting Jellyfin Discord Rich Presence...");
|
||||
Console.Title = $"Jellyfin Discord RPC - {_config.JellyfinBaseUrl}";
|
||||
|
||||
// Initialize Discord Rich Presence
|
||||
_discordClient = new DiscordRpcClient(DiscordClientId);
|
||||
_discordClient.OnReady += (sender, e) => Console.WriteLine("Connected to Discord RPC!");
|
||||
_discordClient.OnPresenceUpdate += (sender, e) => Console.WriteLine("Rich Presence updated!");
|
||||
_discordClient.OnReady += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine("Connected to Discord RPC!");
|
||||
|
||||
// Log message when connection to Discord is established
|
||||
if (!presenceUpdated)
|
||||
{
|
||||
Console.WriteLine("Rich Presence updated!"); // This will only show once
|
||||
presenceUpdated = true; // Set the flag to true to avoid logging it again
|
||||
}
|
||||
};
|
||||
|
||||
// Handle presence updates only once at the start
|
||||
_discordClient.OnPresenceUpdate += (sender, e) =>
|
||||
{
|
||||
if (!presenceUpdated)
|
||||
{
|
||||
Console.WriteLine("Rich Presence updated!");
|
||||
presenceUpdated = true; // Set the flag to true so it doesn't display again
|
||||
}
|
||||
};
|
||||
|
||||
_discordClient.Initialize();
|
||||
|
||||
// Poll Jellyfin API for currently playing media
|
||||
var updateTask = UpdateRichPresence(); // Start the rich presence update task
|
||||
|
||||
|
||||
await updateTask; // Wait for the rich presence update task to finish
|
||||
}
|
||||
|
||||
|
||||
private static async Task UpdateRichPresence()
|
||||
{
|
||||
while (true)
|
||||
|
|
Loading…
Add table
Reference in a new issue