mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Add LnkU URL Shortener
This commit is contained in:
parent
b7c4005ea9
commit
843a07566b
9 changed files with 117 additions and 4 deletions
|
@ -154,6 +154,8 @@ public enum UrlShortenerType
|
||||||
NLCM,
|
NLCM,
|
||||||
[Description("adf.ly")]
|
[Description("adf.ly")]
|
||||||
AdFly,
|
AdFly,
|
||||||
|
[Description("lnku.co")]
|
||||||
|
LnkU,
|
||||||
CustomURLShortener // Localized
|
CustomURLShortener // Localized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
ShareX.UploadersLib/Favicons/LnkU.ico
Normal file
BIN
ShareX.UploadersLib/Favicons/LnkU.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -95,6 +95,7 @@ private void FormSettings()
|
||||||
AddIconToTab(tpImageShack, Resources.ImageShack);
|
AddIconToTab(tpImageShack, Resources.ImageShack);
|
||||||
AddIconToTab(tpImgur, Resources.Imgur);
|
AddIconToTab(tpImgur, Resources.Imgur);
|
||||||
AddIconToTab(tpJira, Resources.jira);
|
AddIconToTab(tpJira, Resources.jira);
|
||||||
|
AddIconToTab(tpLnkU, Resources.LnkU);
|
||||||
AddIconToTab(tpMediaFire, Resources.MediaFire);
|
AddIconToTab(tpMediaFire, Resources.MediaFire);
|
||||||
AddIconToTab(tpMega, Resources.Mega);
|
AddIconToTab(tpMega, Resources.Mega);
|
||||||
AddIconToTab(tpMinus, Resources.Minus);
|
AddIconToTab(tpMinus, Resources.Minus);
|
||||||
|
@ -582,6 +583,10 @@ public void LoadSettings(UploadersConfig uploadersConfig)
|
||||||
txtAdflyAPIKEY.Text = Config.AdFlyAPIKEY;
|
txtAdflyAPIKEY.Text = Config.AdFlyAPIKEY;
|
||||||
txtAdflyAPIUID.Text = Config.AdFlyAPIUID;
|
txtAdflyAPIUID.Text = Config.AdFlyAPIUID;
|
||||||
|
|
||||||
|
// lnku.co
|
||||||
|
|
||||||
|
txtLnkUAPIKEY.Text = Config.LnkUAPIKEY;
|
||||||
|
|
||||||
#endregion URL Shorteners
|
#endregion URL Shorteners
|
||||||
|
|
||||||
#region Other Services
|
#region Other Services
|
||||||
|
@ -2133,13 +2138,21 @@ private void llAdflyLink_LinkClicked(object sender, LinkLabelLinkClickedEventArg
|
||||||
|
|
||||||
#endregion adf.ly
|
#endregion adf.ly
|
||||||
|
|
||||||
#endregion URL Shorteners
|
#region LnkU.co
|
||||||
|
|
||||||
#region Other Uploaders
|
private void txtLnkUAPIKEY_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Config.LnkUAPIKEY = txtLnkUAPIKEY.Text;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Twitter
|
#endregion URL Shorteners
|
||||||
|
|
||||||
private void btnTwitterAdd_Click(object sender, EventArgs e)
|
#region Other Uploaders
|
||||||
|
|
||||||
|
#region Twitter
|
||||||
|
|
||||||
|
private void btnTwitterAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OAuthInfo oauth = new OAuthInfo();
|
OAuthInfo oauth = new OAuthInfo();
|
||||||
Config.TwitterOAuthInfoList.Add(oauth);
|
Config.TwitterOAuthInfoList.Add(oauth);
|
||||||
|
|
10
ShareX.UploadersLib/Properties/Resources.Designer.cs
generated
10
ShareX.UploadersLib/Properties/Resources.Designer.cs
generated
|
@ -421,6 +421,16 @@ internal static System.Drawing.Icon Lambda {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Icon LnkU {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("LnkU", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -461,4 +461,7 @@ Created folders:</value>
|
||||||
<data name="Hubic" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="Hubic" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Favicons\hubic.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Favicons\hubic.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="LnkU" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Favicons\LnkU.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -289,6 +289,7 @@
|
||||||
<Compile Include="URLShorteners\CustomURLShortener.cs" />
|
<Compile Include="URLShorteners\CustomURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\GoogleURLShortener.cs" />
|
<Compile Include="URLShorteners\GoogleURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\IsgdURLShortener.cs" />
|
<Compile Include="URLShorteners\IsgdURLShortener.cs" />
|
||||||
|
<Compile Include="URLShorteners\LnkUURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\NlcmURLShortener.cs" />
|
<Compile Include="URLShorteners\NlcmURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\TinyURLShortener.cs" />
|
<Compile Include="URLShorteners\TinyURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\TurlURLShortener.cs" />
|
<Compile Include="URLShorteners\TurlURLShortener.cs" />
|
||||||
|
@ -745,6 +746,10 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Favicons\Up1.ico" />
|
<None Include="Favicons\Up1.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Favicons\LnkU.ico" />
|
||||||
|
<None Include="Resources\LnkU.ico" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
69
ShareX.UploadersLib/URLShorteners/LnkUURLShortener.cs
Normal file
69
ShareX.UploadersLib/URLShorteners/LnkUURLShortener.cs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
#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 Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ShareX.UploadersLib.URLShorteners
|
||||||
|
{
|
||||||
|
public sealed class LnkUURLShortener : URLShortener
|
||||||
|
{
|
||||||
|
private const string API_ENDPOINT = "https://api-ssl.bitly.com/";
|
||||||
|
public string API_KEY { get; set; }
|
||||||
|
|
||||||
|
public override UploadResult ShortenURL(string url)
|
||||||
|
{
|
||||||
|
UploadResult result = new UploadResult { URL = url };
|
||||||
|
|
||||||
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
|
args.Add("apikey", API_KEY);
|
||||||
|
args.Add("action" , "shorten");
|
||||||
|
args.Add("url", url);
|
||||||
|
|
||||||
|
string response = SendRequest(HttpMethod.GET, API_ENDPOINT, args);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(response))
|
||||||
|
{
|
||||||
|
LnkUURLShortenerResponse jsonResponse = JsonConvert.DeserializeObject<LnkUURLShortenerResponse>(response);
|
||||||
|
|
||||||
|
if (jsonResponse != null)
|
||||||
|
{
|
||||||
|
result.ShortenedURL = jsonResponse.shorturl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LnkUURLShortenerResponse
|
||||||
|
{
|
||||||
|
public string shortcode { get; set; }
|
||||||
|
public string site { get; set; }
|
||||||
|
public string shorturl { get; set; }
|
||||||
|
public string fullurl { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -275,6 +275,9 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
||||||
public string AdFlyAPIKEY = String.Empty;
|
public string AdFlyAPIKEY = String.Empty;
|
||||||
public string AdFlyAPIUID = String.Empty;
|
public string AdFlyAPIUID = String.Empty;
|
||||||
|
|
||||||
|
// lnku.co
|
||||||
|
public string LnkUAPIKEY = string.Empty;
|
||||||
|
|
||||||
#endregion URL shorteners
|
#endregion URL shorteners
|
||||||
|
|
||||||
#region URL sharing services
|
#region URL sharing services
|
||||||
|
@ -428,6 +431,8 @@ public bool IsValid(UrlShortenerType destination)
|
||||||
return !string.IsNullOrEmpty(YourlsAPIURL) && (!string.IsNullOrEmpty(YourlsSignature) || (!string.IsNullOrEmpty(YourlsUsername) && !string.IsNullOrEmpty(YourlsPassword)));
|
return !string.IsNullOrEmpty(YourlsAPIURL) && (!string.IsNullOrEmpty(YourlsSignature) || (!string.IsNullOrEmpty(YourlsUsername) && !string.IsNullOrEmpty(YourlsPassword)));
|
||||||
case UrlShortenerType.AdFly:
|
case UrlShortenerType.AdFly:
|
||||||
return !string.IsNullOrEmpty(AdFlyAPIKEY) && !string.IsNullOrEmpty(AdFlyAPIUID);
|
return !string.IsNullOrEmpty(AdFlyAPIKEY) && !string.IsNullOrEmpty(AdFlyAPIUID);
|
||||||
|
case UrlShortenerType.LnkU:
|
||||||
|
return !string.IsNullOrEmpty(LnkUAPIKEY);
|
||||||
case UrlShortenerType.CustomURLShortener:
|
case UrlShortenerType.CustomURLShortener:
|
||||||
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected);
|
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1075,6 +1075,12 @@ public UploadResult ShortenURL(string url)
|
||||||
APIUID = Program.UploadersConfig.AdFlyAPIUID
|
APIUID = Program.UploadersConfig.AdFlyAPIUID
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
case UrlShortenerType.LnkU:
|
||||||
|
urlShortener = new LnkUURLShortener
|
||||||
|
{
|
||||||
|
API_KEY = Program.UploadersConfig.LnkUAPIKEY
|
||||||
|
};
|
||||||
|
break;
|
||||||
case UrlShortenerType.CustomURLShortener:
|
case UrlShortenerType.CustomURLShortener:
|
||||||
CustomUploaderItem customUploader = GetCustomUploader(Program.UploadersConfig.CustomURLShortenerSelected);
|
CustomUploaderItem customUploader = GetCustomUploader(Program.UploadersConfig.CustomURLShortenerSelected);
|
||||||
if (customUploader != null)
|
if (customUploader != null)
|
||||||
|
|
Loading…
Reference in a new issue