예제 #1
0
        public async Task DownloadHiddendata()
        {
            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 (!Settings.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(HitomiLegalize.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(HitomiLegalize.ArticleToMetadata(article));
             if (!thumbnail_collection.ContainsKey(article.Magic))
             {
                 thumbnail_collection.Add(article.Magic, article.Thumbnail);
             }
         }
         SortMetadata();
     }
 }