mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added chevereto test all button
This commit is contained in:
parent
6c6ab39cf1
commit
ffa78b670b
5 changed files with 141 additions and 14 deletions
|
@ -99,7 +99,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
return result;
|
||||
}
|
||||
|
||||
public static string TestClones()
|
||||
public static string TestUploaders()
|
||||
{
|
||||
List<PomfTest> successful = new List<PomfTest>();
|
||||
List<PomfTest> failed = new List<PomfTest>();
|
||||
|
|
|
@ -514,6 +514,7 @@ private void InitializeComponent()
|
|||
this.btnPicasaRefreshAlbumList = new System.Windows.Forms.Button();
|
||||
this.oauth2Picasa = new ShareX.UploadersLib.OAuthControl();
|
||||
this.tpChevereto = new System.Windows.Forms.TabPage();
|
||||
this.lblCheveretoUploadURLExample = new System.Windows.Forms.Label();
|
||||
this.lblCheveretoUploaders = new System.Windows.Forms.Label();
|
||||
this.cbCheveretoUploaders = new System.Windows.Forms.ComboBox();
|
||||
this.cbCheveretoDirectURL = new System.Windows.Forms.CheckBox();
|
||||
|
@ -534,7 +535,7 @@ private void InitializeComponent()
|
|||
this.lblWidthHint = new System.Windows.Forms.Label();
|
||||
this.ttlvMain = new ShareX.HelpersLib.TabToListView();
|
||||
this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl();
|
||||
this.lblCheveretoUploadURLExample = new System.Windows.Forms.Label();
|
||||
this.btnCheveretoTestAll = new System.Windows.Forms.Button();
|
||||
this.tpOtherUploaders.SuspendLayout();
|
||||
this.tcOtherUploaders.SuspendLayout();
|
||||
this.tpTwitter.SuspendLayout();
|
||||
|
@ -4139,6 +4140,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// tpChevereto
|
||||
//
|
||||
this.tpChevereto.Controls.Add(this.btnCheveretoTestAll);
|
||||
this.tpChevereto.Controls.Add(this.lblCheveretoUploadURLExample);
|
||||
this.tpChevereto.Controls.Add(this.lblCheveretoUploaders);
|
||||
this.tpChevereto.Controls.Add(this.cbCheveretoUploaders);
|
||||
|
@ -4151,6 +4153,11 @@ private void InitializeComponent()
|
|||
this.tpChevereto.Name = "tpChevereto";
|
||||
this.tpChevereto.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblCheveretoUploadURLExample
|
||||
//
|
||||
resources.ApplyResources(this.lblCheveretoUploadURLExample, "lblCheveretoUploadURLExample");
|
||||
this.lblCheveretoUploadURLExample.Name = "lblCheveretoUploadURLExample";
|
||||
//
|
||||
// lblCheveretoUploaders
|
||||
//
|
||||
resources.ApplyResources(this.lblCheveretoUploaders, "lblCheveretoUploaders");
|
||||
|
@ -4286,10 +4293,12 @@ private void InitializeComponent()
|
|||
this.actRapidShareAccountType.Name = "actRapidShareAccountType";
|
||||
this.actRapidShareAccountType.SelectedAccountType = ShareX.UploadersLib.AccountType.Anonymous;
|
||||
//
|
||||
// lblCheveretoUploadURLExample
|
||||
// btnCheveretoTestAll
|
||||
//
|
||||
resources.ApplyResources(this.lblCheveretoUploadURLExample, "lblCheveretoUploadURLExample");
|
||||
this.lblCheveretoUploadURLExample.Name = "lblCheveretoUploadURLExample";
|
||||
resources.ApplyResources(this.btnCheveretoTestAll, "btnCheveretoTestAll");
|
||||
this.btnCheveretoTestAll.Name = "btnCheveretoTestAll";
|
||||
this.btnCheveretoTestAll.UseVisualStyleBackColor = true;
|
||||
this.btnCheveretoTestAll.Click += new System.EventHandler(this.btnCheveretoTestAll_Click);
|
||||
//
|
||||
// UploadersConfigForm
|
||||
//
|
||||
|
@ -4952,5 +4961,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.Label lblCheveretoUploaders;
|
||||
private System.Windows.Forms.ComboBox cbCheveretoUploaders;
|
||||
private System.Windows.Forms.Label lblCheveretoUploadURLExample;
|
||||
private System.Windows.Forms.Button btnCheveretoTestAll;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1003,6 +1003,31 @@ private void cbCheveretoUploaders_SelectedIndexChanged(object sender, EventArgs
|
|||
}
|
||||
}
|
||||
|
||||
private void btnCheveretoTestAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnCheveretoTestAll.Enabled = false;
|
||||
btnCheveretoTestAll.Text = "Testing...";
|
||||
string result = null;
|
||||
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
result = Chevereto.TestUploaders();
|
||||
},
|
||||
() =>
|
||||
{
|
||||
if (!IsDisposed)
|
||||
{
|
||||
btnCheveretoTestAll.Text = "Test all";
|
||||
btnCheveretoTestAll.Enabled = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
MessageBox.Show(result, "Chevereto test results", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void txtCheveretoWebsite_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
Config.CheveretoUploader.UploadURL = txtCheveretoUploadURL.Text;
|
||||
|
@ -2151,7 +2176,7 @@ private void btnPomfTest_Click(object sender, EventArgs e)
|
|||
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
result = Pomf.TestClones();
|
||||
result = Pomf.TestUploaders();
|
||||
},
|
||||
() =>
|
||||
{
|
||||
|
|
|
@ -12517,6 +12517,33 @@ Using an encrypted library disables sharing.</value>
|
|||
<data name=">>tpPicasa.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="btnCheveretoTestAll.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="btnCheveretoTestAll.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>264, 31</value>
|
||||
</data>
|
||||
<data name="btnCheveretoTestAll.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>104, 23</value>
|
||||
</data>
|
||||
<data name="btnCheveretoTestAll.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="btnCheveretoTestAll.Text" xml:space="preserve">
|
||||
<value>Test all</value>
|
||||
</data>
|
||||
<data name=">>btnCheveretoTestAll.Name" xml:space="preserve">
|
||||
<value>btnCheveretoTestAll</value>
|
||||
</data>
|
||||
<data name=">>btnCheveretoTestAll.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>btnCheveretoTestAll.Parent" xml:space="preserve">
|
||||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>btnCheveretoTestAll.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="lblCheveretoUploadURLExample.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
|
@ -12542,7 +12569,7 @@ Using an encrypted library disables sharing.</value>
|
|||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>lblCheveretoUploadURLExample.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="lblCheveretoUploaders.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
|
@ -12569,7 +12596,7 @@ Using an encrypted library disables sharing.</value>
|
|||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>lblCheveretoUploaders.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="cbCheveretoUploaders.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>16, 32</value>
|
||||
|
@ -12590,7 +12617,7 @@ Using an encrypted library disables sharing.</value>
|
|||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>cbCheveretoUploaders.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="cbCheveretoDirectURL.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
|
@ -12620,7 +12647,7 @@ Using an encrypted library disables sharing.</value>
|
|||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>cbCheveretoDirectURL.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="lblCheveretoUploadURL.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
|
@ -12650,7 +12677,7 @@ Using an encrypted library disables sharing.</value>
|
|||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>lblCheveretoUploadURL.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="txtCheveretoUploadURL.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>16, 80</value>
|
||||
|
@ -12671,7 +12698,7 @@ Using an encrypted library disables sharing.</value>
|
|||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>txtCheveretoUploadURL.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="txtCheveretoAPIKey.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>16, 128</value>
|
||||
|
@ -12692,7 +12719,7 @@ Using an encrypted library disables sharing.</value>
|
|||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>txtCheveretoAPIKey.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="lblCheveretoAPIKey.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
|
@ -12722,7 +12749,7 @@ Using an encrypted library disables sharing.</value>
|
|||
<value>tpChevereto</value>
|
||||
</data>
|
||||
<data name=">>lblCheveretoAPIKey.ZOrder" xml:space="preserve">
|
||||
<value>7</value>
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="tpChevereto.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>4, 22</value>
|
||||
|
|
|
@ -25,8 +25,13 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
using Newtonsoft.Json;
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace ShareX.UploadersLib.ImageUploaders
|
||||
{
|
||||
|
@ -87,6 +92,50 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
return result;
|
||||
}
|
||||
|
||||
public static string TestUploaders()
|
||||
{
|
||||
List<CheveretoTest> successful = new List<CheveretoTest>();
|
||||
List<CheveretoTest> failed = new List<CheveretoTest>();
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
using (Image logo = ShareXResources.Logo)
|
||||
{
|
||||
logo.Save(ms, ImageFormat.Png);
|
||||
}
|
||||
|
||||
foreach (CheveretoUploader uploader in Uploaders)
|
||||
{
|
||||
try
|
||||
{
|
||||
Chevereto chevereto = new Chevereto(uploader);
|
||||
string filename = Helpers.GetRandomAlphanumeric(10) + ".png";
|
||||
|
||||
Stopwatch timer = Stopwatch.StartNew();
|
||||
UploadResult result = chevereto.Upload(ms, filename);
|
||||
long uploadTime = timer.ElapsedMilliseconds;
|
||||
|
||||
if (result != null && result.IsSuccess && !string.IsNullOrEmpty(result.URL))
|
||||
{
|
||||
successful.Add(new CheveretoTest { Name = uploader.ToString(), UploadTime = uploadTime });
|
||||
}
|
||||
else
|
||||
{
|
||||
failed.Add(new CheveretoTest { Name = uploader.ToString() });
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e);
|
||||
failed.Add(new CheveretoTest { Name = uploader.ToString() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string.Format("Successful uploads ({0}):\r\n\r\n{1}\r\n\r\nFailed uploads ({2}):\r\n\r\n{3}",
|
||||
successful.Count, string.Join("\r\n", successful.OrderBy(x => x.UploadTime)), failed.Count, string.Join("\r\n", failed));
|
||||
}
|
||||
|
||||
private class CheveretoResponse
|
||||
{
|
||||
public CheveretoImage Image { get; set; }
|
||||
|
@ -103,5 +152,21 @@ private class CheveretoThumb
|
|||
{
|
||||
public string URL { get; set; }
|
||||
}
|
||||
|
||||
private class CheveretoTest
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public long UploadTime { get; set; } = -1;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (UploadTime >= 0)
|
||||
{
|
||||
return $"{Name} ({UploadTime}ms)";
|
||||
}
|
||||
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue