mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added nl.cm URL shortener
This commit is contained in:
parent
5d80134937
commit
098e5d43ce
7 changed files with 56 additions and 9 deletions
|
@ -997,6 +997,9 @@ public UploadResult ShortenURL(string url)
|
|||
Password = Program.UploadersConfig.YourlsPassword
|
||||
};
|
||||
break;
|
||||
case UrlShortenerType.NLCM:
|
||||
urlShortener = new NlcmURLShortener();
|
||||
break;
|
||||
case UrlShortenerType.CustomURLShortener:
|
||||
if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomURLShortenerSelected))
|
||||
{
|
||||
|
|
|
@ -135,6 +135,8 @@ public enum UrlShortenerType
|
|||
TURL,
|
||||
[Description("yourls.org")]
|
||||
YOURLS,
|
||||
[Description("nl.cm")]
|
||||
NLCM,
|
||||
[Description("Custom URL shortener")]
|
||||
CustomURLShortener
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ namespace UploadersLib.URLShorteners
|
|||
{
|
||||
public sealed class IsgdURLShortener : URLShortener
|
||||
{
|
||||
private const string APIURL = "http://is.gd/api.php";
|
||||
|
||||
public override UploadResult ShortenURL(string url)
|
||||
{
|
||||
UploadResult result = new UploadResult { URL = url };
|
||||
|
@ -40,7 +38,7 @@ public override UploadResult ShortenURL(string url)
|
|||
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||
arguments.Add("longurl", url);
|
||||
|
||||
result.Response = result.ShortenedURL = SendRequest(HttpMethod.GET, APIURL, arguments);
|
||||
result.Response = result.ShortenedURL = SendRequest(HttpMethod.GET, "http://is.gd/api.php", arguments);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
47
UploadersLib/URLShorteners/NlcmURLShortener.cs
Normal file
47
UploadersLib/URLShorteners/NlcmURLShortener.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
#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 System.Collections.Generic;
|
||||
|
||||
namespace UploadersLib.URLShorteners
|
||||
{
|
||||
public sealed class NlcmURLShortener : URLShortener
|
||||
{
|
||||
public override UploadResult ShortenURL(string url)
|
||||
{
|
||||
UploadResult result = new UploadResult { URL = url };
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||
arguments.Add("url", url);
|
||||
|
||||
result.Response = result.ShortenedURL = SendRequest(HttpMethod.GET, "http://nl.cm/api/", arguments);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,8 +29,6 @@ namespace UploadersLib.URLShorteners
|
|||
{
|
||||
public sealed class TinyURLShortener : URLShortener
|
||||
{
|
||||
private const string APIURL = "http://tinyurl.com/api-create.php";
|
||||
|
||||
public override UploadResult ShortenURL(string url)
|
||||
{
|
||||
UploadResult result = new UploadResult { URL = url };
|
||||
|
@ -40,7 +38,7 @@ public override UploadResult ShortenURL(string url)
|
|||
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||
arguments.Add("url", url);
|
||||
|
||||
result.Response = result.ShortenedURL = SendRequest(HttpMethod.GET, APIURL, arguments);
|
||||
result.Response = result.ShortenedURL = SendRequest(HttpMethod.GET, "http://tinyurl.com/api-create.php", arguments);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -29,8 +29,6 @@ namespace UploadersLib.URLShorteners
|
|||
{
|
||||
public sealed class TurlURLShortener : URLShortener
|
||||
{
|
||||
private const string APIURL = "http://turl.ca/api.php";
|
||||
|
||||
public override UploadResult ShortenURL(string url)
|
||||
{
|
||||
UploadResult result = new UploadResult { URL = url };
|
||||
|
@ -40,7 +38,7 @@ public override UploadResult ShortenURL(string url)
|
|||
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||
arguments.Add("url", url);
|
||||
|
||||
result.Response = SendRequest(HttpMethod.GET, APIURL, arguments);
|
||||
result.Response = SendRequest(HttpMethod.GET, "http://turl.ca/api.php", arguments);
|
||||
|
||||
if (!string.IsNullOrEmpty(result.Response))
|
||||
{
|
||||
|
|
|
@ -282,6 +282,7 @@
|
|||
<Compile Include="URLShorteners\CustomURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\GoogleURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\IsgdURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\NlcmURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\TinyURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\TurlURLShortener.cs" />
|
||||
<Compile Include="FileUploaders\MediaCrushUploader.cs" />
|
||||
|
|
Loading…
Reference in a new issue