public HitomiAnalysisArtist(IEnumerable <HitomiLogModel> logs)
        {
            Dictionary <string, int> tags_map = new Dictionary <string, int>();

            foreach (var log in logs.Where(log => log.Tags != null))
            {
                tags_count += log.Tags.Length;
                foreach (var tag in log.Tags)
                {
                    if (tags_map.ContainsKey(HitomiCommon.LegalizeTag(tag)))
                    {
                        tags_map[HitomiCommon.LegalizeTag(tag)] += 1;
                    }
                    else
                    {
                        tags_map.Add(HitomiCommon.LegalizeTag(tag), 1);
                    }
                }
            }

            foreach (var pair in tags_map)
            {
                rate.Add(pair.Key, pair.Value * pair.Value / (float)tags_count);
            }
        }
Beispiel #2
0
 public static void ProcessEXHentai(HArticleModel commander, bool unstable = false)
 {
     Task.Run(() =>
     {
         if (unstable)
         {
             MainWindow.Instance.Fade_MiddlePopup(true, $"불안정한 작업 진행중...[{unstable_request}개]");
         }
         var pages               = ExHentaiParser.GetPagesUri(NetCommon.DownloadExHentaiString(commander.URL));
         var pages_html          = EmiliaJobEXH.Instance.AddJob(pages.ToList(), x => { }).Select(x => ExHentaiParser.GetImagesUri(x));
         List <string> pages_all = new List <string>();
         pages_html.ToList().ForEach(x => pages_all.AddRange(x));
         var imagelink      = EmiliaJobEXH.Instance.AddJob(pages_all, x => { }).Select(x => ExHentaiParser.GetImagesAddress(x));
         List <string> tags = new List <string>();
         if (commander.male != null)
         {
             tags.AddRange(commander.male.Select(x => "male:" + x.Replace(' ', '_')));
         }
         if (commander.female != null)
         {
             tags.AddRange(commander.female.Select(x => "female:" + x.Replace(' ', '_')));
         }
         if (commander.misc != null)
         {
             tags.AddRange(commander.misc.Select(x => x.Replace(' ', '_')));
         }
         HitomiArticle article = new HitomiArticle
         {
             Magic      = commander.Magic,
             Title      = commander.Title,
             Artists    = commander.artist,
             Groups     = commander.group,
             Series     = commander.parody,
             Tags       = tags.ToArray(),
             Language   = commander.language != null ? commander.language[0] : "",
             Characters = commander.character
         };
         string dir         = HitomiCommon.MakeDownloadDirectory(article);
         article.ImagesLink = imagelink.ToList();
         Directory.CreateDirectory(dir);
         var se    = Koromo_Copy.Interface.SemaphoreExtends.MakeDefault();
         se.Cookie = "igneous=30e0c0a66;ipb_member_id=2742770;ipb_pass_hash=6042be35e994fed920ee7dd11180b65f;";
         DownloadSpace.Instance.RequestDownload(article.Title,
                                                imagelink.ToArray(),
                                                imagelink.Select(y => Path.Combine(dir, y.Split('/').Last())).ToArray(),
                                                se, dir, article);
         if (unstable)
         {
             Interlocked.Decrement(ref unstable_request);
         }
         if (unstable && unstable_request != 0)
         {
             MainWindow.Instance.Fade_MiddlePopup(true, $"불안정한 작업 진행중...[{unstable_request}개]");
         }
         else
         {
             MainWindow.Instance.FadeOut_MiddlePopup($"{imagelink.Count()}개 이미지 다운로드 시작...");
         }
     });
 }
        private void PicDetailElement_Load(object sender, EventArgs e)
        {
            lTitle.Text     = ha.Title;
            lArtist.Text    = string.Join(",", ha.Artists ?? Enumerable.Empty <string>());
            lSeries.Text    = string.Join(",", ha.Series ?? Enumerable.Empty <string>());
            lGroup.Text     = string.Join(",", ha.Groups ?? Enumerable.Empty <string>());
            lCharacter.Text = string.Join(",", ha.Characters ?? Enumerable.Empty <string>());
            lDate.Text      = HitomiDate.estimate_datetime(Convert.ToInt32(ha.Magic)).ToString();
            if (ha.Tags != null)
            {
                ha.Tags.ToList().ForEach((a) =>
                {
                    a = HitomiCommon.LegalizeTag(a);
                    if (a.StartsWith("female:"))
                    {
                        AddTagToPanel(a.Substring("female:".Length), 1);
                    }
                    else if (a.StartsWith("male:"))
                    {
                        AddTagToPanel(a.Substring("male:".Length), 2);
                    }
                    else
                    {
                        AddTagToPanel(a, 0);
                    }
                });
            }
            if (HitomiSetting.Instance.GetModel().UsingExHentaiBaseOpener)
            {
                metroButton4.Text = "익헨에서 열기";
            }
            lLang.Text = ha.Language;
            if (HitomiSetting.Instance.GetModel().Language != "ALL")
            {
                label9.Dispose();
                lLang.Dispose();
            }

            for (int i = 0; i < Controls.Count; i++)
            {
                if (Controls[i] is Label && Controls[i] != lPage)
                {
                    ConvertToVUILabel(Controls[i--] as Label);
                }
            }

            if (HitomiSetting.Instance.GetModel().ShowPageCount)
            {
                Task.Run(() => {
                    string ppp = HitomiCore.GetPageCount(this).ToString() + "p";
                    this.Send(() => lPage.Text = ppp);
                });
            }
            else
            {
                lPage.Dispose();
            }
        }
