Пример #1
0
        public override async Task UpdateNameAndStatus(IManga manga)
        {
            var client = await MangachanPlugin.Instance.GetCookieClient(true).ConfigureAwait(false);

            var page = await client.GetPage(manga.Uri).ConfigureAwait(false);

            var localizedName = new MangaName();

            try
            {
                var document = new HtmlDocument();
                document.LoadHtml(page.Content);
                var enName = Regex.Match(document.DocumentNode.InnerHtml, @"title>(.*?) &raquo", RegexOptions.IgnoreCase);
                if (enName.Success)
                {
                    localizedName.English = WebUtility.HtmlDecode(enName.Groups[1].Value);
                    var regexed = Regex.Escape(localizedName.English);
                    var node    = document.DocumentNode.SelectSingleNode("//a[@class='title_top_a']");
                    var ruName  = Regex.Match(node.InnerHtml, $"{regexed} \\((.*?)\\)", RegexOptions.IgnoreCase);
                    if (ruName.Success)
                    {
                        localizedName.Russian = WebUtility.HtmlDecode(ruName.Groups[1].Value);
                    }
                }
            }
            catch (NullReferenceException ex) { Log.Exception(ex); }

            UpdateName(manga, localizedName.ToString());

            var status = string.Empty;

            try
            {
                var document = new HtmlDocument();
                document.LoadHtml(page.Content);
                var nodes = document.DocumentNode.SelectNodes("//table[@class=\"mangatitle\"]//tr");
                if (nodes != null)
                {
                    status = nodes.Aggregate(status, (current, node) =>
                                             current + Regex.Replace(WebUtility.HtmlDecode(node.InnerText).Trim(), @"\s+", " ").Replace("\n", "") + Environment.NewLine);
                }
            }
            catch (NullReferenceException ex) { Log.Exception(ex); }
            manga.Status = status;

            var description = string.Empty;

            try
            {
                var document = new HtmlDocument();
                document.LoadHtml(page.Content);
                var node = document.DocumentNode.SelectSingleNode("//div[@id=\"description\"]");
                if (node != null)
                {
                    description = WebUtility.HtmlDecode(node.InnerText).Trim().Replace("Прислать описание", "").TrimEnd();
                }
            }
            catch (Exception e) { Log.Exception(e); }
            manga.Description = description;
        }
Пример #2
0
        public override void UpdateNameAndStatus(IManga manga)
        {
            var localizedName = new MangaName();

            try
            {
                var document = new HtmlDocument();
                document.LoadHtml(Page.GetPage(manga.Uri).Content);
                var enName = Regex.Match(document.DocumentNode.InnerHtml, @"title>(.*?) &raquo", RegexOptions.IgnoreCase);
                if (enName.Success)
                {
                    localizedName.English = WebUtility.HtmlDecode(enName.Groups[1].Value);
                    var regexed = Regex.Escape(localizedName.English);
                    var node    = document.DocumentNode.SelectSingleNode("//a[@class='title_top_a']");
                    var ruName  = Regex.Match(node.InnerHtml, $"{regexed} \\((.*?)\\)", RegexOptions.IgnoreCase);
                    if (ruName.Success)
                    {
                        localizedName.Russian = WebUtility.HtmlDecode(ruName.Groups[1].Value);
                    }
                }
            }
            catch (NullReferenceException ex) { Log.Exception(ex); }

            UpdateName(manga, localizedName.ToString());
        }