mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added Gfycat icon
This commit is contained in:
parent
0a6460bdec
commit
3700fc30d6
9 changed files with 7985 additions and 1872 deletions
|
@ -105,12 +105,12 @@ public enum FileDestination
|
|||
AmazonS3,
|
||||
[Description("Azure Storage")]
|
||||
AzureStorage,
|
||||
[Description("Gfycat")]
|
||||
Gfycat,
|
||||
[Description("ownCloud")]
|
||||
OwnCloud,
|
||||
[Description("MediaFire")]
|
||||
MediaFire,
|
||||
[Description("Gfycat")]
|
||||
Gfycat,
|
||||
[Description("Pushbullet")]
|
||||
Pushbullet,
|
||||
[Description("SendSpace")]
|
||||
|
|
BIN
ShareX.UploadersLib/Favicons/Gfycat.png
Normal file
BIN
ShareX.UploadersLib/Favicons/Gfycat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 871 B |
|
@ -27,8 +27,10 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
using Newtonsoft.Json;
|
||||
using ShareX.HelpersLib;
|
||||
using ShareX.UploadersLib.Properties;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
@ -39,6 +41,8 @@ public class GfycatFileUploaderService : FileUploaderService
|
|||
{
|
||||
public override FileDestination EnumValue { get; } = FileDestination.Gfycat;
|
||||
|
||||
public override Image ServiceImage => Resources.Gfycat;
|
||||
|
||||
public override bool CheckConfig(UploadersConfig config)
|
||||
{
|
||||
return config.GfycatAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(config.GfycatOAuth2Info);
|
||||
|
@ -50,6 +54,7 @@ public override GenericUploader CreateUploader(UploadersConfig config, TaskRefer
|
|||
{
|
||||
config.GfycatOAuth2Info = new OAuth2Info(APIKeys.GfycatClientID, APIKeys.GfycatClientSecret);
|
||||
}
|
||||
|
||||
return new GfycatUploader(config.GfycatOAuth2Info)
|
||||
{
|
||||
UploadMethod = config.GfycatAccountType,
|
||||
|
@ -57,17 +62,17 @@ public override GenericUploader CreateUploader(UploadersConfig config, TaskRefer
|
|||
};
|
||||
}
|
||||
|
||||
public override TabPage GetUploadersConfigTabPage(UploadersConfigForm form) => form.tpImgur;
|
||||
public override TabPage GetUploadersConfigTabPage(UploadersConfigForm form) => form.tpGfycat;
|
||||
}
|
||||
|
||||
public class GfycatUploader : FileUploader, IOAuth2
|
||||
{
|
||||
public bool NoResize { get; set; }
|
||||
public bool IgnoreExisting { get; set; }
|
||||
public bool Private { get; set; }
|
||||
public OAuth2Info AuthInfo { get; set; }
|
||||
public AccountType UploadMethod { get; set; }
|
||||
public OAuth2Token AnonymousToken { get; set; }
|
||||
public bool NoResize { get; set; }
|
||||
public bool IgnoreExisting { get; set; }
|
||||
public bool Private { get; set; }
|
||||
|
||||
private const string URL_AUTHORIZE = "https://gfycat.com/oauth/authorize";
|
||||
private const string URL_UPLOAD = "https://filedrop.gfycat.com";
|
||||
|
@ -88,7 +93,7 @@ public string GetAuthorizationURL()
|
|||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
args.Add("client_id", AuthInfo.Client_ID);
|
||||
args.Add("scope", "all");
|
||||
args.Add("state", "sharex");
|
||||
args.Add("state", "ShareX");
|
||||
args.Add("response_type", "code");
|
||||
args.Add("redirect_uri", Links.URL_CALLBACK);
|
||||
|
||||
|
@ -179,13 +184,16 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
NameValueCollection headers = new NameValueCollection();
|
||||
headers.Add("Authorization", "Bearer " + token.access_token);
|
||||
|
||||
GfycatCreateResponse gfy = CreateGfycat(headers);
|
||||
if (gfy == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
args.Add("key", gfy.GfyName);
|
||||
UploadResult result = SendRequestFile(URL_UPLOAD, stream, fileName, "file", args);
|
||||
|
@ -223,7 +231,8 @@ private void WaitForTranscode(string name, UploadResult result)
|
|||
result.IsSuccess = true;
|
||||
result.URL = "https://gfycat.com/" + response.GfyName;
|
||||
break;
|
||||
} else if (response.Task == "NotFoundo" && iterations > 10)
|
||||
}
|
||||
else if (response.Task == "NotFound" && iterations > 10)
|
||||
{
|
||||
Errors.Add("Gfy not found");
|
||||
result.IsSuccess = false;
|
||||
|
@ -246,7 +255,10 @@ private GfycatCreateResponse CreateGfycat(NameValueCollection headers)
|
|||
args.Add("private", Private);
|
||||
args.Add("noResize", NoResize);
|
||||
args.Add("noMd5", IgnoreExisting);
|
||||
string response = SendRequest(HttpMethod.POST, URL_API_CREATE_GFY, JsonConvert.SerializeObject(args), ContentTypeJSON, null, headers);
|
||||
|
||||
string json = JsonConvert.SerializeObject(args);
|
||||
|
||||
string response = SendRequest(HttpMethod.POST, URL_API_CREATE_GFY, json, ContentTypeJSON, null, headers);
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
return JsonConvert.DeserializeObject<GfycatCreateResponse>(response);
|
||||
|
@ -288,6 +300,7 @@ private OAuth2Token GetOrCreateToken()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return AnonymousToken;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -459,6 +459,7 @@ private void InitializeComponent()
|
|||
this.lblEmailSmtpPort = new System.Windows.Forms.Label();
|
||||
this.txtEmailDefaultSubject = new System.Windows.Forms.TextBox();
|
||||
this.tpGfycat = new System.Windows.Forms.TabPage();
|
||||
this.cbGfycatIsPublic = new System.Windows.Forms.CheckBox();
|
||||
this.atcGfycatAccountType = new ShareX.UploadersLib.AccountTypeControl();
|
||||
this.oauth2Gfycat = new ShareX.UploadersLib.OAuthControl();
|
||||
this.btnCopyShowFiles = new System.Windows.Forms.Button();
|
||||
|
@ -602,7 +603,6 @@ private void InitializeComponent()
|
|||
this.ttlvMain = new ShareX.HelpersLib.TabToListView();
|
||||
this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.cbGfycatIsPublic = new System.Windows.Forms.CheckBox();
|
||||
this.tpOtherUploaders.SuspendLayout();
|
||||
this.tcOtherUploaders.SuspendLayout();
|
||||
this.tpTwitter.SuspendLayout();
|
||||
|
@ -1724,6 +1724,7 @@ private void InitializeComponent()
|
|||
this.tcFileUploaders.Controls.Add(this.tpBox);
|
||||
this.tcFileUploaders.Controls.Add(this.tpAmazonS3);
|
||||
this.tcFileUploaders.Controls.Add(this.tpAzureStorage);
|
||||
this.tcFileUploaders.Controls.Add(this.tpGfycat);
|
||||
this.tcFileUploaders.Controls.Add(this.tpMega);
|
||||
this.tcFileUploaders.Controls.Add(this.tpOwnCloud);
|
||||
this.tcFileUploaders.Controls.Add(this.tpMediaFire);
|
||||
|
@ -1743,7 +1744,6 @@ private void InitializeComponent()
|
|||
this.tcFileUploaders.Controls.Add(this.tpPlik);
|
||||
this.tcFileUploaders.Controls.Add(this.tpSharedFolder);
|
||||
this.tcFileUploaders.Controls.Add(this.tpEmail);
|
||||
this.tcFileUploaders.Controls.Add(this.tpGfycat);
|
||||
resources.ApplyResources(this.tcFileUploaders, "tcFileUploaders");
|
||||
this.tcFileUploaders.Multiline = true;
|
||||
this.tcFileUploaders.Name = "tcFileUploaders";
|
||||
|
@ -3829,6 +3829,13 @@ private void InitializeComponent()
|
|||
this.tpGfycat.Name = "tpGfycat";
|
||||
this.tpGfycat.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbGfycatIsPublic
|
||||
//
|
||||
resources.ApplyResources(this.cbGfycatIsPublic, "cbGfycatIsPublic");
|
||||
this.cbGfycatIsPublic.Name = "cbGfycatIsPublic";
|
||||
this.cbGfycatIsPublic.UseVisualStyleBackColor = true;
|
||||
this.cbGfycatIsPublic.CheckedChanged += new System.EventHandler(this.cbGfycatIsPublic_CheckedChanged);
|
||||
//
|
||||
// atcGfycatAccountType
|
||||
//
|
||||
resources.ApplyResources(this.atcGfycatAccountType, "atcGfycatAccountType");
|
||||
|
@ -4859,13 +4866,6 @@ private void InitializeComponent()
|
|||
this.actRapidShareAccountType.Name = "actRapidShareAccountType";
|
||||
this.actRapidShareAccountType.SelectedAccountType = ShareX.UploadersLib.AccountType.Anonymous;
|
||||
//
|
||||
// cbGfycatIsPublic
|
||||
//
|
||||
resources.ApplyResources(this.cbGfycatIsPublic, "cbGfycatIsPublic");
|
||||
this.cbGfycatIsPublic.Name = "cbGfycatIsPublic";
|
||||
this.cbGfycatIsPublic.UseVisualStyleBackColor = true;
|
||||
this.cbGfycatIsPublic.CheckedChanged += new System.EventHandler(this.cbGfycatIsPublic_CheckedChanged);
|
||||
//
|
||||
// UploadersConfigForm
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
|
@ -5608,9 +5608,9 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.Label lblAmazonS3Endpoint;
|
||||
private System.Windows.Forms.CheckBox cbDropboxUseDirectLink;
|
||||
private System.Windows.Forms.CheckBox cbAmazonS3UsePathStyle;
|
||||
private System.Windows.Forms.TabPage tpGfycat;
|
||||
private OAuthControl oauth2Gfycat;
|
||||
private AccountTypeControl atcGfycatAccountType;
|
||||
private System.Windows.Forms.CheckBox cbGfycatIsPublic;
|
||||
internal System.Windows.Forms.TabPage tpGfycat;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -623,6 +623,8 @@ public void LoadSettings()
|
|||
|
||||
// Gfycat
|
||||
|
||||
atcGfycatAccountType.SelectedAccountType = Config.GfycatAccountType;
|
||||
|
||||
oauth2Gfycat.Enabled = Config.GfycatAccountType == AccountType.User;
|
||||
|
||||
if (OAuth2Info.CheckOAuth(Config.GfycatOAuth2Info))
|
||||
|
@ -630,7 +632,7 @@ public void LoadSettings()
|
|||
oauth2Gfycat.Status = OAuthLoginStatus.LoginSuccessful;
|
||||
}
|
||||
|
||||
atcGfycatAccountType.SelectedAccountType = Config.GfycatAccountType;
|
||||
cbGfycatIsPublic.Checked = Config.GfycatIsPublic;
|
||||
|
||||
#endregion File uploaders
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
10
ShareX.UploadersLib/Properties/Resources.Designer.cs
generated
10
ShareX.UploadersLib/Properties/Resources.Designer.cs
generated
|
@ -225,6 +225,16 @@ internal static System.Drawing.Icon Gett {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Gfycat {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Gfycat", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
|
|
|
@ -386,4 +386,7 @@ Created folders:</value>
|
|||
<data name="Plik" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\favicons\plik.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Gfycat" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\favicons\gfycat.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
|
@ -220,6 +220,11 @@
|
|||
<Compile Include="Helpers\SSLBypassHelper.cs" />
|
||||
<Compile Include="BaseServices\URLSharingService.cs" />
|
||||
<Compile Include="OtherServices\OCRSpace.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SharingServices\DeliciousSharingService.cs" />
|
||||
<Compile Include="SharingServices\EmailSharingService.cs" />
|
||||
<Compile Include="SharingServices\FacebookSharingService.cs" />
|
||||
|
@ -318,11 +323,6 @@
|
|||
<Compile Include="ImageUploaders\YfrogUploader.cs" />
|
||||
<Compile Include="FileUploaders\LocalhostAccount.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BaseUploaders\TextUploader.cs" />
|
||||
<Compile Include="TextUploaders\Paste2.cs" />
|
||||
<Compile Include="TextUploaders\Pastebin_ca.cs" />
|
||||
|
@ -799,8 +799,8 @@
|
|||
<EmbeddedResource Include="Properties\Resources.pt-BR.resx" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.ru.resx" />
|
||||
<EmbeddedResource Include="Properties\Resources.tr.resx" />
|
||||
|
@ -911,6 +911,7 @@
|
|||
<None Include="Favicons\Pastie.png" />
|
||||
<Content Include="Favicons\AzureStorage.png" />
|
||||
<None Include="Favicons\Plik.ico" />
|
||||
<Content Include="Favicons\Gfycat.png" />
|
||||
<Content Include="Favicons\Uplea.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
Loading…
Reference in a new issue