Beispiel #4
0
        private void frmGalleryInfo_LoadAsync(object sender, EventArgs e)
        {
            if (pic != null)
            {
                pbImage.Image   = pic.Image;
                lTitle.Text     = pic.Article.Title;
                lArtist.Text    = string.Join(",", pic.Article.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", pic.Article.Series ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", pic.Article.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", pic.Article.Characters ?? Enumerable.Empty <string>());
                textBox1.Text   = string.Join(",", pic.Article.Tags ?? Enumerable.Empty <string>());

                pic.Article.Tags.ToList().ForEach((a) =>
                {
                    a = HitomiCommon.LegalizeTag(a);
                    if (a.StartsWith("female:"))
                    {
                        AddTagToPanel(a.Substring("female:".Length), 1);
                    }
                    else if (a.StartsWith("male:"))
                    {
                        AddTagToPanel(a.Substring("male:".Length), 2);
                    }
                    else
                    {
                        AddTagToPanel(a, 0);
                    }
                });
            }
            else
            {
                lTitle.Text     = metadata.Name;
                lArtist.Text    = string.Join(",", metadata.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", metadata.Parodies ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", metadata.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", metadata.Characters ?? Enumerable.Empty <string>());

                metadata.Tags.ToList().ForEach((a) =>
                {
                    if (a.StartsWith("female:"))
                    {
                        AddTagToPanel(a.Substring("female:".Length), 1);
                    }
                    else if (a.StartsWith("male:"))
                    {
                        AddTagToPanel(a.Substring("male:".Length), 2);
                    }
                    else
                    {
                        AddTagToPanel(a, 0);
                    }
                });

                Task.Run(() => download_image());
            }
        }
Beispiel #5
0
        private void frmArtistInfo_Load(object sender, EventArgs e)
        {
            Text += group;
            var hitomi_data = HitomiData.Instance.metadata_collection;
            Dictionary <string, int> tag_count = new Dictionary <string, int>();
            int gallery_count = 0;

            foreach (var metadata in hitomi_data)
            {
                if (metadata.Groups != null && metadata.Tags != null && (metadata.Language == HitomiSetting.Instance.GetModel().Language || HitomiSetting.Instance.GetModel().Language == "ALL") && metadata.Groups.Contains(group))
                {
                    gallery_count += 1;
                    foreach (var tag in metadata.Tags)
                    {
                        if (tag_count.ContainsKey(tag))
                        {
                            tag_count[tag] += 1;
                        }
                        else
                        {
                            tag_count.Add(tag, 1);
                        }
                    }
                }
            }

            var result = tag_count.ToList();

            result.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));

            List <ListViewItem> lvil = new List <ListViewItem>();

            for (int i = 0; i < result.Count; i++)
            {
                lvil.Add(new ListViewItem(new string[]
                {
                    result[i].Key,
                    result[i].Value.ToString()
                }));
            }
            lvMyTagRank.Items.AddRange(lvil.ToArray());

            pbLoad.Maximum = gallery_count;

            foreach (var metadata in hitomi_data)
            {
                if (metadata.Groups != null && (metadata.Language == HitomiSetting.Instance.GetModel().Language || HitomiSetting.Instance.GetModel().Language == "ALL") && metadata.Groups.Contains(group))
                {
                    HitomiArticle article = HitomiCommon.MetadataToArticle(metadata);
                    Task.Run(() => ProcessLoading(article));
                }
            }
        }
Beispiel #6
0
 private void LoadImages()
 {
     for (int i = 0; i < Article.ImagesLink.Count; i++)
     {
         Application.Current.Dispatcher.Invoke(new Action(
                                                   delegate
         {
             string address = Article.ImagesLink[i];
             if (Article is HitomiArticle ha)
             {
                 address = HitomiCommon.GetDownloadImageAddress(ha.Magic, address, ha.HasWebp[address], ha.HasWebp[address] ? ha.Hashs[address] : "");
             }
             ImageStack.Children.Add(new PreviewImageElements($"{i + 1} Page", address));
         }));
        public HitomiAnalysisGallery()
        {
            Dictionary <string, int> tag_rank = new Dictionary <string, int>();

            foreach (var v in HitomiLog.Instance.GetEnumerator())
            {
                if (v.Tags == null)
                {
                    continue;
                }
                foreach (var tag in v.Tags)
                {
                    string legalize = HitomiCommon.LegalizeTag(tag);
                    if (tag_rank.ContainsKey(legalize))
                    {
                        tag_rank[legalize] += 1;
                    }
                    else
                    {
                        tag_rank.Add(legalize, 1);
                    }
                }
            }

            Dictionary <int, Tuple <double, HitomiMetadata> > datas = new Dictionary <int, Tuple <double, HitomiMetadata> >();
            double total_score    = 0.0;
            int    count_metadata = HitomiData.Instance.metadata_collection.Count;

            foreach (var metadata in HitomiData.Instance.metadata_collection)
            {
                double score = 0.0;
                if (metadata.Tags != null)
                {
                    foreach (var tag in metadata.Tags)
                    {
                        if (tag_rank.ContainsKey(tag))
                        {
                            score += tag_rank[tag];
                        }
                    }
                    score /= metadata.Tags.Length;
                }
                total_score += score;
                datas.Add(metadata.ID, new Tuple <double, HitomiMetadata>(score, metadata));
            }

            gallery_data = datas.ToList();
            gallery_data.Sort((p1, p2) => p2.Value.Item1.CompareTo(p1.Value.Item1));
        }
Beispiel #8
0
        public HitomiAnalysisArtist(IEnumerable <HitomiLogModel> logs)
        {
            Dictionary <string, int> tags_map = new Dictionary <string, int>();

            foreach (var log in logs.Where(log => log.Tags != null))
            {
                foreach (var tag in log.Tags)
                {
                    if (HitomiSetting.Instance.GetModel().UsingOnlyFMTagsOnAnalysis&&
                        !tag.StartsWith("female:") && !tag.StartsWith("male:"))
                    {
                        continue;
                    }
                    tags_count += 1;
                    if (tags_map.ContainsKey(HitomiCommon.LegalizeTag(tag)))
                    {
                        tags_map[HitomiCommon.LegalizeTag(tag)] += 1;
                    }
                    else
                    {
                        tags_map.Add(HitomiCommon.LegalizeTag(tag), 1);
                    }
                }
            }

            foreach (var pair in tags_map)
            {
                if (!HitomiSetting.Instance.GetModel().UsingCosineAnalysis)
                {
                    if (!HitomiSetting.Instance.GetModel().RecommendNMultipleWithLength)
                    {
                        rate.Add(pair.Key, pair.Value * pair.Value / (float)tags_count);
                    }
                    else
                    {
                        rate.Add(pair.Key, pair.Value / (float)tags_count);
                    }
                }
                else
                {
                    rate.Add(pair.Key, pair.Value);
                }
            }
        }
Beispiel #9
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();
        }
        /// <summary>
        /// 이미지 링크를 다운로드하고 정보를 출력합니다.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="dl">다운로드 가능한 이미지 링크를 출력할지의 여부를 설정합니다.</param>
        static void ProcessImage(string[] args, string type)
        {
            string html_source = NetCommon.DownloadString($"{HitomiCommon.HitomiGalleryAddress}{args[0]}.js");
            var    image_link  = HitomiParser.GetImageLink(html_source);

            if (type == null)
            {
                Console.Instance.WriteLine(image_link.Select(x => HitomiCommon.GetDownloadImageAddress(args[0], x, false, "")));
            }
            else if (type == "small")
            {
                Console.Instance.WriteLine(image_link.Select(x => $"{HitomiCommon.HitomiThumbnailSmall}{args[0]}/{x}.jpg"));
            }
            else if (type == "big")
            {
                Console.Instance.WriteLine(image_link.Select(x => $"{HitomiCommon.HitomiThumbnailBig}{args[0]}/{x}.jpg"));
            }
            else
            {
                Console.Instance.WriteErrorLine($"'{type}' is not correct type. Please input 'small' or 'big'.");
            }
        }
Beispiel #11
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();
     }
 }
