public ArtistViewerWindow()
        {
            InitializeComponent();

            DataContext = new Domain.ArtistDataGridViewModel();

            Task.Run(() =>
            {
                var result = HitomiDataParser.SearchAsync("artist:michiking").Result;
                _          = Task.Run(() => LoadThumbnail(result));
            });
        }
        public ArtistViewerWindow()
        {
            InitializeComponent();
            Koromo_Copy_UX.Language.Lang.ApplyLanguageDictionary(this);

            DataContext = new Domain.ArtistDataGridViewModel();

            Task.Run(() =>
            {
                var result = HitomiDataParser.SearchAsync("artist:michiking").Result;
                _          = Task.Run(() => LoadThumbnail(result));
            });
        }
        public GroupViewerWindow(string group)
        {
            InitializeComponent();
            Koromo_Copy_UX.Language.Lang.ApplyLanguageDictionary(this);

            DataContext      = new Domain.ArtistDataGridViewModel();
            TagList.Sorting += new DataGridSortingEventHandler(new DataGridSorter <ArtistDataGridItemViewModel>(TagList).SortHandler);
            Title           += group;
            Group            = group;

            var dictionary = new Dictionary <string, int>();

            Task.Run(() =>
            {
                var result = HitomiDataParser.SearchAsync($"group:{group.ToLower().Replace(' ', '_')}").Result;
                _          = Task.Run(() => LoadThumbnail(result));

                foreach (var md in result)
                {
                    if (md.Tags != null)
                    {
                        foreach (var _tag in md.Tags)
                        {
                            var tag = HitomiIndex.Instance.index.Tags[_tag];
                            if (dictionary.ContainsKey(tag))
                            {
                                dictionary[tag] += 1;
                            }
                            else
                            {
                                dictionary.Add(tag, 1);
                            }
                        }
                    }
                }
            }).ContinueWith(t => {
                var vm   = DataContext as Domain.ArtistDataGridViewModel;
                var list = dictionary.ToList();
                list.Sort((a, b) => b.Value.CompareTo(a.Value));
                foreach (var tag in list)
                {
                    vm.Items.Add(new Domain.ArtistDataGridItemViewModel
                    {
                        항목  = tag.Key,
                        카운트 = tag.Value
                    });
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Esempio n. 4
0
        /// <summary>
        /// 작품을 검색합니다.
        /// </summary>
        static void ProcessSearch(string[] args, bool show_all)
        {
            if (HitomiData.Instance.metadata_collection == null)
            {
                Console.Instance.WriteErrorLine($"Please load metadatas before searching!.");
                return;
            }

            Console.Instance.GlobalTask.Add(Task.Run(async() =>
            {
                var result = await HitomiDataParser.SearchAsync(args[0] + " " + Instance.setter);
                result.Reverse();
                if (result.Count == 0)
                {
                    Console.Instance.WriteLine("No results were found for your search.");
                    return;
                }
                foreach (var metadata in result)
                {
                    if (show_all)
                    {
                        string artists   = metadata.Artists != null ? string.Join(", ", metadata.Artists) : "N/A";
                        string tags      = metadata.Tags != null ? string.Join(", ", metadata.Tags) : "";
                        string series    = metadata.Parodies != null ? string.Join(", ", metadata.Parodies) : "";
                        string character = metadata.Characters != null ? string.Join(", ", metadata.Characters) : "";
                        string group     = metadata.Groups != null ? string.Join(", ", metadata.Groups) : "";
                        string lang      = metadata.Language != null ? metadata.Language : "";
                        string type      = metadata.Type != null ? metadata.Type : "";

                        Console.Instance.WriteLine($"{metadata.ID.ToString().PadLeft(8)} | {artists.PadLeft(15)} | {metadata.Name} | {lang} | {type} | {series} | {character} | {group} | {tags}");
                    }
                    else
                    {
                        string artist = metadata.Artists != null ? metadata.Artists[0] : "N/A";
                        Console.Instance.WriteLine($"{metadata.ID.ToString().PadLeft(8)} | {artist.PadLeft(15)} | {metadata.Name}");
                    }
                }
                Console.Instance.WriteLine($"Found {result.Count} results.");
            }));
        }
Esempio n. 5
0
        private async void AppendAsync(string content)
        {
            if (content.Trim().StartsWith("http://") || content.Trim().StartsWith("https://"))
            {
                DownloaderHelper.ProcessOthers(content.Trim());
                return;
            }

            try
            {
                List <HitomiIndexMetadata> result;

                int start_element = 0;
                int count_element = 0;

                if (content.Split(' ').Any(x => x.StartsWith("/")))
                {
                    var elem = content.Split(' ').Where(x => x.StartsWith("/")).ElementAt(0);
                    start_element = Convert.ToInt32(elem.Substring(1));
                    content       = content.Replace(elem, " ");
                }

                if (content.Split(' ').Any(x => x.StartsWith("?")))
                {
                    var elem = content.Split(' ').Where(x => x.StartsWith("?")).ElementAt(0);
                    count_element = Convert.ToInt32(elem.Substring(1));
                    content       = content.Replace(elem, " ");
                }

                if (!Settings.Instance.Hitomi.UsingAdvancedSearch || content.Contains("recent:"))
                {
                    result = await HitomiDataParser.SearchAsync(content.Trim());

                    if (content.Contains("recent:"))
                    {
                        var elem         = content.Split(' ').Where(x => x.StartsWith("recent:")).ElementAt(0);
                        int recent_count = 0;
                        int recent_start = 0;
                        if (elem.Substring("recent:".Length).Contains("-"))
                        {
                            recent_start = Convert.ToInt32(elem.Substring("recent:".Length).Split('-')[0]);
                            recent_count = Convert.ToInt32(elem.Substring("recent:".Length).Split('-')[1]);
                        }
                        else
                        {
                            recent_count = Convert.ToInt32(elem.Substring("recent:".Length));
                        }
                        SearchText.Text = "recent:" + (recent_start + recent_count) + "-" + recent_count;
                    }
                }
                else
                {
                    result = await HitomiDataSearchAdvanced.Search(content.Trim());
                }

                if (start_element != 0 && start_element <= result.Count)
                {
                    result.RemoveRange(0, start_element);
                }
                if (count_element != 0 && count_element < result.Count)
                {
                    result.RemoveRange(count_element, result.Count - count_element);
                }

                SearchCount.Text     = $"{FindResource("searched")}: {(result.Count != 0 ? result.Count.ToString("#,#") : "0")}{(FindResource("count_postfix"))}";
                SearchButton.Content = $"{FindResource("stop")}";
                _ = Task.Run(() => LoadThumbnail(result));
            }
            catch
            {
                SearchCount.Text = (string)FindResource("msg_incorret_search_grammar");
            }
        }
        public ArtistViewerWindow(string artist)
        {
            InitializeComponent();
            Koromo_Copy_UX.Language.Lang.ApplyLanguageDictionary(this);

            DataContext      = new Domain.ArtistDataGridViewModel();
            TagList.Sorting += new DataGridSortingEventHandler(new DataGridSorter <ArtistDataGridItemViewModel>(TagList).SortHandler);
            Title            = $"{FindResource("artist")} : {artist}";
            Artist           = artist;

            if (Settings.Instance.Hitomi.DisableArtistViewToast)
            {
                ArtistsPopup.IsOpen = false;
            }

            var dictionary = new Dictionary <string, int>();

            Task.Run(() =>
            {
                var result = HitomiDataParser.SearchAsync($"artist:{artist.ToLower().Replace(' ', '_')}").Result;
                _          = Task.Run(() => LoadThumbnail(result));

                foreach (var md in result)
                {
                    if (md.Tags != null)
                    {
                        foreach (var tag in md.Tags)
                        {
                            if (dictionary.ContainsKey(tag))
                            {
                                dictionary[tag] += 1;
                            }
                            else
                            {
                                dictionary.Add(tag, 1);
                            }
                        }
                    }
                }
            }).ContinueWith(async t => {
                var vm   = DataContext as Domain.ArtistDataGridViewModel;
                var list = dictionary.ToList();
                list.Sort((a, b) => b.Value.CompareTo(a.Value));
                foreach (var tag in list)
                {
                    vm.Items.Add(new Domain.ArtistDataGridItemViewModel
                    {
                        항목  = tag.Key,
                        카운트 = tag.Value
                    });
                }
                hpa.CustomAnalysis = dictionary.Select(x => new Tuple <string, int>(x.Key, x.Value)).ToList();

                if (!Settings.Instance.Hitomi.DisableArtistViewToast)
                {
                    await Task.Run(() => hpa.Update());
                    for (int j = 0; j < 5 && current_item < hpa.Rank.Count; current_item++)
                    {
                        if (hpa.Rank[current_item].Item1 == Artist)
                        {
                            continue;
                        }
                        RecommendArtist.Children.Add(new ArtistViewerToastElements(
                                                         $"{current_load + 1}. {hpa.Rank[current_item].Item1} ({HitomiAnalysis.Instance.ArtistCount[hpa.Rank[current_item].Item1]})", $"{FindResource("score")}: {hpa.Rank[current_item].Item2}", hpa.Rank[current_item].Item1));
                        j++;
                        current_load++;
                    }
                    loaded = true;
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Esempio n. 7
0
        private async void AppendAsync(string content)
        {
            if (content.Trim().StartsWith("http://") || content.Trim().StartsWith("https://"))
            {
                DownloaderHelper.ProcessOthers(content.Trim());
                return;
            }

            try
            {
                List <HitomiMetadata> result;

                int start_element = 0;
                int count_element = 0;

                if (content.Contains('/'))
                {
                    var elem = content.Split(' ').Where(x => x.StartsWith("/")).ElementAt(0);
                    start_element = Convert.ToInt32(elem.Substring(1));
                    content       = content.Replace(elem, " ");
                }

                if (content.Contains('?'))
                {
                    var elem = content.Split(' ').Where(x => x.StartsWith("?")).ElementAt(0);
                    count_element = Convert.ToInt32(elem.Substring(1));
                    content       = content.Replace(elem, " ");
                }

                if (!Settings.Instance.Hitomi.UsingAdvancedSearch || content.Contains("recent:"))
                {
                    result = await HitomiDataParser.SearchAsync(content.Trim());

                    if (content.Contains("recent:"))
                    {
                        var elem         = content.Split(' ').Where(x => x.StartsWith("recent:")).ElementAt(0);
                        int recent_count = 0;
                        int recent_start = 0;
                        if (elem.Substring("recent:".Length).Contains("-"))
                        {
                            recent_start = Convert.ToInt32(elem.Substring("recent:".Length).Split('-')[0]);
                            recent_count = Convert.ToInt32(elem.Substring("recent:".Length).Split('-')[1]);
                        }
                        else
                        {
                            recent_count = Convert.ToInt32(elem.Substring("recent:".Length));
                        }
                        SearchText.Text = "recent:" + (recent_start + recent_count) + "-" + recent_count;
                    }
                }
                else
                {
                    result = await HitomiDataSearchAdvanced.Search(content.Trim());
                }

                if (start_element != 0 && start_element <= result.Count)
                {
                    result.RemoveRange(0, start_element);
                }
                if (count_element != 0 && count_element < result.Count)
                {
                    result.RemoveRange(count_element, result.Count - count_element);
                }

                SearchCount.Text = $"검색된 항목: {result.Count.ToString("#,#")}개";
                _ = Task.Run(() => LoadThumbnail(result));
            }
            catch
            {
                SearchCount.Text = "검색 문법이 잘못되었습니다.";
            }
        }
Esempio n. 8
0
        public async void SearchAsync(string content)
        {
            try
            {
                List <HitomiMetadata> result;
                Stopwatch             sw = Stopwatch.StartNew();
                var end = sw.ElapsedMilliseconds;

                int start_element = 0;
                int count_element = 0;

                if (content.Contains('/'))
                {
                    var elem = content.Split(' ').Where(x => x.StartsWith("/")).ElementAt(0);
                    start_element = Convert.ToInt32(elem.Substring(1));
                    content       = content.Replace(elem, " ");
                }

                if (content.Contains('?'))
                {
                    var elem = content.Split(' ').Where(x => x.StartsWith("?")).ElementAt(0);
                    count_element = Convert.ToInt32(elem.Substring(1));
                    content       = content.Replace(elem, " ");
                }

                if (!Settings.Instance.Hitomi.UsingAdvancedSearch || content.Contains("recent:"))
                {
                    result = await HitomiDataParser.SearchAsync(content.Trim());

                    end = sw.ElapsedMilliseconds - end;
                    sw.Stop();
                    if (content.Contains("recent:"))
                    {
                        var elem         = content.Split(' ').Where(x => x.StartsWith("recent:")).ElementAt(0);
                        int recent_count = 0;
                        int recent_start = 0;
                        if (elem.Substring("recent:".Length).Contains("-"))
                        {
                            recent_start = Convert.ToInt32(elem.Substring("recent:".Length).Split('-')[0]);
                            recent_count = Convert.ToInt32(elem.Substring("recent:".Length).Split('-')[1]);
                        }
                        else
                        {
                            recent_count = Convert.ToInt32(elem.Substring("recent:".Length));
                        }
                        SearchText.Text = "recent:" + (recent_start + recent_count) + "-" + recent_count;
                    }
                }
                else
                {
                    result = await HitomiDataSearchAdvanced.Search(content.Trim());

                    end = sw.ElapsedMilliseconds - end;
                    sw.Stop();
                }

                if (start_element != 0 && start_element <= result.Count)
                {
                    result.RemoveRange(0, start_element);
                }
                if (count_element != 0 && count_element < result.Count)
                {
                    result.RemoveRange(count_element, result.Count - count_element);
                }

                var vm = DataContext as Domain.FinderDataGridViewModel;
                result.Sort((a, b) => b.ID.CompareTo(a.ID));
                vm.Items.Clear();
                foreach (var article in result)
                {
                    vm.Items.Add(new Domain.FinderDataGridItemViewModel
                    {
                        아이디    = article.ID.ToString(),
                        제목     = article.Name,
                        타입     = article.Type,
                        작가     = string.Join(",", article.Artists ?? Enumerable.Empty <string>()),
                        그룹     = string.Join(",", article.Groups ?? Enumerable.Empty <string>()),
                        시리즈    = string.Join(",", article.Parodies ?? Enumerable.Empty <string>()),
                        캐릭터    = string.Join(",", article.Characters ?? Enumerable.Empty <string>()),
                        업로드_시간 = HitomiDate.estimate_datetime(article.ID).ToString(),
                        태그     = string.Join(",", article.Tags ?? Enumerable.Empty <string>()),
                        다운     = HitomiLog.Instance.Contains(article.ID.ToString()) ? "★" : ""
                    });
                }

                ResultText.Text = $"{result.Count.ToString("#,#")}개 ({end / 1000.0} 초)";
            }
            catch
            {
            }
        }
        private async void LoadNext()
        {
            await Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                 delegate
            {
                LeftImage.Source = null;
                LeftProgress.Visibility = Visibility.Visible;
                RightImage.Source = null;
                RightProgress.Visibility = Visibility.Visible;
            }));

            var exclude  = RankSimulatorStatistics.FilterClosingArtists(sys);
            var ava_list = new List <int>();

            for (int i = 0; i < sys.Players.Count; i++)
            {
                if (!exclude.Contains(i))
                {
                    ava_list.Add(i);
                }
            }

            var max     = ava_list.Count;
            var rand    = new Random();
            var r_count = 0;

RETRY:
            if (r_count == 10)
            {
                await Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                     delegate
                {
                    MessageBox.Show("몇 가지 오류가 발생하여 진행할 수 없습니다. 개발자에게 문의하세요!", Title, MessageBoxButton.OK, MessageBoxImage.Error);
                }));

                return;
            }
            r_count++;
            var first  = ava_list[rand.Next(max)];
            var second = ava_list[rand.Next(max)];

            if (first == second)
            {
                goto RETRY;
            }

            var fresult = await HitomiDataParser.SearchAsync($"artist:{sys.Players[first].Indentity}");

            var sresult = await HitomiDataParser.SearchAsync($"artist:{sys.Players[second].Indentity}");

            if (fresult.Count == 0)
            {
                fresult = await HitomiDataParser.SearchAsync($"group:{sys.Players[first].Indentity}");
            }
            if (sresult.Count == 0)
            {
                sresult = await HitomiDataParser.SearchAsync($"group:{sys.Players[second].Indentity}");
            }

            if (fresult.Count == 0 || sresult.Count == 0)
            {
                goto RETRY;
            }

            left  = first;
            right = second;

            var ffirst  = rand.Next(fresult.Count);
            var ssecond = rand.Next(sresult.Count);

            await Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                 delegate
            {
                LeftText.Text = sys.Players[first].Indentity;
                RightText.Text = sys.Players[second].Indentity;
            }));

            LoadLeftImage(await GetThumbnailAddress(id1  = fresult[ffirst].ID));
            LoadRightImage(await GetThumbnailAddress(id2 = sresult[ssecond].ID));
        }