-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
205 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.jpg | ||
*.png | ||
|
||
*.suo | ||
/.vs/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace AnimeImageSorter | ||
{ | ||
class Imgur | ||
{ | ||
public static string Upload(string path, string apiKey) | ||
{ | ||
using (var w = new WebClient()) | ||
{ | ||
w.Headers.Add("Authorization: Client-ID " + apiKey); | ||
var values = new NameValueCollection | ||
{ | ||
{ "image", Convert.ToBase64String(File.ReadAllBytes(@path)) } | ||
}; | ||
|
||
string response = System.Text.Encoding.UTF8.GetString(w.UploadValues("https://api.imgur.com/3/upload", values)); | ||
Console.WriteLine(response); | ||
dynamic dynObj = JsonConvert.DeserializeObject(response); | ||
return dynObj.data.link; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace AnimeImageSorter | ||
{ | ||
internal class Result | ||
{ | ||
public dynamic header; | ||
public dynamic data; | ||
|
||
public Result(dynamic header, dynamic data) | ||
{ | ||
this.header = header; | ||
this.data = data; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace AnimeImageSorter | ||
{ | ||
class SauceNao | ||
{ | ||
private static string ENDPOINT = "https://saucenao.com/search.php"; | ||
private string ApiKey; | ||
|
||
public SauceNao(string apiKey) | ||
{ | ||
this.ApiKey = apiKey; | ||
} | ||
|
||
public List<Result> Request(string url) | ||
{ | ||
WebClient webClient = new WebClient(); | ||
|
||
webClient.QueryString.Add("db", "999"); | ||
webClient.QueryString.Add("output_type", "2"); | ||
webClient.QueryString.Add("numres", "16"); | ||
webClient.QueryString.Add("api_key", ApiKey); | ||
webClient.QueryString.Add("url", url); | ||
|
||
List<Result> results = new List<Result>(); | ||
|
||
try | ||
{ | ||
string response = webClient.DownloadString(ENDPOINT); | ||
dynamic dynObj = JsonConvert.DeserializeObject(response); | ||
foreach (var result in dynObj.results) | ||
{ | ||
results.Add(new Result(result.header, result.data)); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.Message); | ||
} | ||
|
||
return results; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters