mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added gfycat support. Anonymous uploads only, supports gif and ffmpeg video.
This commit is contained in:
parent
2ed433ffef
commit
710c9c6c2b
4 changed files with 94 additions and 0 deletions
|
@ -815,6 +815,9 @@ public UploadResult UploadFile(Stream stream, string fileName)
|
|||
Share = Program.UploadersConfig.BoxShare
|
||||
};
|
||||
break;
|
||||
case FileDestination.Gfycat:
|
||||
fileUploader = new GfycatUploader();
|
||||
break;
|
||||
case FileDestination.Ge_tt:
|
||||
if (Program.UploadersConfig.IsActive(FileDestination.Ge_tt))
|
||||
{
|
||||
|
|
|
@ -86,6 +86,8 @@ public enum FileDestination
|
|||
Dropbox,
|
||||
[Description("FTP Server")]
|
||||
FTP,
|
||||
[Description("gfycat.com")]
|
||||
Gfycat,
|
||||
[Description("mega.co.nz")]
|
||||
Mega,
|
||||
[Description("s3.amazon.com")]
|
||||
|
|
88
UploadersLib/FileUploaders/GfycatUploader.cs
Normal file
88
UploadersLib/FileUploaders/GfycatUploader.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (C) 2007-2014 ShareX Developers
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using HelpersLib;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using UploadersLib.HelperClasses;
|
||||
|
||||
namespace UploadersLib.FileUploaders
|
||||
{
|
||||
public class GfycatUploader : FileUploader
|
||||
{
|
||||
public override UploadResult Upload(Stream stream, string fileName)
|
||||
{
|
||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
|
||||
// Magical official values from http://www.reddit.com/r/gfycat/comments/20xbth/any_word_on_allowing_uploading_a_gif_through_the/
|
||||
args.Add("key", Helpers.GetRandomAlphanumeric(10));
|
||||
args.Add("acl", "private");
|
||||
args.Add("AWSAccessKeyId", "AKIAIT4VU4B7G2LQYKZQ");
|
||||
args.Add("policy", "eyAiZXhwaXJhdGlvbiI6ICIyMDIwLTEyLTAxVDEyOjAwOjAwLjAwMFoiLAogICAgICAgICAgICAiY29uZGl0aW9ucyI6IFsKICAgICAgICAgICAgeyJidWNrZXQiOiAiZ2lmYWZmZSJ9LAogICAgICAgICAgICBbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAiIl0sCiAgICAgICAgICAgIHsiYWNsIjogInByaXZhdGUifSwKCSAgICB7InN1Y2Nlc3NfYWN0aW9uX3N0YXR1cyI6ICIyMDAifSwKICAgICAgICAgICAgWyJzdGFydHMtd2l0aCIsICIkQ29udGVudC1UeXBlIiwgIiJdLAogICAgICAgICAgICBbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwgMCwgNTI0Mjg4MDAwXQogICAgICAgICAgICBdCiAgICAgICAgICB9");
|
||||
args.Add("success_action_status", "200");
|
||||
args.Add("signature", "mk9t/U/wRN4/uU01mXfeTe2Kcoc=");
|
||||
args.Add("Content-Type", MimeTypes.GetMimeType(Path.GetExtension(fileName).ToLower()));
|
||||
UploadResult result = UploadData(stream, "https://gifaffe.s3.amazonaws.com/", fileName, "file", args);
|
||||
|
||||
if (!result.IsError)
|
||||
{
|
||||
TranscodeFile(args["key"], result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void TranscodeFile(string key, UploadResult result)
|
||||
{
|
||||
string json = SendRequest(HttpMethod.GET, "https://upload.gfycat.com/transcode/" + key);
|
||||
GfycatTranscodeResponse response = JsonConvert.DeserializeObject<GfycatTranscodeResponse>(json);
|
||||
|
||||
if (response.Task == GfycatTask.COMPLETE)
|
||||
{
|
||||
result.URL = "http://gfycat.com/" + response.GfyName;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Errors.Add(response.Error);
|
||||
result.IsSuccess = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GfycatTranscodeResponse
|
||||
{
|
||||
public GfycatTask Task { get; set; }
|
||||
public string GfyName { get; set; }
|
||||
public string Error { get; set; }
|
||||
}
|
||||
|
||||
public enum GfycatTask {
|
||||
ERROR,
|
||||
COMPLETE
|
||||
}
|
||||
}
|
|
@ -174,6 +174,7 @@
|
|||
<DependentUpon>UploadersConfigForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FileUploaders\Pushbullet.cs" />
|
||||
<Compile Include="FileUploaders\GfycatUploader.cs" />
|
||||
<Compile Include="TextUploaders\Upaste.cs" />
|
||||
<Compile Include="UploadersConfig.cs" />
|
||||
<Compile Include="GUI\UserPassBox.cs">
|
||||
|
|
Loading…
Reference in a new issue