From 0029171fe081c025b504622436d98f460a748c7e Mon Sep 17 00:00:00 2001 From: lithium_ Date: Mon, 30 May 2016 04:48:58 -0700 Subject: [PATCH] Lithiio - Update Switched to JSON for neat error reporting capabilities. --- ShareX.UploadersLib/Favicons/Lithiio.ico | Bin 1150 -> 318 bytes ShareX.UploadersLib/FileUploaders/Lithiio.cs | 29 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ShareX.UploadersLib/Favicons/Lithiio.ico b/ShareX.UploadersLib/Favicons/Lithiio.ico index 51cae7cbcf5c3e3de2c84635fa97db8420163c3f..0a8e0d06e32de8c6d4537ca20259114f99bceaed 100644 GIT binary patch literal 318 zcmb7;u?>JQ3KGZb(D literal 1150 zcmbu5K?=h_37ChpLW=E)7_l;b_e!@q?3=0Fp?Q(i#_RL*QkL*sV{aKmKywYdqF8iDA?$3MfZ|Fw#`n6xuPo;nW diff --git a/ShareX.UploadersLib/FileUploaders/Lithiio.cs b/ShareX.UploadersLib/FileUploaders/Lithiio.cs index 0314f2486..2ceda9451 100644 --- a/ShareX.UploadersLib/FileUploaders/Lithiio.cs +++ b/ShareX.UploadersLib/FileUploaders/Lithiio.cs @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License // Credits: https://github.com/lithium720 -using ShareX.HelpersLib; +using Newtonsoft.Json; using System.Collections.Generic; using System.IO; using System.Windows.Forms; @@ -58,7 +58,7 @@ public Lithiio(LithiioSettings config) Config = config; } - private const string uploadUrl = "http://api.lithi.io/upload.php"; + private const string uploadUrl = "http://api.lithi.io/v2/"; public static string[] UploadURLs = new string[] { "https://i.lithi.io/", "https://lithi.io/i/", "https://i.mugi.io/", "https://mugi.io/i/" }; @@ -66,31 +66,36 @@ public override UploadResult Upload(Stream stream, string fileName) { Dictionary arguments = new Dictionary(); arguments.Add("key", Config.UserAPIKey); + arguments.Add("linktype", Config.UploadURL); UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments, method: HttpMethod.POST); + LithiioResponse Response = JsonConvert.DeserializeObject(result.Response); if (result.Response == null) { - Errors.Add("Upload failed for unknown reason. Check your API key."); + Errors.Add("Upload failed for unknown reason."); return result; } if (result.IsSuccess) { - result.URL = URLHelpers.CombineURL(Config.UploadURL, result.Response); + if (Response.Success) + { + result.URL = Response.URL; + } + else + { + Errors.Add(Response.Error); + } } return result; } - internal class LithiioResponse + public class LithiioResponse { - public string url { get; set; } - public List errors { get; set; } - } - - internal class LithiioFile - { - public string url { get; set; } + public bool Success { get; set; } + public string URL { get; set; } + public string Error { get; set; } } }