private List <Item> GetItems(byte[] data, ref string source) { var items = new List <Item>(); string contentId = FileList.GetContentId(data); var files = FileList.GetFileList(contentId, "content_id"); if (files.Count > 0) { string stream = string.Format("{0}/ace/getstream?{1}={2}", AceStreamEngine.GetServer, "content_id", contentId); if (files.Count > 1) { source = HTTPUtility.GetRequest(stream); } else { string name = Path.GetFileName(files.First().Value); var item = new Item() { Name = Path.GetFileName(name), Link = stream, Type = ItemType.FILE }; items.Add(item); } } return(items); }
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); }
public static Dictionary <string, string> GetFileList(string key, string type) { string aceMadiaInfo = HTTPUtility.GetRequest(string.Format("{0}/server/api?method=get_media_files&{1}={2}", AceStreamEngine.GetServer, type, key)); if (!string.IsNullOrWhiteSpace(aceMadiaInfo)) { var files = JsonConvert.DeserializeObject <TorrentFile>(aceMadiaInfo); if (string.IsNullOrEmpty(files.Error)) { return(files.Result); } } return(new Dictionary <string, string>()); }
public string GetFileList(Dictionary <string, string> files, string key, string type) { var items = new List <Item>(); if (files.Count > 0) { if (files.Count > 1) { string stream = string.Format("{0}/ace/getstream?{1}={2}", AceStreamEngine.GetServer, type, key); return(HTTPUtility.GetRequest(stream)); } else { string stream = string.Format("{0}/ace/getstream?{1}={2}", AceStreamEngine.GetServer, type, key); string name = Path.GetFileName(files.First().Value); var item = new Item() { Name = Path.GetFileName(name), ImageLink = "http://obovse.ru/ForkPlayer2.5/img/file.png", Link = stream, Type = ItemType.FILE }; items.Add(item); stream = string.Format("{0}/ace/manifest.m3u8?{1}={2}", AceStreamEngine.GetServer, type, key); item = new Item() { Name = "(hls) " + Path.GetFileName(name), ImageLink = "http://obovse.ru/ForkPlayer2.5/img/file.png", Link = stream, Type = ItemType.FILE }; items.Add(item); } } var playlist = new Playlist { Items = items.ToArray(), IsIptv = "false" }; return(ResponseSerializer.PlaylistToXml(playlist)); }
private void ServerRegistration() { var task = new Task(() => { ; //toolStripStatusLabel1.Text = $"{Resources.Main_ServerRegistration}..."; string url = $"http://getlist2.obovse.ru/remote/index.php?v={Assembly.GetExecutingAssembly().GetName().Version}&do=list&localip={ip}:{port}&proxy=false"; string result = HTTPUtility.GetRequest(url); Log.LogInformation(result); //if (result.Split('|')[0] == "new_version") { // if (mcbCheckUpdate.Checked) { // MenuItemNewVersion.Text = result.Split('|')[1]; // MenuItemNewVersion.Visible = true; // urlnewversion = result.Split('|')[2]; // newversion = result.Split('|')[3]; // } //} //timerR.Enabled = mcbUseProxy.Checked; //toolStripStatusLabel1.Text = $"{Resources.Main_ServerRegistration}: OK"; //Log.Debug("StartServer->Result: {0}", result); }); task.Start(); }
public override string Handle(HttpRequest request, HttpResponse response) { string result = string.Empty; Log.LogDebug(request.Host.ToUriComponent()); var requestStrings = HttpUtility.UrlDecode(request.QueryString.Value)?.Substring(1).Split('|'); if (request.Method == "POST") { var getPostParam = new StreamReader(request.Body, true); string postData = getPostParam.ReadToEnd(); requestStrings = HttpUtility.UrlDecode(postData).Substring(2).Split('|'); } if (requestStrings != null) { Log.LogDebug("Parsing: {0}", requestStrings[0]); string curlResponse = requestStrings[0].StartsWith("curl") ? CurlRequest(requestStrings[0]) : HTTPUtility.GetRequest(requestStrings[0]); if (requestStrings.Length == 1) { result = curlResponse; } else { if (!requestStrings[1].Contains(".*?")) { if (string.IsNullOrEmpty(requestStrings[1]) && string.IsNullOrEmpty(requestStrings[2])) { result = curlResponse; } else { int num1 = curlResponse.IndexOf(requestStrings[1], StringComparison.Ordinal); if (num1 == -1) { result = string.Empty; } else { num1 += requestStrings[1].Length; int num2 = curlResponse.IndexOf(requestStrings[2], num1, StringComparison.Ordinal); result = num2 == -1 ? string.Empty : curlResponse.Substring(num1, num2 - num1); } } } else { Log.LogDebug("ParseLinkRequest: {0}", requestStrings[1] + "(.*?)" + requestStrings[2]); string pattern = requestStrings[1] + "(.*?)" + requestStrings[2]; var regex = new Regex(pattern, RegexOptions.Multiline); var match = regex.Match(curlResponse); if (match.Success) { result = match.Groups[1].Captures[0].ToString(); } } } } return(result); }