Beispiel #12
0
        private void AddPanel()
        {
            int count = 0;

            foreach (var md in metadatas)
            {
                if (!md.Item3.HasValue)
                {
                    continue;
                }
                count++;
                if (count == 100)
                {
                    return;
                }
                string path = Path.Combine(tbPath.Text, md.Item1);

                IPicElement pe;
                pe = new PicElement(this);
                HitomiArticle article = HitomiCommon.MetadataToArticle(md.Item3.Value);

                pe.Article = article;
                pe.Label   = article.Title;

                using (var zip = ZipFile.Open(path, ZipArchiveMode.Read))
                {
                    string tmp = Path.GetTempFileName();
                    zip.Entries[0].ExtractToFile(tmp, true);
                    pe.SetImageFromAddress(tmp, 150, 200);
                }

                pe.Font = this.Font;

                this.Post(() => ImagePanel.Controls.Add(pe as Control));
            }
        }
        private void SearchMaterialElements_Loaded(object sender, RoutedEventArgs e)
        {
            if (init)
            {
                return;
            }
            init = true;
            Task.Run(() =>
            {
                HitomiArticle ha = Article as HitomiArticle;
                try
                {
                    ha.Thumbnail = HitomiCommon.HitomiThumbnail + HitomiParser.ParseGalleryBlock(Koromo_Copy.Net.NetCommon.DownloadString(
                                                                                                     $"{HitomiCommon.HitomiGalleryBlock}{ha.Magic}.html")).Thumbnail;
                    ha.ImagesLink = HitomiParser.GetImageLink(Koromo_Copy.Net.NetCommon.DownloadString(HitomiCommon.GetImagesLinkAddress(ha.Magic)));
                }
                catch
                {
                    ha.IsUnstable = true;
                    var har       = HCommander.GetArticleData(Convert.ToInt32(ha.Magic));
                    if (!har.HasValue)
                    {
                        MessageBox.Show($"{ha.Magic}를 찾을 수 없습니다. 이 항목은 히요비, 이헨, 익헨 어디에도 없었습니다. 프로그램 제작자에게 문의하세요.", "Koromo copy", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    ha.UnstableModel = har.Value;
                    ha.Thumbnail     = ha.UnstableModel.Thumbnail;
                    ha.ImagesLink    = new List <string>();
                }
                Application.Current.Dispatcher.BeginInvoke(new Action(
                                                               delegate
                {
                    try
                    {
                        if (ha.IsUnstable && ha.UnstableModel.ArticleType == HArticleType.EXHentai)
                        {
                            var image = NetCommon.GetExHentaiClient().DownloadData(new Uri(ha.UnstableModel.Thumbnail));
                            using (var ms = new System.IO.MemoryStream(image))
                            {
                                BitmapImage.BeginInit();
                                if (Settings.Instance.Model.LowQualityImage)
                                {
                                    BitmapImage.DecodePixelWidth = 100;
                                }
                                BitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                                BitmapImage.StreamSource = ms;
                                BitmapImage.EndInit();
                            }
                        }
                        else
                        {
                            BitmapImage.BeginInit();
                            BitmapImage.UriSource = new Uri(ha.Thumbnail);
                            if (Settings.Instance.Model.LowQualityImage)
                            {
                                BitmapImage.DecodePixelWidth = 100;
                            }
                            BitmapImage.EndInit();
                            BitmapImage.DownloadCompleted += B_DownloadCompleted;
                        }
                    }
                    catch (Exception ex)
                    {
                        Monitor.Instance.Push("[SME Error] " + ex.Message + "\r\n" + ex.StackTrace);
                    }

                    ImageCount.Text = ha.ImagesLink.Count + " Pages";
                    Image.Source    = BitmapImage;

                    if (ha.Artists != null && ha.Artists[0].ToUpper() != "N/A")
                    {
                        var stack = new StackPanel {
                            Orientation = Orientation.Horizontal
                        };
                        stack.Children.Add(new PackIcon {
                            Kind = PackIconKind.Artist, Opacity = .56
                        });
                        stack.Children.Add(new TextBlock {
                            Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center, Text = "작가 목록"
                        });
                        var menu_item = new MenuItem {
                            Header = stack
                        };
                        foreach (var artist in ha.Artists)
                        {
                            var item = new MenuItem {
                                Header = new TextBlock {
                                    Text = artist
                                }, Tag = $"artist:{artist.Replace(' ', '_')}"
                            };
                            item.Click += MenuItem_Click;
                            menu_item.Items.Add(item);
                        }
                        Menu.Items.Add(menu_item);
                    }
                    if (ha.Groups != null && ha.Groups[0].ToUpper() != "N/A")
                    {
                        var stack = new StackPanel {
                            Orientation = Orientation.Horizontal
                        };
                        stack.Children.Add(new PackIcon {
                            Kind = PackIconKind.UserGroup, Opacity = .56
                        });
                        stack.Children.Add(new TextBlock {
                            Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center, Text = "그룹 목록"
                        });
                        var menu_item = new MenuItem {
                            Header = stack
                        };
                        foreach (var group in ha.Groups)
                        {
                            var item = new MenuItem {
                                Header = new TextBlock {
                                    Text = group
                                }, Tag = $"group:{group.Replace(' ', '_')}"
                            };
                            item.Click += MenuItem_Click;
                            menu_item.Items.Add(item);
                        }
                        Menu.Items.Add(menu_item);
                    }
                    if (ha.Series != null)
                    {
                        var stack = new StackPanel {
                            Orientation = Orientation.Horizontal
                        };
                        stack.Children.Add(new PackIcon {
                            Kind = PackIconKind.Book, Opacity = .56
                        });
                        stack.Children.Add(new TextBlock {
                            Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center, Text = "시리즈 목록"
                        });
                        var menu_item = new MenuItem {
                            Header = stack
                        };
                        foreach (var series in ha.Series)
                        {
                            MenuItem item = null;
                            if (KoreanSeries.SeriesMap(series) == series)
                            {
                                item = new MenuItem {
                                    Header = new TextBlock {
                                        Text = series
                                    }, Tag = $"series:{series.Replace(' ', '_')}"
                                }
                            }
                            ;
                            else
                            {
                                item = new MenuItem {
                                    Header = new TextBlock {
                                        Text = $"{series} ({KoreanSeries.SeriesMap(series)})"
                                    }, Tag = $"series:{series.Replace(' ', '_')}"
                                }
                            };
                            item.Click += MenuItem_Click;
                            menu_item.Items.Add(item);
                        }
                        Menu.Items.Add(menu_item);
                    }
                    if (ha.Tags != null)
                    {
                        var stack = new StackPanel {
                            Orientation = Orientation.Horizontal
                        };
                        stack.Children.Add(new PackIcon {
                            Kind = PackIconKind.Tag, Opacity = .56
                        });
                        stack.Children.Add(new TextBlock {
                            Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center, Text = "태그 목록"
                        });
                        var menu_item = new MenuItem {
                            Header = stack
                        };
                        foreach (var tag in ha.Tags)
                        {
                            MenuItem item = null;
                            if (KoreanTag.TagMap(tag) == tag)
                            {
                                item = new MenuItem {
                                    Header = new TextBlock {
                                        Text = tag
                                    }, Tag = $"{(tag.StartsWith("female:") || tag.StartsWith("male:") ? tag.Replace(' ', '_') : $"tag:{tag.Replace(' ', '_')}")}"
                                }
                            }
                            ;
                            else if (KoreanTag.TagMap(tag).Contains(':'))
                            {
                                item = new MenuItem {
                                    Header = new TextBlock {
                                        Text = $"{tag} ({KoreanTag.TagMap(tag).Split(':')[1]})"
                                    }, Tag = $"{(tag.StartsWith("female:") || tag.StartsWith("male:") ? tag.Replace(' ', '_') : $"tag:{tag.Replace(' ', '_')}")}"
                                }
                            }
                            ;
                            else
                            {
                                item = new MenuItem {
                                    Header = new TextBlock {
                                        Text = $"{tag} ({KoreanTag.TagMap(tag)})"
                                    }, Tag = $"{(tag.StartsWith("female:") || tag.StartsWith("male:") ? tag.Replace(' ', '_') : $"tag:{tag.Replace(' ', '_')}")}"
                                }
                            };
                            item.Click += MenuItem_Click;
                            menu_item.Items.Add(item);
                        }
                        Menu.Items.Add(menu_item);
                    }
                }));
            });
Beispiel #14
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var tag = (sender as Button).Tag.ToString();

            if (tag == "Search" && IsMetadataLoaded)
            {
                lock (load_lock)
                {
                    if (!loading)
                    {
                        AppendAsync(SearchText.Text);
                    }
                    else
                    {
                        StopLoad();
                    }
                }
            }
            else if (tag == "Tidy")
            {
                if (!Settings.Instance.UXSetting.UsingThumbnailSearchElements)
                {
                    int count = SearchPanel.Children.Count / 2;
                    SearchPanel.Children.Clear();
                    GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                    if (count > 0)
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup($"{count}{(string)FindResource("msg_tidy")}", false);
                    }
                }
                else
                {
                    int count = SearchMaterialPanel.Children.Count / 2;
                    SearchMaterialPanel.Children.Clear();
                    GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                    if (count > 0)
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup($"{count}{(string)FindResource("msg_tidy")}", false);
                    }
                }
            }
            else if (tag == "SelectAll")
            {
                if (!Settings.Instance.UXSetting.UsingThumbnailSearchElements)
                {
                    SearchPanel.Children.OfType <SearchElements>().ToList().ForEach(x => x.Select = true);
                }
                else
                {
                    SearchMaterialPanel.Children.OfType <SearchMaterialElements>().ToList().ForEach(x => x.Select = true);
                }
            }
            else if (tag == "DeSelectAll")
            {
                if (!Settings.Instance.UXSetting.UsingThumbnailSearchElements)
                {
                    SearchPanel.Children.OfType <SearchElements>().ToList().ForEach(x => x.Select = false);
                }
                else
                {
                    SearchMaterialPanel.Children.OfType <SearchMaterialElements>().ToList().ForEach(x => x.Select = false);
                }
            }
            else if (tag == "Download")
            {
                if (!Settings.Instance.UXSetting.UsingThumbnailSearchElements)
                {
                    int count = 0;
                    SearchPanel.Children.OfType <SearchElements>().ToList().Where(x => x.Select).ToList().ForEach(x =>
                    {
                        var ha     = x.Article as HitomiArticle;
                        var prefix = HitomiCommon.MakeDownloadDirectory(ha, SearchText.Text);
                        Directory.CreateDirectory(prefix);
                        if (!ha.IsUnstable)
                        {
                            DownloadSpace.Instance.RequestDownload(x.Article.Title,
                                                                   x.Article.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y)).ToArray(),
                                                                   x.Article.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(),
                                                                   Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article);
                        }
                        else
                        {
                            DownloaderHelper.ProcessUnstable(ha.UnstableModel);
                        }
                        count++;
                    });
                    if (count > 0)
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup($"{count}{(string)FindResource("msg_download_start")}");
                    }
                }
                else
                {
                    int count = 0;
                    SearchMaterialPanel.Children.OfType <SearchMaterialElements>().ToList().Where(x => x.Select).ToList().ForEach(x =>
                    {
                        var ha     = x.Article as HitomiArticle;
                        var prefix = HitomiCommon.MakeDownloadDirectory(x.Article as HitomiArticle, SearchText.Text);
                        Directory.CreateDirectory(prefix);
                        if (!ha.IsUnstable)
                        {
                            DownloadSpace.Instance.RequestDownload(x.Article.Title,
                                                                   x.Article.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y)).ToArray(),
                                                                   x.Article.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(),
                                                                   Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article);
                        }
                        else
                        {
                            DownloaderHelper.ProcessUnstable(ha.UnstableModel);
                        }
                        count++;
                    });
                    if (count > 0)
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup($"{count}{(string)FindResource("msg_download_start")}");
                    }
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            if (btn.Tag.ToString() == "DownloadAll")
            {
                int count = 0;
                ArticlePanel.Children.OfType <SearchSimpleElements>().ToList().ForEach(x =>
                {
                    var ha     = x.Article as HitomiArticle;
                    ha.Artists = new string[] { Artist };
                    var prefix = HitomiCommon.MakeDownloadDirectory(ha);
                    Directory.CreateDirectory(prefix);
                    if (!ha.IsUnstable)
                    {
                        DownloadSpace.Instance.RequestDownload(x.Article.Title,
                                                               x.Article.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y)).ToArray(),
                                                               x.Article.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(),
                                                               Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article);
                    }
                    else
                    {
                        DownloaderHelper.ProcessUnstable(ha.UnstableModel);
                    }
                    count++;
                });
                if (count > 0)
                {
                    MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}");
                }
                MainWindow.Instance.Activate();
                MainWindow.Instance.FocusDownload();
                Close();
            }
            else if (btn.Tag.ToString() == "Download")
            {
                int count = 0;
                ArticlePanel.Children.OfType <SearchSimpleElements>().ToList().Where(x => x.Select).ToList().ForEach(x =>
                {
                    var ha     = x.Article as HitomiArticle;
                    ha.Artists = new string[] { Artist };
                    var prefix = HitomiCommon.MakeDownloadDirectory(ha);
                    Directory.CreateDirectory(prefix);
                    if (!ha.IsUnstable)
                    {
                        DownloadSpace.Instance.RequestDownload(x.Article.Title,
                                                               x.Article.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y)).ToArray(),
                                                               x.Article.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(),
                                                               Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article);
                    }
                    else
                    {
                        DownloaderHelper.ProcessUnstable(ha.UnstableModel);
                    }
                    count++;
                });
                if (count > 0)
                {
                    MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}");
                }
                MainWindow.Instance.Activate();
                MainWindow.Instance.FocusDownload();
            }
        }
