Removing outdated classes

This commit is contained in:
Jaex 2014-12-11 05:15:21 +02:00
parent 0eefbc19f8
commit 3e4e3c27bf
4 changed files with 0 additions and 376 deletions

View file

@ -1,139 +0,0 @@
#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 Newtonsoft.Json.Linq;
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.Linq;
namespace ShareX.UploadersLib.OtherServices
{
public class GoogleTranslate : Uploader
{
private const string APIURL = "https://www.googleapis.com/language/translate/v2";
private string APIKey;
public GoogleTranslate(string apiKey)
{
APIKey = apiKey;
}
public List<GoogleLanguage> GetLanguages()
{
string url = APIURL + "/languages";
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("key", APIKey);
args.Add("target", "en");
string response = SendRequest(HttpMethod.GET, url, args);
if (!string.IsNullOrEmpty(response))
{
try
{
JToken jt = JObject.Parse(response).SelectToken("data.languages");
return jt.Select(x => new GoogleLanguage((string)x.SelectToken("language"), (string)x.SelectToken("name"))).ToList();
}
catch (Exception e)
{
DebugHelper.WriteException(e);
}
}
return null;
}
public GoogleTranslateInfo TranslateText(string text, string targetLanguage, string sourceLanguage = null)
{
GoogleTranslateInfo translateInfo = new GoogleTranslateInfo();
translateInfo.Text = text;
translateInfo.SourceLanguage = sourceLanguage;
translateInfo.TargetLanguage = targetLanguage;
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("key", APIKey);
if (!string.IsNullOrEmpty(sourceLanguage)) args.Add("source", sourceLanguage);
args.Add("target", targetLanguage);
args.Add("q", text);
string response = SendRequest(HttpMethod.GET, APIURL, args);
if (!string.IsNullOrEmpty(response))
{
try
{
JToken jt = JObject.Parse(response).SelectToken("data.translations");
translateInfo.Result = (string)jt[0]["translatedText"];
if (string.IsNullOrEmpty(sourceLanguage))
{
translateInfo.SourceLanguage = (string)jt[0]["detectedSourceLanguage"];
}
}
catch (Exception e)
{
DebugHelper.WriteException(e);
}
}
return translateInfo;
}
public GoogleTranslateInfo TranslateText(GoogleTranslateInfo info)
{
return TranslateText(info.Text, info.TargetLanguage, info.SourceLanguage);
}
}
public class GoogleTranslateInfo
{
public string Text { get; set; }
public string SourceLanguage { get; set; }
public string TargetLanguage { get; set; }
public string Result { get; set; }
}
public class GoogleLanguage
{
public string Language { get; set; }
public string Name { get; set; }
public GoogleLanguage()
{
}
public GoogleLanguage(string language, string name)
{
Language = language;
Name = name;
}
}
}

View file

@ -1,43 +0,0 @@
#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 ShareX.HelpersLib;
using ShareX.UploadersLib.OtherServices;
using System.Collections.Generic;
namespace ShareX.UploadersLib
{
public class GoogleTranslatorConfig : SettingsBase<GoogleTranslatorConfig>
{
public string APIKey = "";
public List<GoogleLanguage> GoogleLanguages;
public string GoogleSourceLanguage = "en";
public bool GoogleAutoDetectSource = true;
public string GoogleTargetLanguage = "en";
public string GoogleTargetLanguage2 = "?";
public bool AutoTranslate = false;
public int AutoTranslateLength = 20;
}
}

View file

