Compare commits
2 commits
4cf87623e4
...
70c2372535
Author | SHA1 | Date | |
---|---|---|---|
|
70c2372535 | ||
|
40fdd4e084 |
11 changed files with 26 additions and 48 deletions
|
@ -1,7 +1,7 @@
|
||||||
[*.cs]
|
[*.cs]
|
||||||
|
|
||||||
# CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
|
# CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
|
||||||
dotnet_diagnostic.CS8632.severity = suggestion
|
dotnet_diagnostic.CS8632.severity = silent
|
||||||
|
|
||||||
# CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
|
# CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
dotnet_diagnostic.CS4014.severity = suggestion
|
dotnet_diagnostic.CS4014.severity = suggestion
|
||||||
|
|
Binary file not shown.
|
@ -25,25 +25,21 @@ namespace JellyfinRPC
|
||||||
if (!File.Exists(ConfigFile))
|
if (!File.Exists(ConfigFile))
|
||||||
saveCfg();
|
saveCfg();
|
||||||
|
|
||||||
using (StreamReader cfgReader = File.OpenText(ConfigFile))
|
using StreamReader cfgReader = File.OpenText(ConfigFile);
|
||||||
|
for (string line = cfgReader.ReadLine(); line != null; line = cfgReader.ReadLine())
|
||||||
{
|
{
|
||||||
for (string line = cfgReader.ReadLine(); line != null; line = cfgReader.ReadLine())
|
if (line.StartsWith("*")) continue;
|
||||||
{
|
string[] values = line.Split(SEPERATOR.First());
|
||||||
if (line.StartsWith("*")) continue;
|
cfgEntries.Add(values.First().Trim(), String.Join(SEPERATOR, values.Skip(1)).Trim());
|
||||||
string[] values = line.Split(SEPERATOR.First());
|
|
||||||
cfgEntries.Add(values.First().Trim(), String.Join(SEPERATOR, values.Skip(1)).Trim());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void saveCfg()
|
private static void saveCfg()
|
||||||
{
|
{
|
||||||
using (StreamWriter cfgWriter = File.CreateText(ConfigFile))
|
using StreamWriter cfgWriter = File.CreateText(ConfigFile);
|
||||||
|
cfgWriter.WriteLine("**JellyfinDiscordRPC Config**");
|
||||||
|
foreach (KeyValuePair<String, String> values in cfgEntries)
|
||||||
{
|
{
|
||||||
cfgWriter.WriteLine("**JellyfinDiscordRPC Config**");
|
cfgWriter.WriteLine(String.Join(SEPERATOR, new String[] { values.Key.Trim(), values.Value.Trim() }));
|
||||||
foreach (KeyValuePair<String, String> values in cfgEntries)
|
|
||||||
{
|
|
||||||
cfgWriter.WriteLine(String.Join(SEPERATOR, new String[] { values.Key.Trim(), values.Value.Trim() } ));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void SetEntry(string key, string value)
|
public static void SetEntry(string key, string value)
|
||||||
|
|
|
@ -11,13 +11,13 @@ namespace JellyfinRPC
|
||||||
public static Int64 discordAppID = Int64.Parse(ConfigManager.GetEntry("DiscordClientID"));
|
public static Int64 discordAppID = Int64.Parse(ConfigManager.GetEntry("DiscordClientID"));
|
||||||
|
|
||||||
|
|
||||||
static void UpdateActivity(Discord.Discord discord)
|
public static void UpdateActivity(Discord.Discord discord)
|
||||||
{
|
{
|
||||||
var activityManager = discord.GetActivityManager();
|
var activityManager = discord.GetActivityManager();
|
||||||
string[] RPCVari = JellyfinAPI.Jellyfin().Result.Split('|');
|
string[] RPCVari = JellyfinAPI.Jellyfin().Result.Split('|');
|
||||||
if (JellyfinAPI.Jellyfin().Result != null)
|
if (JellyfinAPI.Jellyfin().Result != null)
|
||||||
{
|
{
|
||||||
var activity = new Discord.Activity
|
Activity activity = new Activity
|
||||||
{
|
{
|
||||||
Details = RPCVari.GetValue(int.Parse("2")).ToString(),
|
Details = RPCVari.GetValue(int.Parse("2")).ToString(),
|
||||||
State = RPCVari.GetValue(int.Parse("3")).ToString(),
|
State = RPCVari.GetValue(int.Parse("3")).ToString(),
|
||||||
|
|
|
@ -179,7 +179,6 @@ namespace JellyfinRPC
|
||||||
}
|
}
|
||||||
return "album_cover";
|
return "album_cover";
|
||||||
}
|
}
|
||||||
private static Dictionary<string, string> jsonEntries = new Dictionary<string, string>();
|
|
||||||
public static async Task<string> SendQuickConnectRequest()
|
public static async Task<string> SendQuickConnectRequest()
|
||||||
{
|
{
|
||||||
using var httpClient = new HttpClient();
|
using var httpClient = new HttpClient();
|
||||||
|
@ -198,36 +197,18 @@ namespace JellyfinRPC
|
||||||
{
|
{
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||||
string[] splitEmUp = jsonResponse.Split(',');
|
var jsonObject = JObject.Parse(jsonResponse);
|
||||||
|
|
||||||
if (!splitEmUp.Any())
|
if (!jsonObject.HasValues)
|
||||||
{
|
{
|
||||||
return "Error: Server did not respond.";
|
return "Error: Server did not respond.";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var splitstring in splitEmUp)
|
string quickConnectCode = jsonObject.Value<string>("Code");
|
||||||
{
|
string quickConnectToken = jsonObject.Value<string>("Secret");
|
||||||
string[] values = splitstring.Split(':');
|
return quickConnectCode;
|
||||||
jsonEntries.Add(values.First().Trim(), String.Join(":", values.Skip(1)).Trim());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (jsonEntries.ContainsKey("\"Code\""))
|
|
||||||
{
|
|
||||||
return jsonEntries["\"Code\""].Replace('"', ' ').Trim();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "Error: Server did not return code.";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -244,14 +225,12 @@ namespace JellyfinRPC
|
||||||
|
|
||||||
public static string DeviceID()
|
public static string DeviceID()
|
||||||
{
|
{
|
||||||
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
|
using RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
|
||||||
{
|
byte[] randomNumber = new byte[4];
|
||||||
byte[] randomNumber = new byte[4];
|
rng.GetBytes(randomNumber);
|
||||||
rng.GetBytes(randomNumber);
|
int value = BitConverter.ToInt32(randomNumber, 0);
|
||||||
int value = BitConverter.ToInt32(randomNumber, 0);
|
byte[] valueBytes = System.Text.Encoding.UTF8.GetBytes(value.ToString());
|
||||||
byte[] valueBytes = System.Text.Encoding.UTF8.GetBytes(value.ToString());
|
return System.Convert.ToBase64String(valueBytes);
|
||||||
return System.Convert.ToBase64String(valueBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public static async Task GetTokenFromUsernameAndPassword(string Username, string Password)
|
public static async Task GetTokenFromUsernameAndPassword(string Username, string Password)
|
||||||
|
@ -294,8 +273,10 @@ namespace JellyfinRPC
|
||||||
|
|
||||||
public class Login
|
public class Login
|
||||||
{
|
{
|
||||||
|
#pragma warning disable IDE1006 // Naming Styles
|
||||||
public string username { get; set; }
|
public string username { get; set; }
|
||||||
public string pw { get; set; }
|
public string pw { get; set; }
|
||||||
|
#pragma warning restore IDE1006 // Naming Styles
|
||||||
}
|
}
|
||||||
public class QuickConnect
|
public class QuickConnect
|
||||||
{
|
{
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -39,3 +39,4 @@ C:\Users\random()\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2
|
||||||
C:\Users\random()\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\JellyfinRPCGUI.csproj.CopyComplete
|
C:\Users\random()\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\JellyfinRPCGUI.csproj.CopyComplete
|
||||||
C:\Users\random()\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\Jellyfin Rich Presence.exe
|
C:\Users\random()\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\Jellyfin Rich Presence.exe
|
||||||
C:\Users\random()\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\Jellyfin Rich Presence.pdb
|
C:\Users\random()\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\Jellyfin Rich Presence.pdb
|
||||||
|
C:\Users\random()\Documents\Visual Studio 2010\Projects\WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\JellyfinRPCGUI.csproj.AssemblyReference.cache
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue