From a7d0664b67736b4c68f06c4ec0637b7e4e65a700 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Fri, 10 Feb 2017 22:54:08 +0100 Subject: [PATCH] Remove RapidShare --- .../FileUploaders/RapidShare.cs | 237 ------------------ .../ShareX.UploadersLib.csproj | 1 - 2 files changed, 238 deletions(-) delete mode 100644 ShareX.UploadersLib/FileUploaders/RapidShare.cs diff --git a/ShareX.UploadersLib/FileUploaders/RapidShare.cs b/ShareX.UploadersLib/FileUploaders/RapidShare.cs deleted file mode 100644 index 9e59a6112..000000000 --- a/ShareX.UploadersLib/FileUploaders/RapidShare.cs +++ /dev/null @@ -1,237 +0,0 @@ -#region License Information (GPL v3) - -/* - ShareX - A program that allows you to take screenshots and share any file type - Copyright (c) 2007-2017 ShareX Team - - 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 System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace ShareX.UploadersLib.FileUploaders -{ - public sealed class RapidShare : FileUploader - { - private const string rapidshareURL = "https://api.rapidshare.com/cgi-bin/rsapi.cgi"; - private const string rapidshareUploadURL = "https://rs{0}.rapidshare.com/cgi-bin/rsapi.cgi"; - - public string Username { get; set; } - - public string Password { get; set; } - - public string FolderID { get; set; } - - public RapidShare(string username, string password, string folderID = null) - { - Username = username; - Password = password; - FolderID = folderID; - } - - public override UploadResult Upload(Stream stream, string fileName) - { - if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)) - { - Errors.Add("RapidShare account username or password is empty."); - return null; - } - - string url = NextUploadServer(); - - if (string.IsNullOrEmpty(url)) - { - Errors.Add("RapidShare next upload server URL is empty."); - return null; - } - - Dictionary args = new Dictionary(); - args.Add("sub", "upload"); - args.Add("login", Username); - args.Add("password", Password); - - if (!string.IsNullOrEmpty(FolderID)) - { - args.Add("folder", FolderID); - } - - UploadResult result = SendRequestFile(url, stream, fileName, "filecontent", args); - - if (result.IsSuccess) - { - if (result.Response.StartsWith("ERROR: ")) - { - Errors.Add(result.Response.Substring(7)); - } - else if (result.Response.StartsWith("COMPLETE\n")) - { - RapidShareUploadInfo info = new RapidShareUploadInfo(result.Response); - result.URL = info.URL; - } - } - - return result; - } - - private string NextUploadServer() - { - Dictionary args = new Dictionary(); - args.Add("sub", "nextuploadserver"); - - string response = SendRequest(HttpMethod.GET, rapidshareURL, args); - - if (!string.IsNullOrEmpty(response)) - { - return string.Format(rapidshareUploadURL, response); - } - - return ""; - } - - public RapidShareFolderInfo GetRootFolderWithChilds() - { - Dictionary args = new Dictionary(); - args.Add("sub", "listrealfolders"); - args.Add("login", Username); - args.Add("password", Password); - - string response = SendRequest(HttpMethod.GET, rapidshareURL, args); - - return RapidShareFolderInfo.GetRootFolderWithChilds(response); - } - } - - public class RapidShareUploadInfo - { - public string FileID { get; private set; } - - public string FileName { get; private set; } - - public string FileSize { get; private set; } - - public string MD5 { get; private set; } - - public string URL - { - get - { - if (!string.IsNullOrEmpty(FileID) && !string.IsNullOrEmpty(FileName)) - { - return string.Format("https://rapidshare.com/files/{0}/{1}", FileID, FileName); - } - - return null; - } - } - - public RapidShareUploadInfo(string response) - { - string[] split = response.Substring(9).Trim('\n').Split(','); - - if (split.Length > 3) - { - FileID = split[0]; - FileName = split[1]; - FileSize = split[2]; - MD5 = split[3]; - } - } - } - - public class RapidShareFolderInfo - { - public string RealFolderID { get; private set; } - - public string ParentRealFolderID { get; private set; } - - public string FolderName { get; private set; } - - public string BrowseACL { get; private set; } - - public string UploadACL { get; private set; } - - public string DownloadACL { get; private set; } - - public List ChildFolders = new List(); - - public RapidShareFolderInfo(string id, string name) - { - RealFolderID = id; - FolderName = name; - } - - public RapidShareFolderInfo(string response) - { - string[] split = response.Split(','); - - if (split.Length > 5) - { - RealFolderID = split[0]; - ParentRealFolderID = split[1]; - FolderName = split[2]; - BrowseACL = split[3]; - UploadACL = split[4]; - DownloadACL = split[5]; - } - } - - public static List GetFolderInfos(string response) - { - List list = new List(); - - if (!string.IsNullOrEmpty(response) && response != "NONE") - { - string[] split = response.Trim('\n').Split('\n'); - - list.AddRange(split.Select(folderInfo => new RapidShareFolderInfo(folderInfo))); - } - - return list; - } - - public static RapidShareFolderInfo GetRootFolderWithChilds(string response) - { - RapidShareFolderInfo root = new RapidShareFolderInfo("0", "root"); - - List list = GetFolderInfos(response); - list.Add(root); - - foreach (RapidShareFolderInfo folderInfo in list) - { - if (folderInfo.RealFolderID != "0") - { - foreach (RapidShareFolderInfo folderInfo2 in list) - { - if (folderInfo.ParentRealFolderID == folderInfo2.RealFolderID) - { - folderInfo2.ChildFolders.Add(folderInfo); - folderInfo2.ChildFolders = folderInfo2.ChildFolders.OrderBy(x => x.FolderName).ToList(); - } - } - } - } - - root.ChildFolders = root.ChildFolders.OrderBy(x => x.FolderName).ToList(); - - return root; - } - } -} \ No newline at end of file diff --git a/ShareX.UploadersLib/ShareX.UploadersLib.csproj b/ShareX.UploadersLib/ShareX.UploadersLib.csproj index 287a5d7f6..65355e067 100644 --- a/ShareX.UploadersLib/ShareX.UploadersLib.csproj +++ b/ShareX.UploadersLib/ShareX.UploadersLib.csproj @@ -277,7 +277,6 @@ -