diff --git a/.vs/WindowsFormsApplication2/v16/.suo b/.vs/WindowsFormsApplication2/v16/.suo index ccafb1c..b291209 100644 Binary files a/.vs/WindowsFormsApplication2/v16/.suo and b/.vs/WindowsFormsApplication2/v16/.suo differ diff --git a/WindowsFormsApplication2/Form1.cs b/WindowsFormsApplication2/Form1.cs index e28361e..30bbb7e 100644 --- a/WindowsFormsApplication2/Form1.cs +++ b/WindowsFormsApplication2/Form1.cs @@ -38,7 +38,7 @@ namespace JellyfinRPC private static System.Timers.Timer consoleTimer; - private void Form1_Load(object sender, EventArgs e) + private async void Form1_Load(object sender, EventArgs e) { minimiseToTrayToolStripMenuItem.Checked = bool.Parse(ConfigManager.GetEntry("MinimiseToTray", "False")); closeToTrayToolStripMenuItem.Checked = bool.Parse(ConfigManager.GetEntry("CloseToTray", "False")); @@ -50,7 +50,7 @@ namespace JellyfinRPC ConfigManager.GetEntry("JellyfinToken", ""); ConfigManager.GetEntry("DeviceID", $"{JellyfinAPI.DeviceID()}"); SetTimer(); - JellyfinAPI.Jellyfin(); + await JellyfinAPI.Jellyfin(); diff --git a/WindowsFormsApplication2/JellyfinAPI.cs b/WindowsFormsApplication2/JellyfinAPI.cs index cf640ae..2504608 100644 --- a/WindowsFormsApplication2/JellyfinAPI.cs +++ b/WindowsFormsApplication2/JellyfinAPI.cs @@ -105,10 +105,10 @@ namespace JellyfinRPC { if (ConfigManager.GetEntry("JellyfinToken") == "") { - var response = await httpClient.GetAsync($"{ConfigManager.GetEntry("ServerURL")}/Sessions?api_key={ConfigManager.GetEntry("APIKey")}"); - response.EnsureSuccessStatusCode(); + var playingInfoResponse = await httpClient.GetAsync($"{ConfigManager.GetEntry("ServerURL")}/Sessions?api_key={ConfigManager.GetEntry("APIKey")}"); + playingInfoResponse.EnsureSuccessStatusCode(); - var jsonResponse = await response.Content.ReadAsStringAsync(); + var jsonResponse = await playingInfoResponse.Content.ReadAsStringAsync(); var sessions = JArray.Parse(jsonResponse); foreach (var session in sessions) @@ -302,7 +302,7 @@ namespace JellyfinRPC var responseJson = JObject.Parse(responseAsString); if (responseJson.Value("Authenticated") == true) { - var quickConnectLoginSecret = new QuickConnect() { Secret = quickConnectToken }; + var quickConnectLoginSecret = new JellyfinAuth() { AccessToken = quickConnectToken }; var quickConnectLoginJson = JsonConvert.SerializeObject(quickConnectLoginSecret); HttpResponseMessage quickConnectLoginResponse = await httpClient.PostAsync($"{ConfigManager.GetEntry("ServerURL")}/Users/AuthenticateWithQuickConnect", new StringContent(quickConnectLoginJson, Encoding.UTF8, "application/json")); quickConnectLoginResponse.EnsureSuccessStatusCode(); @@ -313,6 +313,7 @@ namespace JellyfinRPC if (quickConnectLoginResponseJson.Value("AccessToken") != null && quickConnectLoginResponseJson.Value("AccessToken") != "") { ConfigManager.SetEntry("JellyfinToken", quickConnectLoginResponseJson.Value("AccessToken")); + authSuccess = true; (System.Windows.Forms.Application.OpenForms["ConfigForm"] as ConfigForm).label9.Text = "Authentication Successful."; } @@ -335,6 +336,9 @@ namespace JellyfinRPC } } + // don't touch! + #region classes + public class Login { #pragma warning disable IDE1006 // Naming Styles @@ -342,8 +346,121 @@ namespace JellyfinRPC public string pw { get; set; } #pragma warning restore IDE1006 // Naming Styles } - public class QuickConnect + public class JellyfinAuth { - public string Secret { get; set; } + public User User { get; } + public string AccessToken { get; set; } + public string ServerId { get; } + } + public class User + { + public string Name { get; } + public string ServerId { get; } + public string Id { get; } + public string PrimaryImageTag { get; } + public bool HasPassword { get; } + public bool HasConfiguredPassword { get; } + public bool HasConfiguredEasyPassword { get; } + public bool EnableAutoLogin { get; } + public string LastLoginDate { get; } + public string LastActivityDate { get; } + public Configuration Configuration { get; } + public Policy Policy { get; } + public int PrimaryImageAspectRatio { get; } + } + public class SessionInfo + { + public JArray AdditionalUsers { get; } + public string RemoteEndPoint { get; } + public JArray PlayableMediaTypes { get; } + public string Id { get; } + public string UserId { get; } + public string UserName { get; } + public string Client { get; } + public string LastActivityDate { get; } + public string LastPlaybackCheckIn { get; } + public string LastPausedDate { get; } + public string DeviceName { get; } + public string DeviceType { get; } + public string DeviceId { get; } + public string ApplicationVersion { get; } + public bool IsActive { get; } + public bool SuportsMediaControl { get; } + public bool SupportsRemoteControl { get; } + public JArray NowPlayingQueue { get; } + public JArray NowPlayingQueueFullItems { get; } + public bool HasCustomDeviceName { get; } + public string PlaylistItemId { get; } + public string ServerId { get; } + public string UserPrimaryImageTag { get; } + public JArray SupportedCommands { get; } + + } + public class Configuration + { + public string AudioLanguagePreference { get; } + public bool PlayDefaultAudioTrack { get; } + public string SubtitleLanguagePreference { get; } + public bool DisplayMissingEpisodes { get; } + public JArray GroupedFolders { get; } + public string SubtitleMode { get; } + public bool DisplayCollectionsView { get; } + public bool EnableLocalPassword { get; } + public JArray OrderedViews { get; } + public JArray LatestItemsExcludes { get; } + public JArray MyMediaExcludes { get; } + public bool HidePlayedInLatest { get; } + public bool RememberSubtitleSelections { get; } + public bool EnableNextEpisodeAutoPlay { get; } + public string CastRecieverId { get; } + } + public class Policy + { + // we don't actualy care about the policies, but i'm defining them in here just in case + public bool IsAdministrator { get; } + public bool IsHidden { get; } + public bool EnableCollectionManagement { get; } + public bool EnableSubtitleManagement { get; } + public bool EnableLyricManagement { get; } + public bool IsDisabled { get; } + public int MaxParentalRating { get; } + public JArray BlockedTags { get; } + public JArray AllowedTags { get; } + public bool EnableUserPreferenceAccess { get; } + public JArray AccessSchedules { get; } + public JArray BlockUnratedItems { get; } + public bool EnableRemoteControlOfOtherUsers { get; } + public bool EnableSharedDeviceControl { get; } + public bool EnableRemoteAccess { get; } + public bool EnableLiveTvManagement { get; } + public bool EnableLiveTvAccess { get; } + public bool EnableMediaPlayback { get; } + public bool EnableAudioPlaybackTranscoding { get; } + public bool EnableVideoPlaybackTranscoding { get; } + public bool EnablePlaybackRemuxing { get; } + public bool ForceRemoteSourceTranscoding { get; } + public bool EnableConetentDeletion { get; } + public JArray EnableContentDeletionFromFolders { get; } + public bool EnableContentDownloading { get; } + public bool EnableSyncTranscoding { get; } + public bool EnableMediaConverison { get; } + public JArray EnabledDevices { get; } + public bool EnableAllDevices { get; } + public JArray EnabledChannels { get; } + public bool EnableAllChannels { get; } + public JArray EnabledFolders { get; } + public bool EnableAllFolders { get; } + public int InvalidLoginAttemptCount { get; } + public int LoginAttemptsBeforeLockout { get; } + public int MaxActiveSessions { get; } + public bool EnablePublicSharing { get; } + public JArray BlockedMediaFolders { get; } + public JArray BlockedChannels { get; } + public int RemoteClientBitrateLimit { get; } + public string AuthenticationProviderId { get; } + public string PasswordResetProviderId { get; } + public string SyncPlayAccess { get; } + } + #endregion } diff --git a/WindowsFormsApplication2/bin/Debug/Jellyfin Rich Presence.exe b/WindowsFormsApplication2/bin/Debug/Jellyfin Rich Presence.exe index 2b87036..a390899 100644 Binary files a/WindowsFormsApplication2/bin/Debug/Jellyfin Rich Presence.exe and b/WindowsFormsApplication2/bin/Debug/Jellyfin Rich Presence.exe differ diff --git a/WindowsFormsApplication2/bin/Debug/Jellyfin Rich Presence.pdb b/WindowsFormsApplication2/bin/Debug/Jellyfin Rich Presence.pdb index 819874c..6a13c61 100644 Binary files a/WindowsFormsApplication2/bin/Debug/Jellyfin Rich Presence.pdb and b/WindowsFormsApplication2/bin/Debug/Jellyfin Rich Presence.pdb differ diff --git a/WindowsFormsApplication2/obj/x86/Debug/Jellyfin Rich Presence.exe b/WindowsFormsApplication2/obj/x86/Debug/Jellyfin Rich Presence.exe index 2b87036..a390899 100644 Binary files a/WindowsFormsApplication2/obj/x86/Debug/Jellyfin Rich Presence.exe and b/WindowsFormsApplication2/obj/x86/Debug/Jellyfin Rich Presence.exe differ diff --git a/WindowsFormsApplication2/obj/x86/Debug/Jellyfin Rich Presence.pdb b/WindowsFormsApplication2/obj/x86/Debug/Jellyfin Rich Presence.pdb index 819874c..6a13c61 100644 Binary files a/WindowsFormsApplication2/obj/x86/Debug/Jellyfin Rich Presence.pdb and b/WindowsFormsApplication2/obj/x86/Debug/Jellyfin Rich Presence.pdb differ diff --git a/WindowsFormsApplication2/obj/x86/Debug/JellyfinRPCGUI.csproj.GenerateResource.Cache b/WindowsFormsApplication2/obj/x86/Debug/JellyfinRPCGUI.csproj.GenerateResource.Cache index 5a191dc..e257f59 100644 Binary files a/WindowsFormsApplication2/obj/x86/Debug/JellyfinRPCGUI.csproj.GenerateResource.Cache and b/WindowsFormsApplication2/obj/x86/Debug/JellyfinRPCGUI.csproj.GenerateResource.Cache differ