diff --git a/EndpointSetup/EndpointSetup.csproj b/EndpointSetup/EndpointSetup.csproj new file mode 100644 index 0000000..b84e63f --- /dev/null +++ b/EndpointSetup/EndpointSetup.csproj @@ -0,0 +1,12 @@ + + + + Exe + net5.0 + + + + + + + diff --git a/EndpointSetup/Program.cs b/EndpointSetup/Program.cs new file mode 100644 index 0000000..ab05dfe --- /dev/null +++ b/EndpointSetup/Program.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; + +using Newtonsoft.Json; + +namespace EndpointSetup { + internal class Program { + public struct Endpoint { + public string name; + public string apiInfo; + public string SfwEndpoint; + public string NsfwEndpoint; + public List SfwEndpoints; + public List NsfwEndpoints; + } + public static List endpoints = new List(); + + static void Main(string[] args) { + + endpoints.Add(new Endpoint { + name = "waifu.pics", + apiInfo = "url", + SfwEndpoint = "https://api.waifu.pics/sfw", + NsfwEndpoint = "https://api.waifu.pics/nsfw", + SfwEndpoints = new List { "waifu", "neko", "shinobu", "megumin", "bully", "cuddle", "cry", "hug", "awoo", "kiss", "lick", "pat", "smug", "bonk", "yeet", "blush", "smile", "wave", "highfive", "handhold", "nom", "bite", "glomp", "slap", "kill", "kick", "happy", "wink", "poke", "dance", "cringe" }, + NsfwEndpoints = new List { "waifu", "neko", "trap", "blowjob" } + }); + + endpoints.Add(new Endpoint { + name = "nekos.life", + SfwEndpoint = "https://nekos.life/api/v2/img/", + NsfwEndpoint = "https://nekos.life/api/v2/img/", + apiInfo = "url", + SfwEndpoints = new List + { + "neko", "waifu", "tickle", "slap", "pat", "meow", "lizard", "kiss", "hug", "fox_girl","feed", "cuddle", "ngif", "smug", "woof", "wallpaper", "goose", "gecg", "avatar" + }, + NsfwEndpoints = new List() { "lewd" } + }); + + endpoints.Add(new Endpoint { + name = "xsky.dev", + SfwEndpoint = "https://api.xsky.dev/", + NsfwEndpoint = "https://api.xsky.dev/", + apiInfo = "url", + SfwEndpoints = new List { "neko", "catboy" }, + NsfwEndpoints = new List { "hentai", "bdsm", "furry", "ff", "feet", "trap", "gif", "futa" } + }); + + endpoints.Add(new Endpoint { + name = "anime-images", + SfwEndpoint = "https://anime-api.hisoka17.repl.co/img/", + NsfwEndpoint = "https://anime-api.hisoka17.repl.co/img/", + apiInfo = "url", + SfwEndpoints = new List { "hug", "kiss", "slap", "wink", "pat", "kill", "cuddle", "punch", "waifu" }, + NsfwEndpoints = new List { "hentai", "boobs", "lesbian" } + }); + + + + + + Console.WriteLine(JsonConvert.SerializeObject(endpoints, Formatting.Indented)); + Console.ReadKey(); + Console.WriteLine("\n\n\n\n\n\n\n"); + Console.WriteLine(JsonConvert.SerializeObject(endpoints, Formatting.None)); + } + } +} diff --git a/NyaDesktop.sln b/NyaDesktop.sln index 00b23c2..e5c6301 100644 --- a/NyaDesktop.sln +++ b/NyaDesktop.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31702.278 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32228.430 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NyaDesktop", "NyaDesktop\NyaDesktop.csproj", "{4E049685-DF3B-4301-BE3D-5C0CF1A3251D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndpointSetup", "EndpointSetup\EndpointSetup.csproj", "{DFFE4998-AD89-4C21-94D6-1FEC22B8AAF5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {4E049685-DF3B-4301-BE3D-5C0CF1A3251D}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E049685-DF3B-4301-BE3D-5C0CF1A3251D}.Release|Any CPU.ActiveCfg = Release|Any CPU {4E049685-DF3B-4301-BE3D-5C0CF1A3251D}.Release|Any CPU.Build.0 = Release|Any CPU + {DFFE4998-AD89-4C21-94D6-1FEC22B8AAF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFFE4998-AD89-4C21-94D6-1FEC22B8AAF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFFE4998-AD89-4C21-94D6-1FEC22B8AAF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFFE4998-AD89-4C21-94D6-1FEC22B8AAF5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/NyaDesktop/Class1.cs b/NyaDesktop/Class1.cs new file mode 100644 index 0000000..27c26bd --- /dev/null +++ b/NyaDesktop/Class1.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NyaDesktop { + internal class Class1 { + } +} diff --git a/NyaDesktop/Form1.Designer.cs b/NyaDesktop/Form1.Designer.cs index b03e512..77d15e5 100644 --- a/NyaDesktop/Form1.Designer.cs +++ b/NyaDesktop/Form1.Designer.cs @@ -31,33 +31,24 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); - this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.sfw_comboBox = new System.Windows.Forms.ComboBox(); - this.nsfw_comboBox = new System.Windows.Forms.ComboBox(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.panel1 = new System.Windows.Forms.Panel(); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.SettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.setSaveDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.endpointToolStripComboBox2 = new System.Windows.Forms.ToolStripComboBox(); + this.SFWToolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox(); + this.serviceToolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.panel1.SuspendLayout(); + this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.BackColor = System.Drawing.Color.Transparent; - this.button1.Location = new System.Drawing.Point(3, 2); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 21); - this.button1.TabIndex = 0; - this.button1.Text = "Save Path"; - this.button1.UseVisualStyleBackColor = false; - this.button1.Click += new System.EventHandler(this.button1_Click); - // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -81,78 +72,6 @@ private void InitializeComponent() this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // - // comboBox1 - // - this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(new object[] { - "sfw", - "nsfw"}); - this.comboBox1.Location = new System.Drawing.Point(246, 2); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(75, 21); - this.comboBox1.TabIndex = 5; - this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); - // - // sfw_comboBox - // - this.sfw_comboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.sfw_comboBox.Enabled = false; - this.sfw_comboBox.FormattingEnabled = true; - this.sfw_comboBox.Items.AddRange(new object[] { - "waifu", - "neko", - "shinobu", - "megumin", - "bully", - "cuddle", - "cry", - "hug", - "awoo", - "kiss", - "lick", - "pat", - "smug", - "bonk", - "yeet", - "blush", - "smile", - "wave", - "highfive", - "handhold", - "nom", - "bite", - "glomp", - "slap", - "kill", - "kick", - "happy", - "wink", - "poke", - "dance", - "cringe"}); - this.sfw_comboBox.Location = new System.Drawing.Point(328, 2); - this.sfw_comboBox.Name = "sfw_comboBox"; - this.sfw_comboBox.Size = new System.Drawing.Size(74, 21); - this.sfw_comboBox.TabIndex = 6; - this.sfw_comboBox.Visible = false; - // - // nsfw_comboBox - // - this.nsfw_comboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.nsfw_comboBox.Enabled = false; - this.nsfw_comboBox.FormattingEnabled = true; - this.nsfw_comboBox.Items.AddRange(new object[] { - "waifu", - "neko", - "trap", - "blowjob"}); - this.nsfw_comboBox.Location = new System.Drawing.Point(328, 2); - this.nsfw_comboBox.Name = "nsfw_comboBox"; - this.nsfw_comboBox.Size = new System.Drawing.Size(74, 21); - this.nsfw_comboBox.TabIndex = 7; - this.nsfw_comboBox.Visible = false; - // // pictureBox1 // this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -160,7 +79,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.pictureBox1.Location = new System.Drawing.Point(12, 13); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(401, 283); + this.pictureBox1.Size = new System.Drawing.Size(401, 287); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.pictureBox1.TabIndex = 8; this.pictureBox1.TabStop = false; @@ -168,13 +87,9 @@ private void InitializeComponent() // panel1 // this.panel1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.panel1.Controls.Add(this.button1); - this.panel1.Controls.Add(this.sfw_comboBox); - this.panel1.Controls.Add(this.nsfw_comboBox); this.panel1.Controls.Add(this.button2); this.panel1.Controls.Add(this.button3); - this.panel1.Controls.Add(this.comboBox1); - this.panel1.Location = new System.Drawing.Point(12, 298); + this.panel1.Location = new System.Drawing.Point(12, 302); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(402, 23); this.panel1.TabIndex = 9; @@ -194,38 +109,107 @@ private void InitializeComponent() this.contextMenuStrip1.ShowImageMargin = false; this.contextMenuStrip1.Size = new System.Drawing.Size(36, 4); // + // menuStrip1 + // + this.menuStrip1.BackColor = System.Drawing.Color.Black; + this.menuStrip1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.menuStrip1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.SettingsToolStripMenuItem, + this.endpointToolStripComboBox2, + this.SFWToolStripComboBox1, + this.serviceToolStripComboBox1}); + this.menuStrip1.Location = new System.Drawing.Point(0, 328); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(426, 27); + this.menuStrip1.TabIndex = 10; + this.menuStrip1.Text = "menuStrip1"; + // + // SettingsToolStripMenuItem + // + this.SettingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.setSaveDirectoryToolStripMenuItem}); + this.SettingsToolStripMenuItem.ForeColor = System.Drawing.SystemColors.Control; + this.SettingsToolStripMenuItem.Name = "SettingsToolStripMenuItem"; + this.SettingsToolStripMenuItem.Size = new System.Drawing.Size(61, 23); + this.SettingsToolStripMenuItem.Text = "Settings"; + // + // setSaveDirectoryToolStripMenuItem + // + this.setSaveDirectoryToolStripMenuItem.Name = "setSaveDirectoryToolStripMenuItem"; + this.setSaveDirectoryToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.setSaveDirectoryToolStripMenuItem.Text = "Set Save Directory"; + this.setSaveDirectoryToolStripMenuItem.Click += new System.EventHandler(this.setSaveDirectoryToolStripMenuItem_Click); + // + // endpointToolStripComboBox2 + // + this.endpointToolStripComboBox2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.endpointToolStripComboBox2.BackColor = System.Drawing.Color.Black; + this.endpointToolStripComboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.endpointToolStripComboBox2.ForeColor = System.Drawing.Color.White; + this.endpointToolStripComboBox2.Name = "endpointToolStripComboBox2"; + this.endpointToolStripComboBox2.Size = new System.Drawing.Size(75, 23); + // + // SFWToolStripComboBox1 + // + this.SFWToolStripComboBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.SFWToolStripComboBox1.BackColor = System.Drawing.Color.Black; + this.SFWToolStripComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.SFWToolStripComboBox1.ForeColor = System.Drawing.Color.White; + this.SFWToolStripComboBox1.Items.AddRange(new object[] { + "sfw", + "nsfw"}); + this.SFWToolStripComboBox1.Name = "SFWToolStripComboBox1"; + this.SFWToolStripComboBox1.Size = new System.Drawing.Size(75, 23); + // + // serviceToolStripComboBox1 + // + this.serviceToolStripComboBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.serviceToolStripComboBox1.BackColor = System.Drawing.Color.Black; + this.serviceToolStripComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.serviceToolStripComboBox1.ForeColor = System.Drawing.Color.White; + this.serviceToolStripComboBox1.Name = "serviceToolStripComboBox1"; + this.serviceToolStripComboBox1.Size = new System.Drawing.Size(100, 23); + this.serviceToolStripComboBox1.SelectedIndexChanged += new System.EventHandler(this.serviceToolStripComboBox1_SelectedIndexChanged); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(426, 333); + this.ClientSize = new System.Drawing.Size(426, 355); + this.Controls.Add(this.menuStrip1); this.Controls.Add(this.panel1); this.Controls.Add(this.pictureBox1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip1; this.MinimumSize = new System.Drawing.Size(442, 372); this.Name = "Form1"; this.Text = "Nya"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ProgramCloser); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.panel1.ResumeLayout(false); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion - - private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; - private System.Windows.Forms.ComboBox comboBox1; - private System.Windows.Forms.ComboBox sfw_comboBox; - private System.Windows.Forms.ComboBox nsfw_comboBox; private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.NotifyIcon notifyIcon1; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem SettingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem setSaveDirectoryToolStripMenuItem; + private System.Windows.Forms.ToolStripComboBox endpointToolStripComboBox2; + private System.Windows.Forms.ToolStripComboBox SFWToolStripComboBox1; + private System.Windows.Forms.ToolStripComboBox serviceToolStripComboBox1; } } diff --git a/NyaDesktop/Form1.cs b/NyaDesktop/Form1.cs index 09b5a10..f6480e6 100644 --- a/NyaDesktop/Form1.cs +++ b/NyaDesktop/Form1.cs @@ -21,6 +21,8 @@ public partial class Form1 : Form readonly WebClient webclient = new WebClient(); readonly DiscordRpcClient DiscordClient; string emergcencySave = ""; + bool nsfw = false; + NyaAPI.Endpoint currEndpoint; public Form1(DiscordRpcClient client) { @@ -32,49 +34,52 @@ public Form1(DiscordRpcClient client) { save_path = Properties.Settings.Default.path; } - } + LoadEndpointInfo(); - private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) - { - if ((string)comboBox1.SelectedItem == "sfw") - { - sfw_comboBox.Enabled = true; - sfw_comboBox.Visible = true; - nsfw_comboBox.Enabled = false; - nsfw_comboBox.Visible = false; - } - else if ((string)comboBox1.SelectedItem == "nsfw") - { - nsfw_comboBox.Enabled = true; - nsfw_comboBox.Visible = true; - sfw_comboBox.Enabled = false; - sfw_comboBox.Visible = false; - } } - private string getEndPoint() - { - if ((string)comboBox1.SelectedItem == "sfw") - { - return (string)sfw_comboBox.SelectedItem; - } - else if ((string)comboBox1.SelectedItem == "nsfw") - { - return (string)nsfw_comboBox.SelectedItem; - } - else { return "broke"; } + + public void LoadEndpointInfo(){ + NyaAPI.LoadEndpoints(); + NyaAPI.endpoints.ForEach(x => { + serviceToolStripComboBox1.Items.Add(x.name); + }); + SFWToolStripComboBox1.SelectedIndex = 0; + serviceToolStripComboBox1.SelectedIndex = 0; + endpointToolStripComboBox2.SelectedIndex = 0; + } - private void button1_Click(object sender, EventArgs e) - { + private void serviceToolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e) { + endpointToolStripComboBox2.Items.Clear(); + NyaAPI.endpoints.ForEach(x => { + currEndpoint = x; + if (x.name == serviceToolStripComboBox1.SelectedItem.ToString()) { + endpointToolStripComboBox2.Items.Clear(); + + if (SFWToolStripComboBox1.SelectedItem.ToString() == "nsfw") { + x.NsfwEndpoints.ForEach(y => { + endpointToolStripComboBox2.Items.Add(y); + }); + nsfw = true; + } else { + x.SfwEndpoints.ForEach(y => { + endpointToolStripComboBox2.Items.Add(y); + }); + nsfw = false; + } + } + }); + endpointToolStripComboBox2.SelectedIndex = 0; + } - if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) - { + private void setSaveDirectoryToolStripMenuItem_Click(object sender, EventArgs e) { + if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { save_path = folderBrowserDialog1.SelectedPath; button2.Enabled = true; Properties.Settings.Default.path = save_path; Properties.Settings.Default.Save(); } - } + } private void button2_Click(object sender, EventArgs e) { @@ -95,11 +100,10 @@ private void button2_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e) { + string endpoint = endpointToolStripComboBox2.SelectedItem.ToString(); try { - string endpoint = getEndPoint(); - string type = (string)comboBox1.SelectedItem; - curr_image_url = Task.Run(() => NyaAPI.PullNyaImageURL(type, endpoint)).Result; + curr_image_url = Task.Run(() => NyaAPI.PullNyaImageURL(currEndpoint, nsfw, endpoint)).Result; pictureBox1.Load(curr_image_url); } catch diff --git a/NyaDesktop/Form1.resx b/NyaDesktop/Form1.resx index a4de8fc..796ee4a 100644 --- a/NyaDesktop/Form1.resx +++ b/NyaDesktop/Form1.resx @@ -2654,6 +2654,9 @@ AIABAACAAQAAgAMAAIABAACAAQAAAAAAAAAAAAAAAAAAAB8AAA== + + 454, 17 + AAABAAYAAAAAAAEAIADPyQAAZgAAAICAAAABACAAKAgBADXKAABAQAAAAQAgAChCAABd0gEAMDAAAAEA diff --git a/NyaDesktop/NyaAPI.cs b/NyaDesktop/NyaAPI.cs index f4d95fc..0d813de 100644 --- a/NyaDesktop/NyaAPI.cs +++ b/NyaDesktop/NyaAPI.cs @@ -1,41 +1,88 @@ using System; using System.Collections.Generic; +using System.Drawing; +using System.IO; using System.Linq; using System.Net.Http; +using System.Security.Policy; using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; + +using static System.Windows.Forms.LinkLabel; namespace NyaDesktop { class NyaAPI { static readonly HttpClient client = new HttpClient(); + public static List endpoints; - // HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks. - public static async Task PullNyaImageURL(string type, string endpoint) + public static async Task PullNyaImageURL(Endpoint selectedEndpoint, bool nsfw, string endpoint) { - // Call asynchronous network methods in a try/catch block to handle exceptions. + string Nyaurl = ""; + if (nsfw) { + Nyaurl = selectedEndpoint.NsfwEndpoint + "/" + endpoint; + } else { + Nyaurl = selectedEndpoint.SfwEndpoint + "/" + endpoint; + } try { - HttpResponseMessage response = await client.GetAsync(@"https://api.waifu.pics/" + type + "/" + endpoint); + HttpResponseMessage response = await client.GetAsync(Nyaurl); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); - // Above three lines can be replaced with new helper method below - // string responseBody = await client.GetStringAsync(uri); + // you know this works for now and i know it's not super cool but idc int sIn = responseBody.IndexOf(":") + 2; int length = responseBody.LastIndexOf("}") - 1 - sIn; string url = responseBody.Substring(sIn, length); - - //string url = responseBody.Substring(responseBody.IndexOf(":") + 2, responseBody.LastIndexOf("}") - 3); + return url; } catch (HttpRequestException e) { Console.WriteLine("\nException Caught!"); Console.WriteLine("Message :{0} ", e.Message); - return "https://cdn.discordapp.com/attachments/839294618062553098/901663348280684604/API_Error.png"; + return "https://i.imgur.com/5JFEDXs.png"; } } + + public static void LoadEndpoints() { + string temp = NyaDesktop.Properties.Resources.JSONendpoints; + endpoints = JsonConvert.DeserializeObject>(temp); + } + + public struct Endpoint { + public string name; + public string apiInfo; + public string SfwEndpoint; + public string NsfwEndpoint; + public List SfwEndpoints; + public List NsfwEndpoints; + } } } + +/* + * public static async Task PullNyaImageURL(string type, string endpoint) + { + try + { + HttpResponseMessage response = await client.GetAsync(@"https://api.waifu.pics/" + type + "/" + endpoint); + response.EnsureSuccessStatusCode(); + string responseBody = await response.Content.ReadAsStringAsync(); + + int sIn = responseBody.IndexOf(":") + 2; + int length = responseBody.LastIndexOf("}") - 1 - sIn; + string url = responseBody.Substring(sIn, length); + + return url; + } + catch (HttpRequestException e) + { + Console.WriteLine("\nException Caught!"); + Console.WriteLine("Message :{0} ", e.Message); + return "https://cdn.discordapp.com/attachments/839294618062553098/901663348280684604/API_Error.png"; + } + } +*/ \ No newline at end of file diff --git a/NyaDesktop/NyaAPIManager.cs b/NyaDesktop/NyaAPIManager.cs new file mode 100644 index 0000000..5b68b98 --- /dev/null +++ b/NyaDesktop/NyaAPIManager.cs @@ -0,0 +1,36 @@ +using DiscordRPC; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace NyaDesktop +{ + static class NyaAPIManager + { + public static DiscordRpcClient DiscordClient { get; private set; } + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + startRichPrecense(); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1(DiscordClient)); + } + + public static void startRichPrecense() + { + DiscordClient = new DiscordRpcClient("901892124679741541"); //Creates the client + } + + public static void ProgramCloser() + { + DiscordClient.Dispose(); + } + } +} diff --git a/NyaDesktop/Properties/Resources.Designer.cs b/NyaDesktop/Properties/Resources.Designer.cs index 72b45ff..f97071d 100644 --- a/NyaDesktop/Properties/Resources.Designer.cs +++ b/NyaDesktop/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace NyaDesktop.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -69,5 +69,14 @@ internal static System.Drawing.Icon favicon { return ((System.Drawing.Icon)(obj)); } } + + /// + /// Looks up a localized string similar to [{"name":"waifu.pics","apiInfo":"url","SfwEndpoint":"https://api.waifu.pics/sfw","NsfwEndpoint":"https://api.waifu.pics/nsfw","SfwEndpoints":["waifu","neko","shinobu","megumin","bully","cuddle","cry","hug","awoo","kiss","lick","pat","smug","bonk","yeet","blush","smile","wave","highfive","handhold","nom","bite","glomp","slap","kill","kick","happy","wink","poke","dance","cringe"],"NsfwEndpoints":["waifu","neko","trap","blowjob"]},{"name":"nekos.life","apiInfo":"url","SfwEndpoint":"https://nekos.life/api/v2/im [re.... + /// + internal static string JSONendpoints { + get { + return ResourceManager.GetString("JSONendpoints", resourceCulture); + } + } } } diff --git a/NyaDesktop/Properties/Resources.resx b/NyaDesktop/Properties/Resources.resx index e2fbe90..daec4ad 100644 --- a/NyaDesktop/Properties/Resources.resx +++ b/NyaDesktop/Properties/Resources.resx @@ -121,4 +121,8 @@ ..\favicon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + [{"name":"waifu.pics","apiInfo":"url","SfwEndpoint":"https://api.waifu.pics/sfw","NsfwEndpoint":"https://api.waifu.pics/nsfw","SfwEndpoints":["waifu","neko","shinobu","megumin","bully","cuddle","cry","hug","awoo","kiss","lick","pat","smug","bonk","yeet","blush","smile","wave","highfive","handhold","nom","bite","glomp","slap","kill","kick","happy","wink","poke","dance","cringe"],"NsfwEndpoints":["waifu","neko","trap","blowjob"]},{"name":"nekos.life","apiInfo":"url","SfwEndpoint":"https://nekos.life/api/v2/img/","NsfwEndpoint":"https://nekos.life/api/v2/img/","SfwEndpoints":["neko","waifu","tickle","slap","pat","meow","lizard","kiss","hug","fox_girl","feed","cuddle","ngif","smug","woof","wallpaper","goose","gecg","avatar"],"NsfwEndpoints":["lewd"]},{"name":"xsky.dev","apiInfo":"url","SfwEndpoint":"https://api.xsky.dev/","NsfwEndpoint":"https://api.xsky.dev/","SfwEndpoints":["neko","catboy"],"NsfwEndpoints":["hentai","bdsm","furry","ff","feet","trap","gif","futa"]},{"name":"anime-images","apiInfo":"url","SfwEndpoint":"https://anime-api.hisoka17.repl.co/img/","NsfwEndpoint":"https://anime-api.hisoka17.repl.co/img/","SfwEndpoints":["hug","kiss","slap","wink","pat","kill","cuddle","punch","waifu"],"NsfwEndpoints":["hentai","boobs","lesbian"]}] + Used to store Endpoint data to be embedded and easily copied. + \ No newline at end of file