public Episode[] SearchForEpisode(string url)
        {
            var episodes = new List <Episode>();

            var doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(HtmlUtils.GetHtmlPage(Utils.Combine(Info().SiteUrl, url)));
            }
            catch (Exception ex)
            {
                LogManager.GetCurrentClassLogger().Error(ex, "Ошибка при получении страницы");
            }

            var nodes = doc.DocumentNode.SelectNodes($"//div[contains(@class,'episodes-slick_item')]");

            if (nodes != null && nodes.Count > 0)
            {
                GetMultipleSeries(nodes, ref episodes);
            }
            else
            {
                var node = doc.DocumentNode.SelectSingleNode("//div[@class='episode_info']/a[not(contains(@href,'#'))]");
                if (node != null)
                {
                    GetSingleSeries(node, ref episodes);
                }
            }

            return(episodes.ToArray());
        }
        public Series[] SearchForSeries(string name)
        {
            var series = new List <Series>();

            var doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(
                    HtmlUtils.GetHtmlPage(Utils.Combine(Info().SiteUrl, $"/index.php?do=search"),
                                          formData: new[] {
Example #3
0
        public Series[] SearchForSeries(string name)
        {
            var series = new List <Series>();

            var doc  = new HtmlDocument();
            var test = Info().SiteUrl;

            try
            {
                doc.LoadHtml(
                    HtmlUtils.GetHtmlPage(
                        Info().SiteUrl,
                        formData: new [] {
        public Series[] SearchForSeries(string name)
        {
            var series = new List <Series>();

            var doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(HtmlUtils.GetHtmlPage($"https://sovetromantica.com/anime?query={name}"));
            }
            catch (Exception ex)
            {
                LogManager.GetCurrentClassLogger().Error(ex, "Ошибка при получении страницы");
            }

            var nodes = doc.DocumentNode.SelectNodes($"//div[@class='anime--block__desu']");

            if (nodes == null || nodes.Count == 0)
            {
                return(series.ToArray());
            }

            foreach (var node in nodes)
            {
                try
                {
                    var linkNode = node.SelectSingleNode(".//div/a");
                    var link     = linkNode.Attributes["href"].Value;

                    var imageUrl = Regex.Match(node.InnerHtml, "content=\"(https.+?)\"").Groups[1].Value;

                    var titleNode = node.SelectSingleNode(".//div/div[@class='anime--block__name']/span[2]");
                    var title     = titleNode.InnerText;

                    series.Add(new Series()
                    {
                        Name      = title,
                        SeriesUrl = link,
                        ImageUrl  = imageUrl
                    });
                }
                catch (Exception ex)
                {
                    LogManager.GetCurrentClassLogger().Error(ex, "Ошибка при парсинге сериала");
                }
            }

            return(series.ToArray());
        }
        private KansaiStudioProvider()
        {
            var pageNumber = 1;

            while (true)
            {
                var doc = new HtmlDocument();
                doc.LoadHtml(HtmlUtils.GetHtmlPage("https://kansai.studio/" + pageNumber));

                var movieNodes = doc.DocumentNode.SelectNodes("//div[contains(@class, 'flatpost__container')]");
                if (movieNodes == null)
                {
                    break;
                }

                foreach (var movieNode in movieNodes)
                {
                    try
                    {
                        var image       = movieNode.SelectSingleNode(".//div[contains(@class, 'flatpost__image')]").Attributes["style"].Value;
                        var imageUrl    = Regex.Match(image, "background-image:url\\('(.+)'\\);").Groups[1].Value;
                        var titleNode   = movieNode.SelectSingleNode(".//a[contains(@class, 'flatpost__title')]");
                        var title       = titleNode.InnerText.Split('[')[0].TrimEnd(' ');
                        var link        = "https://kansai.studio" + titleNode.Attributes["href"].Value;
                        var description = movieNode.SelectSingleNode(".//div[contains(@class, 'flatpost__description')]").InnerText;

                        _series.Add(new Series()
                        {
                            Name        = title,
                            SeriesUrl   = link,
                            ImageUrl    = imageUrl,
                            Description = description
                        });
                    }
                    catch (Exception ex)
                    {
                        LogManager.GetCurrentClassLogger().Error(ex, "Ошибка при парсинге сериала");
                    }
                }

                pageNumber++;
            }
        }
        public Episode[] SearchForEpisode(string url)
        {
            var episodes = new List <Episode>();

            try
            {
                var htmlPage        = HtmlUtils.GetHtmlPage(url);
                var javascriptBlock = Regex.Match(htmlPage, "\"series\":\\[([^\\]]+)\\]")?.Groups[1].Value;
                javascriptBlock = Regex.Replace(javascriptBlock, "\"(\\d+)\"", m => $"\"res{m.Groups[1].Value}\"");

                dynamic jsonResponse = JsonConvert.DeserializeObject($"{{\"seria\":[{javascriptBlock}]}}");
                foreach (var seria in jsonResponse.seria)
                {
                    if (!string.IsNullOrWhiteSpace(seria.links.res720?.ToString()))
                    {
                        episodes.Add(new Episode()
                        {
                            Name         = $"Серия {seria.number} (720)",
                            MovieUrl     = seria.links.res720,
                            IsDirectLink = true
                        });
                    }
                    if (!string.IsNullOrWhiteSpace(seria.links.res1080?.ToString()))
                    {
                        episodes.Add(new Episode()
                        {
                            Name         = $"Серия {seria.number} (1080)",
                            MovieUrl     = seria.links.res1080,
                            IsDirectLink = true
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.GetCurrentClassLogger().Error(ex);
            }

            return(episodes.ToArray());
        }
        public Series[] SearchForSeries(string name)
        {
            var series = new List <Series>();

            var     json    = HtmlUtils.GetHtmlPage(Utils.Combine(Info().SiteUrl, $"/ajax/url_s/search&keywords={name}"));
            dynamic jsonObj = JsonConvert.DeserializeObject(json);

            foreach (var item in jsonObj.items)
            {
                if (item.language == "Аниме онлайн")
                {
                    string title    = item.name;
                    string link     = item.html_url;
                    string imageUrl = item.image;

                    if (link.StartsWith("//"))
                    {
                        link = "http:" + link;
                    }

                    series.Add(new Series()
                    {
                        Name      = title,
                        SeriesUrl = link,
                        ImageUrl  = imageUrl
                    });
                }
            }

            #region Temporary broken full search

            /*
             * var doc = new HtmlDocument();
             * try
             * {
             *  doc.LoadHtml(HtmlUtils.GetHtmlPage(Utils.Combine(Info().SiteUrl, $"/ajax/search_result_search_page/P0?keywords={name}")));
             * }
             * catch (Exception ex)
             * {
             *  LogManager.GetCurrentClassLogger().Error(ex, $"Ошибка при получении страницы {name}");
             * }
             *
             * var nodes = doc.DocumentNode.SelectNodes("//div[@class='ads-list__item']");
             * if (nodes != null && nodes.Count > 0)
             * {
             *  foreach(var node in nodes)
             *  {
             *      try
             *      {
             *          var titleNode = node.SelectSingleNode("./a[contains(@class,'ads-list__item__title')]");
             *          var title = titleNode.InnerText;
             *          var link = titleNode.Attributes["href"].Value;
             *
             *          var imageNode = node.SelectSingleNode("./div/a/img");
             *          var imageUrl = imageNode.Attributes["data-src"].Value;
             *
             *          series.Add(new Series()
             *          {
             *              Name = title,
             *              SeriesUrl = link,
             *              ImageUrl = imageUrl
             *          });
             *
             *      }
             *      catch (Exception ex)
             *      {
             *          LogManager.GetCurrentClassLogger().Error(ex, "Ошибка парсинга сериала");
             *      }
             *  }
             * }
             */
            #endregion

            return(series.ToArray());
        }
        public Episode[] SearchForEpisode(string url)
        {
            var episodes = new List <Episode>();

            var doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(HtmlUtils.GetHtmlPage(url));
            }
            catch (Exception ex)
            {
                LogManager.GetCurrentClassLogger().Error(ex, $"Ошибка при получении страницы {url}");
            }

            int seriesId = 0, playlistId = 0;

            // Episode Id - //ul[@role='tablist'] - @data-entry_id
            var seriesIdNode = doc.DocumentNode.SelectSingleNode("//ul[@role='tablist']");

            if (seriesIdNode == null)
            {
                return(episodes.ToArray());
            }
            else
            {
                seriesId = int.Parse(seriesIdNode.Attributes["data-entry_id"].Value);
            }

            // Playlists Ids - //a[contains(@href,'#tab')] - @href (only numbers)
            var playlistNodes = doc.DocumentNode.SelectNodes("//a[contains(@href,'#tab')]");

            if (playlistNodes != null && playlistNodes.Count > 0)
            {
                foreach (var playlistNode in playlistNodes)
                {
                    try
                    {
                        playlistId = int.Parse(playlistNode.Attributes["href"].Value.Replace("#tab", "")) + 1;

                        // Episode file (JSON) - https://online.animedia.tv/embeds/playlist-j.txt/{seriesId}/{playlistId}
                        var     json    = HtmlUtils.GetHtmlPage(Utils.Combine(Info().SiteUrl, $"embeds/playlist-j.txt/{seriesId}/{playlistId}"));
                        dynamic jsonObj = JsonConvert.DeserializeObject($"{{\"episodes\":{json}}}");
                        foreach (var episode in jsonObj.episodes)
                        {
                            // Episode description - title
                            string title = episode.title;

                            // Link to m3u8 file - file
                            string file = episode.file;

                            if (file.StartsWith("//"))
                            {
                                file = "http:" + file;
                            }

                            episodes.Add(new Episode()
                            {
                                Name         = title,
                                MovieUrl     = file,
                                IsDirectLink = true
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.GetCurrentClassLogger().Error(ex, $"Ошибка при обработке эпизодов {seriesId} {playlistId}");
                    }
                }
            }

            // Get all episodes - https://online.animedia.tv/ajax/episodes/{episodeId}/{playlistId}
            // Episode node - //div[@class='media__tabs__series__list__item']
            // Link to episode - ./a - @href (+provider url)
            // Preview image - ./a/img - @data-src
            // Episode description - ./a/img - @alt

            return(episodes.ToArray());
        }