Exemplo n.º 1
0
        public async Task DownloadTagdata()
        {
            HttpClient client = new HttpClient();
            var        data   = await client.GetStringAsync(tag_json_uri);

            tagdata_collection = JsonConvert.DeserializeObject <HitomiTagdataCollection>(data);
            List <HitomiTagdata> female_data = new List <HitomiTagdata>();

            tagdata_collection.female.ForEach((a) => { HitomiTagdata tag_data = new HitomiTagdata(); tag_data.Tag = "female:" + a.Tag; tag_data.Count = a.Count; female_data.Add(tag_data); });
            List <HitomiTagdata> male_data = new List <HitomiTagdata>();

            tagdata_collection.male.ForEach((a) => { HitomiTagdata tag_data = new HitomiTagdata(); tag_data.Tag = "male:" + a.Tag; tag_data.Count = a.Count; male_data.Add(tag_data); });
            tagdata_collection.female = female_data;
            tagdata_collection.male   = male_data;
            SortTagdata();

            JsonSerializer serializer = new JsonSerializer();

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

            using (StreamWriter sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "tagdata.json")))
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    serializer.Serialize(writer, tagdata_collection);
                }
        }
Exemplo n.º 2
0
        public List <HitomiTagdata> GetCharacterList(string startswith, bool constains = false)
        {
            List <HitomiTagdata> result = new List <HitomiTagdata>();

            if (!constains)
            {
                foreach (var tagdata in tagdata_collection.character)
                {
                    if (tagdata.Tag.ToLower().Replace(' ', '_').StartsWith(startswith.ToLower()))
                    {
                        HitomiTagdata data = new HitomiTagdata(); data.Tag = tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                    }
                }
            }
            else
            {
                foreach (var tagdata in tagdata_collection.character)
                {
                    if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(startswith.ToLower()))
                    {
                        HitomiTagdata data = new HitomiTagdata(); data.Tag = tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public List <HitomiTagdata> GetTagList(string startswith, bool constains = false)
        {
            List <HitomiTagdata> target = new List <HitomiTagdata>();

            target.AddRange(tagdata_collection.female);
            target.AddRange(tagdata_collection.male);
            target.AddRange(tagdata_collection.tag);
            target.Sort((a, b) => b.Count.CompareTo(a.Count));
            List <HitomiTagdata> result = new List <HitomiTagdata>();

            if (!constains)
            {
                foreach (var tagdata in target)
                {
                    if (tagdata.Tag.ToLower().Replace(' ', '_').StartsWith(startswith.ToLower()))
                    {
                        HitomiTagdata data = new HitomiTagdata(); data.Tag = tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                    }
                }
            }
            else
            {
                foreach (var tagdata in target)
                {
                    if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(startswith))
                    {
                        HitomiTagdata data = new HitomiTagdata(); data.Tag = tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public List <HitomiTagdata> GetSeriesList(string startswith)
        {
            List <HitomiTagdata> result = new List <HitomiTagdata>();

            foreach (var tagdata in tagdata_collection.series)
            {
                if (tagdata.Tag.ToLower().Replace(' ', '_').StartsWith(startswith.ToLower()))
                {
                    HitomiTagdata data = new HitomiTagdata(); data.Tag = tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public List <HitomiTagdata> GetTotalListFuzzy(string search)
        {
            List <HitomiTagdata> result = new List <HitomiTagdata>();
            List <HitomiTagdata> target = new List <HitomiTagdata>();

            target.AddRange(tagdata_collection.female);
            target.AddRange(tagdata_collection.male);
            search = search.ToLower();
            foreach (var tagdata in tagdata_collection.artist)
            {
                HitomiTagdata data = new HitomiTagdata(); data.Tag = "artist:" + tagdata.Tag.ToLower().Replace(' ', '_');
                data.Count = -StringAlgorithms.get_diff(search, tagdata.Tag.ToLower().Replace(' ', '_')); result.Add(data);
            }
            foreach (var tagdata in tagdata_collection.group)
            {
                HitomiTagdata data = new HitomiTagdata(); data.Tag = "group:" + tagdata.Tag.ToLower().Replace(' ', '_');
                data.Count = -StringAlgorithms.get_diff(search, tagdata.Tag.ToLower().Replace(' ', '_')); result.Add(data);
            }
            foreach (var tagdata in tagdata_collection.series)
            {
                HitomiTagdata data = new HitomiTagdata(); data.Tag = "series:" + tagdata.Tag.ToLower().Replace(' ', '_');
                data.Count = -StringAlgorithms.get_diff(search, tagdata.Tag.ToLower().Replace(' ', '_')); result.Add(data);
            }
            foreach (var tagdata in tagdata_collection.character)
            {
                HitomiTagdata data = new HitomiTagdata(); data.Tag = "character:" + tagdata.Tag.ToLower().Replace(' ', '_');
                data.Count = -StringAlgorithms.get_diff(search, tagdata.Tag.ToLower().Replace(' ', '_')); result.Add(data);
            }
            foreach (var tagdata in tagdata_collection.type)
            {
                HitomiTagdata data = new HitomiTagdata(); data.Tag = "type:" + tagdata.Tag.ToLower().Replace(' ', '_');
                data.Count = -StringAlgorithms.get_diff(search, tagdata.Tag.ToLower().Replace(' ', '_')); result.Add(data);
            }
            foreach (var tagdata in target)
            {
                HitomiTagdata data = new HitomiTagdata(); data.Tag = tagdata.Tag.ToLower().Replace(' ', '_');
                data.Count = -StringAlgorithms.get_diff(search, tagdata.Tag.ToLower().Replace(' ', '_')); result.Add(data);
            }
            foreach (var tagdata in tagdata_collection.tag)
            {
                HitomiTagdata data = new HitomiTagdata(); data.Tag = "tag:" + tagdata.Tag.ToLower().Replace(' ', '_');
                data.Count = -StringAlgorithms.get_diff(search, tagdata.Tag.ToLower().Replace(' ', '_')); result.Add(data);
            }
            result.Sort((a, b) => b.Count.CompareTo(a.Count));
            return(result);
        }
Exemplo n.º 6
0
        public List <HitomiTagdata> GetTotalList(string contains)
        {
            if (HitomiSetting.Instance.GetModel().UsingFuzzy)
            {
                return(GetTotalListFuzzy(contains));
            }
            List <HitomiTagdata> result = new List <HitomiTagdata>();
            List <HitomiTagdata> target = new List <HitomiTagdata>();

            target.AddRange(tagdata_collection.female);
            target.AddRange(tagdata_collection.male);
            contains = contains.ToLower();
            foreach (var tagdata in tagdata_collection.artist)
            {
                if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(contains))
                {
                    HitomiTagdata data = new HitomiTagdata(); data.Tag = "artist:" + tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                }
            }
            foreach (var tagdata in tagdata_collection.group)
            {
                if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(contains))
                {
                    HitomiTagdata data = new HitomiTagdata(); data.Tag = "group:" + tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                }
            }
            foreach (var tagdata in tagdata_collection.series)
            {
                if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(contains))
                {
                    HitomiTagdata data = new HitomiTagdata(); data.Tag = "series:" + tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                }
            }
            foreach (var tagdata in tagdata_collection.character)
            {
                if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(contains))
                {
                    HitomiTagdata data = new HitomiTagdata(); data.Tag = "character:" + tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                }
            }
            foreach (var tagdata in tagdata_collection.type)
            {
                if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(contains))
                {
                    HitomiTagdata data = new HitomiTagdata(); data.Tag = "type:" + tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                }
            }
            foreach (var tagdata in target)
            {
                if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(contains))
                {
                    HitomiTagdata data = new HitomiTagdata(); data.Tag = tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                }
            }
            foreach (var tagdata in tagdata_collection.tag)
            {
                if (tagdata.Tag.ToLower().Replace(' ', '_').Contains(contains))
                {
                    HitomiTagdata data = new HitomiTagdata(); data.Tag = "tag:" + tagdata.Tag.ToLower().Replace(' ', '_'); data.Count = tagdata.Count; result.Add(data);
                }
            }
            result.Sort((a, b) => b.Count.CompareTo(a.Count));
            return(result);
        }