Beispiel #16
0
        private void frmGalleryInfo_LoadAsync(object sender, EventArgs e)
        {
            lDate.Text = HitomiDate.estimate_datetime(Convert.ToInt32(id)).ToString();
            if (pic != null)
            {
                pbImage.Image   = pic.Image;
                lTitle.Text     = pic.Article.Title;
                lArtist.Text    = string.Join(",", pic.Article.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", pic.Article.Series ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", pic.Article.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", pic.Article.Characters ?? Enumerable.Empty <string>());
                textBox1.Text   = string.Join(",", pic.Article.Tags ?? Enumerable.Empty <string>());

                if (pic.Article.Tags != null)
                {
                    pic.Article.Tags.ToList().ForEach((a) =>
                    {
                        a = HitomiCommon.LegalizeTag(a);
                        if (a.StartsWith("female:"))
                        {
                            AddTagToPanel(a.Substring("female:".Length), 1);
                        }
                        else if (a.StartsWith("male:"))
                        {
                            AddTagToPanel(a.Substring("male:".Length), 2);
                        }
                        else
                        {
                            AddTagToPanel(a, 0);
                        }
                    });
                }
            }
            else
            {
                lTitle.Text     = metadata.Name;
                lArtist.Text    = string.Join(",", metadata.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", metadata.Parodies ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", metadata.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", metadata.Characters ?? Enumerable.Empty <string>());

                if (metadata.Tags != null)
                {
                    metadata.Tags.ToList().ForEach((a) =>
                    {
                        if (a.StartsWith("female:"))
                        {
                            AddTagToPanel(a.Substring("female:".Length), 1);
                        }
                        else if (a.StartsWith("male:"))
                        {
                            AddTagToPanel(a.Substring("male:".Length), 2);
                        }
                        else
                        {
                            AddTagToPanel(a, 0);
                        }
                    });
                }

                Task.Run(() => download_image());
            }

            if (HitomiSetting.Instance.GetModel().ShowPageCount)
            {
                Task.Run(() => {
                    string ppp = HitomiCore.GetPageCount(id).ToString() + "p";
                    this.Send(() => lPage.Text = ppp);
                });
            }
            else
            {
                lPage.Dispose();
            }
        }
Beispiel #17
0
        public HitomiAnalysisGallery()
        {
            Dictionary <string, int> tag_rank = new Dictionary <string, int>();

            foreach (var legalize in from v in HitomiLog.Instance.GetEnumerator() where v.Tags != null from tag in v.Tags select HitomiCommon.LegalizeTag(tag))
            {
                if (tag_rank.ContainsKey(legalize))
                {
                    tag_rank[legalize] += 1;
                }
                else
                {
                    tag_rank.Add(legalize, 1);
                }
            }

            Dictionary <int, Tuple <double, HitomiMetadata> > datas = new Dictionary <int, Tuple <double, HitomiMetadata> >();
            double total_score    = 0.0;
            int    count_metadata = HitomiData.Instance.metadata_collection.Count;

            foreach (var metadata in HitomiData.Instance.metadata_collection)
            {
                double score = 0.0;
                if (metadata.Tags != null)
                {
                    score  = metadata.Tags.Where(tag => tag_rank.ContainsKey(tag)).Aggregate(score, (current, tag) => current + tag_rank[tag]);
                    score /= metadata.Tags.Length;
                }
                total_score += score;
                datas.Add(metadata.ID, new Tuple <double, HitomiMetadata>(score, metadata));
            }

            gallery_data = datas.ToList();
            gallery_data.Sort((p1, p2) => p2.Value.Item1.CompareTo(p1.Value.Item1));
        }
        public static void ProcessHiyobi(string url, bool unstable = false)
        {
            Task.Run(() =>
            {
                if (url.StartsWith("https://hiyobi.me/manga/info/"))
                {
                    MainWindow.Instance.Fade_MiddlePopup(true, "접속중...");
                    var html     = NetCommon.DownloadString(url);
                    var articles = HiyobiParser.ParseNonHArticles(html);
                    var title    = HiyobiParser.ParseNonHTitle(html);

                    MainWindow.Instance.ModifyText_MiddlePopup($"가져오는중...[0/{articles.Count}]");
                    for (int i = 0; i < articles.Count; i++)
                    {
                        articles[i].ImagesLink = HitomiParser.GetImageLink(NetCommon.DownloadString(HiyobiCommon.GetDownloadMangaImageAddress(articles[i].Magic)));
                        MainWindow.Instance.ModifyText_MiddlePopup($"가져오는중...[{i + 1}/{articles.Count}]");
                    }

                    int count = 0;
                    foreach (var article in articles)
                    {
                        string dir = Path.Combine(Path.Combine(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "hiyobi"), DeleteInvalid(title)), DeleteInvalid(article.Title));
                        Directory.CreateDirectory(dir);

                        var se     = Koromo_Copy.Interface.SemaphoreExtends.MakeDefault();
                        se.Referer = url;

                        count += article.ImagesLink.Count;
                        DownloadSpace.Instance.RequestDownload($"hiyobi-nonh: {article.Title}",
                                                               article.ImagesLink.Select(x => x.StartsWith("http://") || x.StartsWith("https://") ? x : $"https://aa.hiyobi.me/data_m/{article.Magic}/{x}").ToArray(),
                                                               article.ImagesLink.Select(x => Path.Combine(dir, !x.StartsWith("http://images-blogger-opensocial.googleusercontent.com/") ?
                                                                                                           HttpUtility.UrlDecode(HttpUtility.UrlDecode(x.Split('/').Last())) :
                                                                                                           HttpUtility.UrlDecode(HttpUtility.UrlDecode(HttpUtility.ParseQueryString(new Uri(x).Query).Get("url").Split('/').Last())))).ToArray(),
                                                               se,
                                                               dir + '\\',
                                                               null
                                                               );
                    }

                    MainWindow.Instance.FadeOut_MiddlePopup($"{count}개({articles.Count} 작품) 항목 다운로드 시작...");
                }
                else if (url.StartsWith("https://hiyobi.me/info/"))
                {
                    if (unstable)
                    {
                        MainWindow.Instance.Fade_MiddlePopup(true, $"불안정한 작업 진행중...[{unstable_request}개]");
                    }
                    else
                    {
                        MainWindow.Instance.Fade_MiddlePopup(true, "접속중...");
                    }
                    var imagelink      = HitomiParser.GetImageLink(NetCommon.DownloadString(HiyobiCommon.GetDownloadImageAddress(url.Split('/').Last())));
                    var article        = HiyobiParser.ParseGalleryConents(NetCommon.DownloadString(url));
                    string dir         = HitomiCommon.MakeDownloadDirectory(article);
                    article.ImagesLink = imagelink;
                    Directory.CreateDirectory(dir);
                    DownloadSpace.Instance.RequestDownload(article.Title,
                                                           imagelink.Select(y => HitomiCommon.GetDownloadImageAddress(article.Magic, y)).ToArray(),
                                                           imagelink.Select(y => Path.Combine(dir, y)).ToArray(),
                                                           Koromo_Copy.Interface.SemaphoreExtends.Default, dir, article);
                    Directory.CreateDirectory(dir);
                    if (unstable)
                    {
                        Interlocked.Decrement(ref unstable_request);
                    }
                    if (unstable && unstable_request != 0)
                    {
                        MainWindow.Instance.Fade_MiddlePopup(true, $"불안정한 작업 진행중...[{unstable_request}개]");
                    }
                    else
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup($"{imagelink.Count}개 이미지 다운로드 시작...");
                    }
                }
            });
        }
Beispiel #19
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            if (btn.Tag.ToString() == "DownloadAll")
            {
                try
                {
                    int count = 0;
                    ArticlePanel.Children.OfType <SearchSimpleElements>().ToList().ForEach(x =>
                    {
                        var ha     = x.Article as HitomiArticle;
                        ha.Artists = new string[] { Artist };
                        var prefix = HitomiCommon.MakeDownloadDirectory(ha);
                        Directory.CreateDirectory(prefix);
                        if (!ha.IsUnstable)
                        {
                            DownloadSpace.Instance.RequestDownload(x.Article.Title,
                                                                   ha.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y, ha.HasWebp[y], ha.HasWebp[y] || ha.Hashs[y].Length > 3 ? ha.Hashs[y] : "")).ToArray(),
                                                                   ha.ImagesLink.Select(y => Path.Combine(prefix, ha.HasWebp[y] ? y + ".webp" : y)).ToArray(),
                                                                   Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article);
                        }
                        else
                        {
                            DownloaderHelper.ProcessUnstable(ha.UnstableModel);
                        }
                        count++;
                    });
                    if (count > 0)
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}");
                    }
                    MainWindow.Instance.Activate();
                    MainWindow.Instance.FocusDownload();
                    Close();
                }
                catch (Exception ex)
                {
                    Koromo_Copy.Monitor.Instance.Push("[Artist Viewer] " + ex.Message);
                    MessageBox.Show($"{FindResource("msg_wait_fucking_loading")}", "Koromo Copy", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (btn.Tag.ToString() == "Download")
            {
                try
                {
                    int count = 0;
                    ArticlePanel.Children.OfType <SearchSimpleElements>().ToList().Where(x => x.Select).ToList().ForEach(x =>
                    {
                        var ha     = x.Article as HitomiArticle;
                        ha.Artists = new string[] { Artist };
                        var prefix = HitomiCommon.MakeDownloadDirectory(ha);
                        Directory.CreateDirectory(prefix);
                        if (!ha.IsUnstable)
                        {
                            DownloadSpace.Instance.RequestDownload(x.Article.Title,
                                                                   ha.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y, ha.HasWebp[y], ha.HasWebp[y] || ha.Hashs[y].Length > 3 ? ha.Hashs[y] : "")).ToArray(),
                                                                   ha.ImagesLink.Select(y => Path.Combine(prefix, ha.HasWebp[y] ? y + ".webp" : y)).ToArray(),
                                                                   Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article);
                        }
                        else
                        {
                            DownloaderHelper.ProcessUnstable(ha.UnstableModel);
                        }
                        count++;
                    });
                    if (count > 0)
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}");
                    }
                    MainWindow.Instance.Activate();
                    MainWindow.Instance.FocusDownload();
                }
                catch (Exception ex)
                {
                    Koromo_Copy.Monitor.Instance.Push("[Artist Viewer] " + ex.Message);
                    MessageBox.Show($"{FindResource("msg_wait_fucking_all_loading")}", "Koromo Copy", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Beispiel #20
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!Addr.Text.EndsWith(".txt"))
            {
                PB.IsIndeterminate = true;
                FileIndexor fi = new FileIndexor();
                await fi.ListingDirectoryAsync(Addr.Text);

                PB.IsIndeterminate = false;

                file_list = new List <string>();
                fi.Enumerate((string path, List <FileInfo> files) =>
                {
                    foreach (var iz in files)
                    {
                        if (Path.GetExtension(iz.Name) == ".zip")
                        {
                            file_list.Add(iz.FullName);
                        }
                    }
                });

                append(file_list.Count.ToString("#,#") + "개의 Zip 파일이 검색됨");
            }
            else
            {
                var lls = File.ReadAllLines(Addr.Text);

                var pp = new List <Tuple <string, string> >();

                var rx = new Regex(@"^\[(\d+)\]");
                foreach (var article in lls)
                {
                    var f = Path.GetFileNameWithoutExtension(article);
                    if (rx.Match(Path.GetFileNameWithoutExtension(article)).Success)
                    {
                        var id     = rx.Match(System.IO.Path.GetFileNameWithoutExtension(article)).Groups[1].Value;
                        var artist = Path.GetFileName(Path.GetDirectoryName(article));

                        pp.Add(new Tuple <string, string>(id, artist));
                    }
                    else
                    {
                        append("[NO MATCH] " + article);
                    }
                }

                var articles = new List <HitomiArticle>();

                foreach (var p in pp)
                {
                    var aaa = HitomiLegalize.GetMetadataFromMagic(p.Item1);

                    if (!aaa.HasValue)
                    {
                        append("[NOT FOUND] " + p.Item1);
                        continue;
                    }

                    var xxx = HitomiLegalize.MetadataToArticle(aaa.Value);
                    xxx.Artists = new string[] { p.Item2 };
                    articles.Add(xxx);
                }

                await Task.Run(() =>
                {
                    int cnt = 0;
                    foreach (var at in articles)
                    {
                        try
                        {
                            var url       = HitomiCommon.GetImagesLinkAddress(at.Magic);
                            var imgs      = HitomiParser.GetImageLink(NetCommon.DownloadString(url));
                            at.ImagesLink = imgs;
                        }
                        catch
                        {
                            append("[FAIL DOWNLOAD] " + at.Magic);
                        }

                        cnt++;

                        Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                       delegate
                        {
                            PB.Value = cnt / (double)articles.Count * 100;
                        }));
                    }

                    int count = 0;

                    foreach (var ha in articles)
                    {
                        if (ha.ImagesLink == null)
                        {
                            continue;
                        }
                        var prefix = HitomiCommon.MakeDownloadDirectory(ha);
                        Directory.CreateDirectory(prefix);
                        DownloadSpace.Instance.RequestDownload(ha.Title,
                                                               ha.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress(ha.Magic, y, ha.HasWebp[y], ha.HasWebp[y] || ha.Hashs[y].Length > 3 ? ha.Hashs[y] : "")).ToArray(),
                                                               ha.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(),
                                                               Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, ha);
                        count++;
                    }

                    Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                   delegate
                    {
                        if (count > 0)
                        {
                            MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}");
                        }
                        MainWindow.Instance.Activate();
                        MainWindow.Instance.FocusDownload();
                    }));
                });
            }
        }
