private Item[] GetSeriesListRequest(IPluginContext context, string url) { List <Item> items = new List <Item>(); var header = new Dictionary <string, string>() { { "Accept-Encoding", "gzip, deflate, lzma" }, { "Content-Type", "text/html; charset=UTF-8" } }; context.ConsoleLog("url=" + string.Format(SITE_URL, url.Replace("transСтандартный", "trans"))); string response = context.GetHttpClient().GetRequest(string.Format(SITE_URL, url.Replace("transСтандартный", "trans")), header); var matches = Regex.Matches(response, "({)([\\s\\S]*?)(\"comment\"\\s*:\\s*\")(.+?)(\",)([\\s\\S]*?)(\"streamsend\"\\s*:\\s*\")(.+?)(\",)([\\s\\S]*?)(\"galabel\"\\s*:\\s*\")(.+?)(\",)([\\s\\S]*?)(\"file\"\\s*:\\s*\")(.+?)(\")([\\s\\S]*?)(})", RegexOptions.Multiline); var match = Regex.Match(url, "(\\/)(\\d+)(\\/list.xml)"); Item Item = GetSerialInfoRequest(match.Groups[2].Value); for (int i = 0; i < matches.Count; i++) { var item = new Item() { Name = matches[i].Groups[4].Value.Replace("<br>", " "), Link = matches[i].Groups[16].Value, Type = ItemType.FILE, ImageLink = Item.ImageLink, Description = Item.Description }; items.Add(item); } return(items.ToArray()); }
// Item представляет собой класс, содержащащий следующие поля: //// Name - навзание //// Link - ссылка (если директория, то ссылка передается на обработку плагину, если файл, то ссылка открывается в проигрывателе) //// ImageLink - иконка //// Description - описание, поддерживает HTML формат //// Type - тип сущности: ItemType.FILE или ItemType.DIRECTORY (по умолчанию) // Главный метод для обработки запросов public Playlist GetList(IPluginContext context) { var path = context.GetRequestParams().Get(PLUGIN_PATH); path = path == null ? "plugin" : "plugin;" + path; context.ConsoleLog("path=" + path); // SEPARATOR служит для разделения команд при парсинге (char) var arg = path.Split(SEPARATOR); List <Item> items = new List <Item>(); switch (arg.Length) { case 0: break; case 1: items.AddRange(GetRootListRequest()); break; default: string lang = arg[1]; string sort = string.Empty; string page = string.Empty; switch (arg[1]) { case "eng": { if (arg.Length > 2) { sort = arg[2]; } if (arg.Length > 3) { page = arg[3]; } items.AddRange(GetFilteringListRequest(context, lang, sort, page)); } break; case "rus": { if (arg.Length > 2) { sort = arg[2]; } if (arg.Length > 3) { page = arg[3]; } items.AddRange(GetFilteringListRequest(context, lang, sort, page)); } break; case "series": items.AddRange(GetSeriesListRequest(context, arg[2])); break; case "list": items.AddRange(GetSerialListRequest(context, arg[2])); break; case "voise": items.AddRange(GetVoiseListRequest(context, arg[2])); break; case "update": ClearList(); break; case "search": items.AddRange(SearchItem(context, context.GetRequestParams()["search"])); break; } break; } var playlist = new Playlist(); foreach (var item in items) { if (ItemType.DIRECTORY == item.Type) { var pluginParams = new NameValueCollection(); pluginParams[PLUGIN_PATH] = item.Link; item.Link = context.CreatePluginUrl(pluginParams); } } playlist.Items = items.ToArray(); return(playlist); }
private Item[] GetVoiseListRequest(IPluginContext context, string url) { List <Item> items = new List <Item>(); var header = new Dictionary <string, string>() { { "Accept-Encoding", "gzip, deflate, lzma" }, { "Content-Type", "text/html; charset=UTF-8" } }; context.ConsoleLog("url=" + string.Format(SITE_URL, url)); string response = context.GetHttpClient().GetRequest(string.Format(SITE_URL, url), header).Replace("\n", " "); // context.ConsoleLog("response=" + response.Substring(0, 1000)); var match = Regex.Match(response, "'(secureMark)': '(.*?)'.*?'time': (\\d+)"); if (match.Success) { string secure = match.Groups[2].Value; string time = match.Groups[3].Value; context.ConsoleLog("secure=" + secure); context.ConsoleLog("time=" + time); match = Regex.Match(response, "data-id-serial=\"(.*?)\""); if (match.Success) { string serialId = match.Groups[1].Value; context.ConsoleLog("serialId=" + serialId); match = Regex.Match(response, "data-id-season=\"(.*?)\""); if (match.Success) { string seasonId = match.Groups[1].Value; context.ConsoleLog("seasonId=" + seasonId); Item Item = GetSerialInfoRequest(seasonId, response); var data = new Dictionary <string, string>() { { "type", "html5" }, { "id", seasonId }, { "serial", serialId }, { "secure", secure }, { "time", time } }; header = new Dictionary <string, string>() { { "X-Requested-With", "XMLHttpRequest" }, { "Accept-Encoding", "gzip, deflate, lzma" }, { "Content-Type", "text/html; charset=UTF-8" } }; string datastring = ""; foreach (var k in data) { if (datastring != "") { datastring += "&"; } datastring += System.Net.WebUtility.UrlEncode(k.Key) + "=" + System.Net.WebUtility.UrlEncode(k.Value); } context.ConsoleLog(string.Format(SITE_URL, "/player.php") + " datastring=" + datastring); response = context.GetHttpClient().PostRequest(string.Format(SITE_URL, "/player.php"), datastring, header).Replace("\n", ""); //context.ConsoleLog("response=" + response.Substring(0, 1000)); var matches0 = Regex.Matches(response, " pl = {'0': \"(.*?)\""); var matches = Regex.Matches(response, "data-translate=\"([^0].*?)\">(.*?)</li.{1,30}>pl\\[.*?\"(.*?)\""); context.ConsoleLog("matches0=" + matches0.Count); context.ConsoleLog("matches=" + matches.Count); if (matches0.Count == 1 && matches.Count < 2) { return(GetSeriesListRequest(context, matches0[0].Groups[1].Value)); } else { if (matches0.Count > 0) { var item = new Item() { Name = "Стандартный", Link = string.Format("{1}{0}{2}", SEPARATOR, "series", Uri.UnescapeDataString(matches0[0].Groups[1].Value)), ImageLink = Item.ImageLink, Description = Item.Description }; items.Add(item); } for (int i = 0; i < matches.Count; i++) { var item = new Item() { Name = matches[i].Groups[2].Value.Trim(), Link = string.Format("{1}{0}{2}", SEPARATOR, "series", Uri.UnescapeDataString(matches[i].Groups[3].Value)), ImageLink = Item.ImageLink, Description = Item.Description }; items.Add(item); } } } } } return(items.ToArray()); }
private Item[] GetFilteringListRequest(IPluginContext context, string lang, string sort, string page) { List <Item> items = new List <Item>(); if (sort == "first") { if (!serialMatches.ContainsKey(lang + "name")) { GetFilteringListRequest(context, lang, "name", page); } if (serialMatches.ContainsKey(lang + "name")) { items.AddRange(FirstSymbolGroup(lang, sort, page)); return(items.ToArray()); } else { sort = "name"; } } else if (!string.IsNullOrEmpty(page)) { if (serialMatches.ContainsKey(lang + sort)) { items.AddRange(NextPage(lang, sort, page)); return(items.ToArray()); } } if (string.IsNullOrEmpty(sort)) { sort = "view"; var item = new Item() { Name = "По популярности", Link = string.Format("{1}{0}{2}", SEPARATOR, lang, "view") }; items.Add(item); item = new Item() { Name = "По названию", Link = string.Format("{1}{0}{2}", SEPARATOR, lang, "name") }; items.Add(item); item = new Item() { Name = "По году", Link = string.Format("{1}{0}{2}", SEPARATOR, lang, "god") }; items.Add(item); item = new Item() { Name = "По добавлению", Link = string.Format("{1}{0}{2}", SEPARATOR, lang, "newest") }; items.Add(item); item = new Item() { Name = "По первому символу", Link = string.Format("{1}{0}{2}", SEPARATOR, lang, "first") }; items.Add(item); } List <Match> tempSerials; if (serialMatches.ContainsKey(lang + sort)) { tempSerials = serialMatches[lang + sort]; } else { var data = new Dictionary <string, string>() { { "filter[only]", lang }, { "filter[rait]", "kp" }, { "filter[sortTo][]", sort }, { "filter[block]", "yes" }, }; var header = new Dictionary <string, string>() { { "Accept-Encoding", "gzip, deflate, lzma" }, { "Content-Type", "text/html; charset=UTF-8" } }; string datastring = ""; foreach (var k in data) { if (datastring != "") { datastring += "&"; } datastring += System.Net.WebUtility.UrlEncode(k.Key) + "=" + System.Net.WebUtility.UrlEncode(k.Value); } string response = context.GetHttpClient().PostRequest(string.Format(SITE_URL, "/index.php"), datastring, header).Replace("\n", " "); context.ConsoleLog(string.Format(SITE_URL, "/index.php") + " datastring=" + datastring); //context.ConsoleLog("response=" + response.Substring(0,400)); tempSerials = Regex.Matches(response, "<a data-id=\"(.*?)\".*?href=\"(.*?)\".*?>(.*?)<", RegexOptions.Multiline) .Cast <Match>() .ToList(); context.ConsoleLog("tempSerials.Count=" + tempSerials.Count); if (tempSerials.Count > 0) { serialMatches.Add((lang + sort), tempSerials); } } if (tempSerials != null) { for (int i = 0; i < Math.Min(50, tempSerials.Count); i++) { var item = GetSerialInfoRequest(tempSerials[i].Groups[1].Value); item.Name = tempSerials[i].Groups[3].Value.Trim(); item.Link = string.Format("{1}{0}{2}", SEPARATOR, "list", tempSerials[i].Groups[2]); items.Add(item); } if (tempSerials.Count > 50) { var item = new Item() { Name = "СТРАНИЦА 2", Link = string.Format("{1}{0}{2}{0}{3}", SEPARATOR, lang, sort, 50), ImageLink = NEXT_PAGE_IMAGE_URL }; items.Add(item); } } return(items.ToArray()); }