Пример #1
0
        public async Task DownloadHiddendata()
        {
            LogEssential.Instance.PushLog(() => "Start download hiddendata...");
            thumbnail_collection = new Dictionary <string, string>();
            HttpClient client = new HttpClient();

            client.Timeout = new TimeSpan(0, 0, 0, 0, Timeout.Infinite);
            var data = await client.GetStringAsync(hidden_data_url);

            List <HitomiArticle> articles   = JsonConvert.DeserializeObject <List <HitomiArticle> >(data);
            JsonSerializer       serializer = new JsonSerializer();

            serializer.Converters.Add(new JavaScriptDateTimeConverter());
            serializer.NullValueHandling = NullValueHandling.Ignore;

            if (!HitomiSetting.Instance.GetModel().AutoSync)
            {
                using (StreamWriter sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "hiddendata.json")))
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        serializer.Serialize(writer, articles);
                    }
            }

            HashSet <string> overlap = new HashSet <string>();

            metadata_collection.ForEach(x => overlap.Add(x.ID.ToString()));
            foreach (var article in articles)
            {
                if (overlap.Contains(article.Magic))
                {
                    continue;
                }
                metadata_collection.Add(HitomiCommon.ArticleToMetadata(article));
                if (!thumbnail_collection.ContainsKey(article.Magic))
                {
                    thumbnail_collection.Add(article.Magic, article.Thumbnail);
                }
            }
            SortMetadata();
        }
Пример #2
0
 public void LoadHiddendataJson()
 {
     thumbnail_collection = new Dictionary <string, string>();
     if (CheckHiddendataExist())
     {
         List <HitomiArticle> articles = JsonConvert.DeserializeObject <List <HitomiArticle> >(File.ReadAllText(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "hiddendata.json")));
         HashSet <string>     overlap  = new HashSet <string>();
         metadata_collection.ForEach(x => overlap.Add(x.ID.ToString()));
         foreach (var article in articles)
         {
             if (overlap.Contains(article.Magic))
             {
                 continue;
             }
             metadata_collection.Add(HitomiCommon.ArticleToMetadata(article));
             if (!thumbnail_collection.ContainsKey(article.Magic))
             {
                 thumbnail_collection.Add(article.Magic, article.Thumbnail);
             }
         }
         SortMetadata();
     }
 }