Beispiel #21
0
 private void SearchElements_Loaded(object sender, EventArgs ex)
 {
     if (init)
     {
         return;
     }
     init = true;
     Task.Run(() =>
     {
         HitomiArticle ha = Article as HitomiArticle;
         try
         {
             ha.Thumbnail = HitomiCommon.HitomiThumbnail + HitomiParser.ParseGalleryBlock(Koromo_Copy.Net.NetCommon.DownloadString(
                                                                                              $"{HitomiCommon.HitomiGalleryBlock}{ha.Magic}.html")).Thumbnail;
             var info      = Koromo_Copy.Net.NetCommon.DownloadString(HitomiCommon.GetImagesLinkAddress(ha.Magic));
             ha.ImagesLink = HitomiParser.GetImageLink(info);
             ha.HasWebp    = HitomiParser.CheckHasWebp(info);
             ha.Hashs      = HitomiParser.GetHash(info);
         }
         catch
         {
             ha.IsUnstable = true;
             var har       = HCommander.GetArticleData(Convert.ToInt32(ha.Magic));
             if (!har.HasValue)
             {
                 Koromo_Copy.Console.Console.Instance.WriteErrorLine($"Cannot find '{ha.Magic}'! This item was not found in Hiyobi, Ex-Hentai, and Hitomi. Contact to the developer.\r\n" +
                                                                     "Run program as an administrator, or use a DPI program or VPN.");
                 return;
             }
             ha.UnstableModel = har.Value;
             ha.Thumbnail     = ha.UnstableModel.Thumbnail;
             ha.ImagesLink    = new List <string>();
         }
         Application.Current.Dispatcher.BeginInvoke(new Action(
                                                        delegate
         {
             try
             {
                 if (ha.IsUnstable && ha.UnstableModel.ArticleType == HArticleType.EXHentai)
                 {
                     var image = NetCommon.GetExHentaiClient().DownloadData(new Uri(ha.UnstableModel.Thumbnail));
                     using (var ms = new System.IO.MemoryStream(image))
                     {
                         BitmapImage.BeginInit();
                         if (Settings.Instance.Model.LowQualityImage)
                         {
                             BitmapImage.DecodePixelWidth = 100;
                         }
                         BitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                         BitmapImage.StreamSource = ms;
                         BitmapImage.EndInit();
                     }
                 }
                 else
                 {
                     BitmapImage.BeginInit();
                     BitmapImage.UriSource = new Uri(ha.Thumbnail);
                     if (Settings.Instance.Model.LowQualityImage)
                     {
                         BitmapImage.DecodePixelWidth = 100;
                     }
                     BitmapImage.EndInit();
                     BitmapImage.DownloadCompleted += B_DownloadCompleted;
                 }
                 if (!ha.IsUnstable)
                 {
                     Page.Text = ha.ImagesLink.Count + " Pages";
                 }
                 else
                 {
                     Page.Text = ha.UnstableModel.Length + " Pages";
                 }
                 Image.Source  = BitmapImage;
                 Image.Stretch = Stretch.Uniform;
                 Image.Width   = BitmapImage.Width * 200 / BitmapImage.Height;
             }
             catch (Exception e)
             {
                 Monitor.Instance.Push($"[Search Elements] isunstable={ha.IsUnstable} article_type={ha.UnstableModel}" +
                                       $" thumbnail={(ha.UnstableModel.Thumbnail ?? ha.Thumbnail)}" +
                                       $"\r\n{e.Message}\r\n{e.StackTrace}");
             }
         }));
     });
 }
