Esempio n. 1
0
        public void Load()
        {
            Log.Logs.Instance.Push("Load metadata files...");

            try
            {
                metadata_collection = JsonConvert.DeserializeObject <List <HitomiMetadata> >(File.ReadAllText("metadata.json"));

                var articles = JsonConvert.DeserializeObject <List <HitomiArticle> >(File.ReadAllText("hiddendata.json"));
                var overlap  = new HashSet <string>();
                if (metadata_collection == null)
                {
                    metadata_collection = new List <HitomiMetadata>();
                }
                metadata_collection.ForEach(x => overlap.Add(x.ID.ToString()));
                foreach (var article in articles)
                {
                    if (overlap.Contains(article.Magic))
                    {
                        continue;
                    }
                    metadata_collection.Add(HitomiLegalize.ArticleToMetadata(article));
                }
                metadata_collection.Sort((a, b) => b.ID.CompareTo(a.ID));
            }
            catch (Exception e)
            {
                Log.Logs.Instance.PushError("Metadata loading error!");
                Log.Logs.Instance.PushException(e);
                Log.Logs.Instance.Panic();
            }
        }
Esempio n. 2
0
        static public HitomiArticle ParseGalleryBlock(string source)
        {
            HitomiArticle article = new HitomiArticle();

            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(source);
            HtmlNode nodes = document.DocumentNode.SelectNodes("/div")[0];

            article.Magic = nodes.SelectSingleNode("./a").GetAttributeValue("href", "");
            try { article.Thumbnail = nodes.SelectSingleNode("./a//img").GetAttributeValue("data-src", "").Substring("//tn.hitomi.la/".Length).Replace("smallbig", "big"); }
            catch
            { article.Thumbnail = nodes.SelectSingleNode("./a//img").GetAttributeValue("src", "").Substring("//tn.hitomi.la/".Length); }
            article.Title = nodes.SelectSingleNode("./h1").InnerText;

            try { article.Artists = nodes.SelectNodes(".//div[@class='artist-list']//li").Select(node => node.SelectSingleNode("./a").InnerText).ToArray(); }
            catch { article.Artists = new[] { "N/A" }; }

            var contents = nodes.SelectSingleNode("./div[2]/table");

            try { article.Series = contents.SelectNodes("./tr[1]/td[2]/ul/li").Select(node => node.SelectSingleNode(".//a").InnerText).ToArray(); } catch { }
            article.Type = contents.SelectSingleNode("./tr[2]/td[2]/a").InnerText;
            try { article.Language = HitomiLegalize.LegalizeLanguage(contents.SelectSingleNode("./tr[3]/td[2]/a").InnerText); } catch { }
            try { article.Tags = contents.SelectNodes("./tr[4]/td[2]/ul/li").Select(node => HitomiLegalize.LegalizeTag(node.SelectSingleNode(".//a").InnerText)).ToArray(); } catch { }

            article.DateTime = nodes.SelectSingleNode("./div[2]/p").InnerText;

            return(article);
        }