Example #1
0
        private Item[] GetSerialListRequest(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" }
            };

            string response = context.GetHttpClient().GetRequest(string.Format(SITE_URL, url), header);

            var matches = Regex.Matches(response,
                                        "(<h2>[.\\s^&]*?<a href=\")((\\S*?)(\\/serial-(\\d+))(\\S*?))(\">[\\s>]*?Сериал)(.+?)(\\s*?(<span>|<\\/a>))",
                                        RegexOptions.Multiline);

            if (matches.Count == 1)
            {
                return(GetVoiseListRequest(context, url));
            }
            else
            {
                for (int i = 0; i < matches.Count; i++)
                {
                    Item item = GetSerialInfoRequest(matches[i].Groups[5].Value);
                    item.Name = matches[i].Groups[8].Value.Trim();
                    item.Link = string.Format("{1}{0}{2}", SEPARATOR, "voise", matches[i].Groups[2].Value);

                    items.Add(item);
                }
            }

            return(items.ToArray());
        }
Example #2
0
        private Item[] SearchItem(IPluginContext context, string words)
        {
            List <Item> items = new List <Item>();

            var header = new Dictionary <string, string>()
            {
                { "Accept-Encoding", "gzip, deflate, lzma" },
                { "Content-Type", "text/html; charset=UTF-8" }
            };

            string response = context.GetHttpClient().GetRequest(string.Format(SITE_SEARCH_URL, words), header);

            // remove new lines tabs and double spaces
            response = Regex.Replace(response, "([\\n|\\t|\\r]+|\\ {2,})", String.Empty, RegexOptions.Multiline);

            // get only search results
            string html    = String.Empty;
            var    matches = Regex.Matches(response, "pgs-search-info\">(.+?(?=<\\/p)<\\/p>)", RegexOptions.Multiline);

            for (int i = 0; i < matches.Count; i++)
            {
                html += matches[i].Groups[0].Value;
            }

            // remove all HTML tags except <a> and <p>
            html = Regex.Replace(
                html,
                "</?(?(?=a|p)notag|[a-zA-Z0-9]+)(?:\\s[a-zA-Z0-9\\-]+=?(?:([\"\",']?).*?\\1?)?)*\\s*/?>",
                String.Empty,
                RegexOptions.Multiline
                );

            // parse results
            matches = Regex.Matches(
                html,
                "pgs-search-info.+?(?=serial)(serial-(\\d+)-[^\"]+)\">(.+?(?=<\\/)).+?(?=<p>)<p>([^<\\/]+)",
                RegexOptions.Multiline
                );

            for (int i = 0; i < matches.Count; i++)
            {
                Item item = GetSerialInfoRequest(matches[i].Groups[2].Value);
                item.Name        = matches[i].Groups[3].Value;
                item.Link        = string.Format("{1}{0}{2}", SEPARATOR, "list", "/" + matches[i].Groups[1].Value);
                item.Description = string.Format(
                    "<img src=\"{0}\" alt=\"\" align=\"left\"/><h3>{1}</h3><p style=\"padding-left:10px;\">{2}</p>",
                    string.Format(IMAGE_URL, matches[i].Groups[2].Value),
                    matches[i].Groups[3].Value,
                    matches[i].Groups[4].Value
                    );

                items.Add(item);
            }

            return(items.ToArray());
        }
Example #3
0
        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());
        }
Example #4
0
        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());
        }
Example #5
0
        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());
        }