Beispiel #22
0
        private void RecursiveVisit(TreeNode node, List <Regex> regex)
        {
            string match = "";

            if (regex.Any(x => {
                if (!x.Match(Path.GetFileNameWithoutExtension(node.Text)).Success)
                {
                    return(false);
                }
                match = x.Match(Path.GetFileNameWithoutExtension(node.Text)).Groups[1].Value;
                return(true);
            }))
            {
                metadatas.Add(new Tuple <string, string, HitomiMetadata?>(node.FullPath, match, HitomiCommon.GetMetadataFromMagic(match)));
                available_count += 1;
                if (!tgPVS.Checked)
                {
                    return;
                }
            }

            visit_count += 1;

            foreach (var cnode in node.Nodes.OfType <TreeNode>())
            {
                RecursiveVisit(cnode, regex);
            }
        }
        public HitomiAnalysisTagCount()
        {
            Dictionary <string, int> dic = new Dictionary <string, int>();

            foreach (var legal in from data in HitomiLog.Instance.GetEnumerator() where data.Tags != null from tag in data.Tags select HitomiCommon.LegalizeTag(tag))
            {
                if (dic.ContainsKey(legal))
                {
                    dic[legal]++;
                }
                else
                {
                    dic.Add(legal, 1);
                }
            }

            tag_count = dic.ToList();
            tag_count.Sort((a, b) => b.Value.CompareTo(a.Value));
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            switch ((sender as Button).Tag.ToString())
            {
            case "Preview":
                (new PreviewWindow(Article)).Show();
                break;

            case "Artist":
            {
                if (Article is HitomiArticle ha)
                {
                    if (ha.Artists != null)
                    {
                        (new ArtistViewerWindow(ha.Artists[0])).Show();
                    }
                }
            }
            break;

            case "Group":
            {
                if (Article is HitomiArticle ha)
                {
                    if (ha.Groups != null)
                    {
                        (new GroupViewerWindow(ha.Groups[0])).Show();
                    }
                }
            }
            break;

            case "":
            case "Hitomi":
            {
                if (Article is HitomiArticle ha)
                {
                    System.Diagnostics.Process.Start($"{HitomiCommon.HitomiAddress}galleries/{ha.Magic}.html");
                }
            }
            break;

            case "Exhentai":
            {
                if (Article is HitomiArticle ha)
                {
                    string result = ExHentaiTool.GetAddressFromMagicTitle(ha.Magic, ha.Title);
                    if (result != "")
                    {
                        System.Diagnostics.Process.Start(result);
                    }
                    else
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup("익헨 주소를 찾지 못했습니다 ㅠㅠ", false);
                    }
                }
            }
            break;

            case "Series":
            {
                if (Article is HitomiArticle ha)
                {
                    if (ha.Series != null)
                    {
                        (new FinderWindow($"series:{ha.Series[0].Replace(' ', '_')}")).Show();
                    }
                }
            }
            break;

            case "Character":
            {
                if (Article is HitomiArticle ha)
                {
                    if (ha.Characters != null)
                    {
                        (new FinderWindow($"character:{ha.Characters[0].Replace(' ', '_')}")).Show();
                    }
                }
            }
            break;

            case "Comment":
            {
                if (Article is HitomiArticle ha)
                {
                    string result = ExHentaiTool.GetAddressFromMagicTitle(ha.Magic, ha.Title);
                    if (result != "")
                    {
                        (new CommentWindow(result)).Show();
                    }
                    else
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup("익헨 주소를 찾지 못했습니다 ㅠㅠ", false);
                    }
                }
            }
            break;

            case "Download":
            {
                if (Article is HitomiArticle ha)
                {
                    var prefix = HitomiCommon.MakeDownloadDirectory(ha);
                    Directory.CreateDirectory(prefix);

                    if (!ha.IsUnstable)
                    {
                        DownloadSpace.Instance.RequestDownload(ha.Title,
                                                               ha.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress(ha.Magic, y)).ToArray(),
                                                               ha.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(),
                                                               Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, ha);
                    }
                    else
                    {
                        DownloaderHelper.ProcessUnstable(ha.UnstableModel);
                    }
                    MainWindow.Instance.FadeOut_MiddlePopup($"1개 항목 다운로드 시작...");
                    MainWindow.Instance.Activate();
                    MainWindow.Instance.FocusDownload();
                    Close();
                }
            }
            break;
            }
        }
 private void SearchElements_Loaded(object sender, EventArgs ex)
 {
     if (init)
     {
         return;
     }
     init = true;
     Task.Run(() =>
     {
         HitomiArticle ha = Article as HitomiArticle;
         try
         {
             ha.Thumbnail = HitomiCommon.HitomiThumbnail + HitomiParser.ParseGalleryBlock(Koromo_Copy.Net.NetCommon.DownloadString(
                                                                                              $"{HitomiCommon.HitomiGalleryBlock}{ha.Magic}.html")).Thumbnail;
             ha.ImagesLink = HitomiParser.GetImageLink(Koromo_Copy.Net.NetCommon.DownloadString(HitomiCommon.GetImagesLinkAddress(ha.Magic)));
         }
         catch
         {
             ha.IsUnstable = true;
             var har       = HCommander.GetArticleData(Convert.ToInt32(ha.Magic));
             if (!har.HasValue)
             {
                 MessageBox.Show($"{ha.Magic}를 찾을 수 없습니다. 이 항목은 히요비, 이헨, 익헨 어디에도 없었습니다. 프로그램 제작자에게 문의하세요.", "Koromo copy", MessageBoxButton.OK, MessageBoxImage.Error);
                 return;
             }
             ha.UnstableModel = har.Value;
             ha.Thumbnail     = ha.UnstableModel.Thumbnail;
             ha.ImagesLink    = new List <string>();
         }
         Application.Current.Dispatcher.BeginInvoke(new Action(
                                                        delegate
         {
             if (ha.IsUnstable && ha.UnstableModel.ArticleType == HArticleType.EXHentai)
             {
                 var image = NetCommon.GetExHentaiClient().DownloadData(new Uri(ha.UnstableModel.Thumbnail));
                 using (var ms = new System.IO.MemoryStream(image))
                 {
                     BitmapImage.BeginInit();
                     if (Settings.Instance.Model.LowQualityImage)
                     {
                         BitmapImage.DecodePixelWidth = 100;
                     }
                     BitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                     BitmapImage.StreamSource = ms;
                     BitmapImage.EndInit();
                 }
             }
             else
             {
                 BitmapImage.BeginInit();
                 BitmapImage.UriSource = new Uri(ha.Thumbnail);
                 if (Settings.Instance.Model.LowQualityImage)
                 {
                     BitmapImage.DecodePixelWidth = 100;
                 }
                 BitmapImage.EndInit();
                 BitmapImage.DownloadCompleted += B_DownloadCompleted;
             }
             Page.Text     = ha.ImagesLink.Count + " Pages";
             Image.Source  = BitmapImage;
             Image.Stretch = Stretch.Uniform;
             Image.Width   = BitmapImage.Width * 200 / BitmapImage.Height;
         }));
     });
 }
Beispiel #26
0
        private void CustomArtistRecommendation_Load(object sender, EventArgs e)
        {
            ColumnSorter.InitListView(lvCustomTag);
            ColumnSorter.InitListView(lvArtists);

            Dictionary <string, int> tags_map = new Dictionary <string, int>();

            if (!HitomiAnalysis.Instance.UserDefined)
            {
                foreach (var log in HitomiLog.Instance.GetEnumerator().Where(log => log.Tags != null))
                {
                    foreach (var tag in log.Tags)
                    {
                        if (HitomiSetting.Instance.GetModel().UsingOnlyFMTagsOnAnalysis&&
                            !tag.StartsWith("female:") && !tag.StartsWith("male:"))
                        {
                            continue;
                        }
                        if (tags_map.ContainsKey(HitomiCommon.LegalizeTag(tag)))
                        {
                            tags_map[HitomiCommon.LegalizeTag(tag)] += 1;
                        }
                        else
                        {
                            tags_map.Add(HitomiCommon.LegalizeTag(tag), 1);
                        }
                    }
                }
            }

            var list = tags_map.ToList();

            if (HitomiAnalysis.Instance.UserDefined)
            {
                list = HitomiAnalysis.Instance.CustomAnalysis.Select(x => new KeyValuePair <string, int>(x.Item1, x.Item2)).ToList();
            }
            list.Sort((a, b) => b.Value.CompareTo(a.Value));

            List <ListViewItem> lvil = new List <ListViewItem>();

            foreach (var item in list)
            {
                lvil.Add(new ListViewItem(new string[] { item.Key, item.Value.ToString() }));
            }
            lvCustomTag.Items.Clear();
            lvCustomTag.Items.AddRange(lvil.ToArray());

            lvil.Clear();
            var list2 = HitomiAnalysis.Instance.Rank.ToList();

            for (int i = 0; i < list2.Count; i++)
            {
                lvil.Add(new ListViewItem(new string[] {
                    (i + 1).ToString(),
                    list2[i].Item1,
                    HitomiAnalysis.Instance.ArtistCount[list2[i].Item1].ToString(),
                    list2[i].Item2.ToString(),
                    list2[i].Item3
                }));
            }
            lvArtists.Items.Clear();
            lvArtists.Items.AddRange(lvil.ToArray());
        }