@ -1,191 +0,0 @@
#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 ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace ShareX.UploadersLib.OtherServices
{
public class Lyricsfly : Uploader
{
public string UserID { get; set; }
public string AppID { get; set; }
public Lyricsfly(string userID, string appID)
{
UserID = userID;
AppID = appID;
}
/// <summary>
/// To search by artist and title combination
/// </summary>
public Lyrics SearchLyrics(string artist, string title)
{
Dictionary<string, string> arguments = new Dictionary<string, string>();
arguments.Add("i", UserID + AppID);
arguments.Add("a", FixText(artist));
arguments.Add("t", FixText(title));
string response = SendRequest(HttpMethod.GET, "http://lyricsfly.com/api/api.php", arguments);
return ParseResponse(response);
}
/// <summary>
/// To search by lyrics text string
/// </summary>
public Lyrics SearchLyrics(string text)
{
Dictionary<string, string> arguments = new Dictionary<string, string>();
arguments.Add("i", UserID + AppID);
arguments.Add("l", FixText(text));
string response = SendRequest(HttpMethod.GET, "http://lyricsfly.com/api/txt-api.php", arguments);
return ParseResponse(response);
}
/// <summary>
/// Function to edit lyrics (incomplete)
/// </summary>
/// <param name="lyrics"></param>
public void EditLyrics(Lyrics lyrics)
{
Dictionary<string, string> arguments = new Dictionary<string, string>();
arguments.Add("cs", lyrics.Checksum);
arguments.Add("id", lyrics.SongID);
string response = SendRequest(HttpMethod.GET, "http://lyricsfly.com/search/correction.php?", arguments);
ParseResponse(response);
}
private Lyrics ParseResponse(string response)
{
if (!string.IsNullOrEmpty(response))
{
XDocument xdoc = XDocument.Parse(response);
XElement xele = xdoc.Element("start");
if (xele != null)
{
string status = xele.GetElementValue("status");
if (!string.IsNullOrEmpty(status))
{
switch (status)
{
case "200": // OK - Results are returned. All parameters checked ok.
case "300": // TESTING LIMITED - Temporary access. Limited content. All parameters checked ok.
xele = xele.Element("sg");
if (xele != null)
{
Lyrics lyric = new Lyrics();
lyric.Checksum = xele.GetElementValue("cs");
lyric.SongID = xele.GetElementValue("id");
lyric.ArtistName = xele.GetElementValue("ar");
lyric.Title = xele.GetElementValue("tt");
lyric.AlbumName = xele.GetElementValue("al");
lyric.Text = xele.GetElementValue("tx").Replace("[br]", string.Empty);
return lyric;
}
break;
case "204": // NO CONTENT
Errors.Add("Parameter query returned no results. All parameters checked ok.");
break;
case "400": // MISSING KEY
Errors.Add("Parameter “i” missing. Authorization failed.");
break;
case "401": // UNAUTHORIZED
Errors.Add("Parameter “i” invalid. Authorization failed.");
break;
case "402": // LIMITED TIME
Errors.Add("Query request too soon. Limit query requests. Time of delay is shown in <delay> tag in milliseconds.");
break;
case "406": // QUERY TOO SHORT
Errors.Add("Query request string is too short. All other parameters checked ok.");
break;
default:
Errors.Add("Unknown status.");
break;
}
}
}
}
return null;
}
/// <summary>
/// Because our database varies with many html format encodings including international characters,
/// we recommend that you replace all quotes, ampersands and all other special and international characters with "%".
/// Simply put; if the character is not [A-Z a-z 0-9] or space, just substitute "%" for it to get most out of your results.
/// </summary>
private string FixText(string text)
{
char[] chars = text.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
if (!Char.IsLetterOrDigit(chars[i]) && chars[i] != ' ')
{
chars[i] = '%';
}
}
return new string(chars);
}
}
public class Lyrics
{
/// <summary>
/// cs - checksum (for original URL link back construction)
/// </summary>
public string Checksum { get; set; }
/// <summary>
/// id - song ID in the database (for original URL link back construction)
/// </summary>
public string SongID { get; set; }
/// <summary>
/// ar - artist name
/// </summary>
public string ArtistName { get; set; }
/// <summary>
/// tt - title of the song
/// </summary>
public string Title { get; set; }
/// <summary>
/// al - album name
/// </summary>
public string AlbumName { get; set; }
/// <summary>
/// tx - lyrics text separated by [br] for line break
/// </summary>
public string Text { get; set; }
}
}

View file

@ -191,7 +191,6 @@
<Compile Include="Controls\AccountsControl.Designer.cs">
<DependentUpon>AccountsControl.cs</DependentUpon>
</Compile>
<Compile Include="OtherServices\GoogleTranslatorConfig.cs" />
<Compile Include="Forms\DropboxFilesForm.cs">
<SubType>Form</SubType>
</Compile>
@ -258,8 +257,6 @@
<Compile Include="ImageUploaders\YfrogUploader.cs" />
<Compile Include="FileUploaders\Localhost\LocalhostAccount.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="OtherServices\GoogleTranslate.cs" />
<Compile Include="OtherServices\Lyricsfly.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>