begin defining the entire fucking jellyfin API response for login
This commit is contained in:
parent
c9e2e7fb5f
commit
4c880c3e9f
8 changed files with 125 additions and 8 deletions
|
@ -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();
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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<bool>("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<string>("AccessToken") != null && quickConnectLoginResponseJson.Value<string>("AccessToken") != "")
|
||||
{
|
||||
ConfigManager.SetEntry("JellyfinToken", quickConnectLoginResponseJson.Value<string>("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
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue