mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added v.gd url shortener, Updated is.gd API usage
This commit is contained in:
parent
2db840ef3d
commit
ea80f46acc
5 changed files with 55 additions and 3 deletions
|
@ -136,6 +136,8 @@ public enum UrlShortenerType
|
|||
Google,
|
||||
[Description("is.gd")]
|
||||
ISGD,
|
||||
[Description("v.gd")]
|
||||
VGD,
|
||||
[Description("tinyurl.com")]
|
||||
TINYURL,
|
||||
[Description("turl.ca")]
|
||||
|
|
|
@ -281,6 +281,7 @@
|
|||
<Compile Include="URLShorteners\TinyURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\TurlURLShortener.cs" />
|
||||
<Compile Include="FileUploaders\MediaCrushUploader.cs" />
|
||||
<Compile Include="URLShorteners\VgdURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\YourlsURLShortener.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -23,12 +23,15 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ShareX.UploadersLib.URLShorteners
|
||||
{
|
||||
public sealed class IsgdURLShortener : URLShortener
|
||||
public class IsgdURLShortener : URLShortener
|
||||
{
|
||||
protected virtual string APIURL { get { return "http://is.gd/create.php"; } }
|
||||
|
||||
public override UploadResult ShortenURL(string url)
|
||||
{
|
||||
UploadResult result = new UploadResult { URL = url };
|
||||
|
@ -36,9 +39,15 @@ public override UploadResult ShortenURL(string url)
|
|||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||
arguments.Add("longurl", url);
|
||||
arguments.Add("format", "simple");
|
||||
arguments.Add("url", url);
|
||||
|
||||
result.Response = result.ShortenedURL = SendRequest(HttpMethod.GET, "http://is.gd/api.php", arguments);
|
||||
result.Response = SendRequest(HttpMethod.GET, APIURL, arguments);
|
||||
|
||||
if (!result.Response.StartsWith("Error:", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
result.ShortenedURL = result.Response;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
37
ShareX.UploadersLib/URLShorteners/VgdURLShortener.cs
Normal file
37
ShareX.UploadersLib/URLShorteners/VgdURLShortener.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright © 2007-2015 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ShareX.UploadersLib.URLShorteners
|
||||
{
|
||||
public class VgdURLShortener : IsgdURLShortener
|
||||
{
|
||||
protected override string APIURL { get { return "http://v.gd/create.php"; } }
|
||||
}
|
||||
}
|
|
@ -1030,6 +1030,9 @@ public UploadResult ShortenURL(string url)
|
|||
case UrlShortenerType.ISGD:
|
||||
urlShortener = new IsgdURLShortener();
|
||||
break;
|
||||
case UrlShortenerType.VGD:
|
||||
urlShortener = new VgdURLShortener();
|
||||
break;
|
||||
case UrlShortenerType.TINYURL:
|
||||
urlShortener = new TinyURLShortener();
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue