Exemple #1
0
        public override void UpdateNameAndStatus(IManga manga)
        {
            var page          = Page.GetPage(manga.Uri);
            var localizedName = new MangaName();

            try
            {
                var document = new HtmlDocument();
                document.LoadHtml(page.Content);
                var japNode = document.DocumentNode.SelectSingleNode("//span[@class='jp-name']");
                if (japNode != null)
                {
                    localizedName.Japanese = WebUtility.HtmlDecode(japNode.InnerText);
                }
                var engNode = document.DocumentNode.SelectSingleNode("//span[@class='eng-name']");
                if (engNode != null)
                {
                    localizedName.English = WebUtility.HtmlDecode(engNode.InnerText);
                }
                var rusNode = document.DocumentNode.SelectSingleNode("//span[@class='name']");
                if (rusNode != null)
                {
                    localizedName.Russian = WebUtility.HtmlDecode(rusNode.InnerText);
                }
            }
            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("//div[@class=\"subject-meta col-sm-7\"]//p");
                if (nodes != null)
                {
                    status = nodes.Aggregate(status, (current, node) =>
                                             current + Regex.Replace(node.InnerText.Trim(), @"\s+", " ").Replace("\n", "") + Environment.NewLine);
                }
            }
            catch (NullReferenceException ex) { Log.Exception(ex); }
            manga.Status = status;
        }
        public override async Task UpdateNameAndStatus(IManga manga)
        {
            var client = await GetClient().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 japNode = document.DocumentNode.SelectSingleNode("//span[@class='jp-name']");
                if (japNode != null)
                {
                    localizedName.Japanese = WebUtility.HtmlDecode(japNode.InnerText);
                }
                var engNode = document.DocumentNode.SelectSingleNode("//span[@class='eng-name']");
                if (engNode != null)
                {
                    localizedName.English = WebUtility.HtmlDecode(engNode.InnerText);
                }
                var rusNode = document.DocumentNode.SelectSingleNode("//span[@class='name']");
                if (rusNode != null)
                {
                    localizedName.Russian = WebUtility.HtmlDecode(rusNode.InnerText);
                }
            }
            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("//div[contains(@class, 'subject-meta')]//p");
                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[@class=\"manga-description\"]");
                if (node != null)
                {
                    description = WebUtility.HtmlDecode(node.InnerText).Trim();
                }
            }
            catch (Exception e) { Log.Exception(e); }
            manga.Description = description;
        }