From 3e4e3c27bf2f88620c8eb442de08a91644dc0302 Mon Sep 17 00:00:00 2001 From: Jaex Date: Thu, 11 Dec 2014 05:15:21 +0200 Subject: [PATCH] Removing outdated classes --- .../OtherServices/GoogleTranslate.cs | 139 ------------- .../OtherServices/GoogleTranslatorConfig.cs | 43 ---- .../OtherServices/Lyricsfly.cs | 191 ------------------ .../ShareX.UploadersLib.csproj | 3 - 4 files changed, 376 deletions(-) delete mode 100644 ShareX.UploadersLib/OtherServices/GoogleTranslate.cs delete mode 100644 ShareX.UploadersLib/OtherServices/GoogleTranslatorConfig.cs delete mode 100644 ShareX.UploadersLib/OtherServices/Lyricsfly.cs diff --git a/ShareX.UploadersLib/OtherServices/GoogleTranslate.cs b/ShareX.UploadersLib/OtherServices/GoogleTranslate.cs deleted file mode 100644 index e7b21f7c0..000000000 --- a/ShareX.UploadersLib/OtherServices/GoogleTranslate.cs +++ /dev/null @@ -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 . -*/ - -#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 GetLanguages() - { - string url = APIURL + "/languages"; - - Dictionary args = new Dictionary(); - 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 args = new Dictionary(); - 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; - } - } -} \ No newline at end of file diff --git a/ShareX.UploadersLib/OtherServices/GoogleTranslatorConfig.cs b/ShareX.UploadersLib/OtherServices/GoogleTranslatorConfig.cs deleted file mode 100644 index 7b38206c9..000000000 --- a/ShareX.UploadersLib/OtherServices/GoogleTranslatorConfig.cs +++ /dev/null @@ -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 . -*/ - -#endregion License Information (GPL v3) - -using ShareX.HelpersLib; -using ShareX.UploadersLib.OtherServices; -using System.Collections.Generic; - -namespace ShareX.UploadersLib -{ - public class GoogleTranslatorConfig : SettingsBase - { - public string APIKey = ""; - public List GoogleLanguages; - public string GoogleSourceLanguage = "en"; - public bool GoogleAutoDetectSource = true; - public string GoogleTargetLanguage = "en"; - public string GoogleTargetLanguage2 = "?"; - public bool AutoTranslate = false; - public int AutoTranslateLength = 20; - } -} \ No newline at end of file diff --git a/ShareX.UploadersLib/OtherServices/Lyricsfly.cs b/ShareX.UploadersLib/OtherServices/Lyricsfly.cs deleted file mode 100644 index bcf6cd87c..000000000 --- a/ShareX.UploadersLib/OtherServices/Lyricsfly.cs +++ /dev/null @@ -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 . -*/ - -#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; - } - - /// - /// To search by artist and title combination - /// - public Lyrics SearchLyrics(string artist, string title) - { - Dictionary arguments = new Dictionary(); - 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); - } - - /// - /// To search by lyrics text string - /// - public Lyrics SearchLyrics(string text) - { - Dictionary arguments = new Dictionary(); - 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); - } - - /// - /// Function to edit lyrics (incomplete) - /// - /// - public void EditLyrics(Lyrics lyrics) - { - Dictionary arguments = new Dictionary(); - 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 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; - } - - /// - /// 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. - /// - 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 - { - /// - /// cs - checksum (for original URL link back construction) - /// - public string Checksum { get; set; } - - /// - /// id - song ID in the database (for original URL link back construction) - /// - public string SongID { get; set; } - - /// - /// ar - artist name - /// - public string ArtistName { get; set; } - - /// - /// tt - title of the song - /// - public string Title { get; set; } - - /// - /// al - album name - /// - public string AlbumName { get; set; } - - /// - /// tx - lyrics text separated by [br] for line break - /// - public string Text { get; set; } - } -} \ No newline at end of file diff --git a/ShareX.UploadersLib/ShareX.UploadersLib.csproj b/ShareX.UploadersLib/ShareX.UploadersLib.csproj index 311af7e8f..7feda5150 100644 --- a/ShareX.UploadersLib/ShareX.UploadersLib.csproj +++ b/ShareX.UploadersLib/ShareX.UploadersLib.csproj @@ -191,7 +191,6 @@ AccountsControl.cs - Form @@ -258,8 +257,6 @@ - - True True