public static string GetContentId(string torrentData) { string response = HTTPUtility.PostRequest("http://api.torrentstream.net/upload/raw", Encoding.UTF8.GetBytes(torrentData)); var content = JsonConvert.DeserializeObject <TorrentId>(response); if (string.IsNullOrEmpty(content.Error)) { return(content.ContentID); } return(response); }
public string CurlRequest(string text) { string result; if (text.StartsWith("curlorig")) { Log.LogDebug("curlorig " + text.Substring(9)); result = HTTPUtility.GetRequest(text.Substring(9)); } else { bool verbose = text.IndexOf(" -i", StringComparison.Ordinal) > 0; bool autoredirect = text.IndexOf(" -L", StringComparison.Ordinal) > 0; string url = Regex.Match(text, "(?:\")(.*?)(?=\")").Groups[1].Value; var matches = Regex.Matches(text, "(?:-H\\s\")(.*?)(?=\")"); var header = ( from Match match in matches select match.Groups into groups where groups.Count > 1 select groups[1].Value into value where value.Contains(": ") select value).ToDictionary(value => value.Remove(value.IndexOf(": ", StringComparison.Ordinal)), value => value.Substring(value.IndexOf(": ", StringComparison.Ordinal) + 2)); if (text.Contains("--data")) { Log.LogDebug("POST DATA"); try { string dataString = Regex.Match(text, "(?:--data\\s\")(.*?)(?=\")").Groups[1].Value; result = HTTPUtility.PostRequest(url, dataString, header, verbose, autoredirect); } catch (Exception e) { result = e.ToString(); Log.LogDebug(e.ToString()); } } else { Log.LogInformation(url); result = HTTPUtility.GetRequest(url, header, verbose, autoredirect); } } return(result); }