コード例 #1
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));
         }));
コード例 #2
0
        /// <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'.");
            }
        }
コード例 #3
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")}");
                    }
                }
            }
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
        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}개 이미지 다운로드 시작...");
                    }
                }
            });
        }
コード例 #6
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);
                }
            }
        }
コード例 #7
0
        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;
            }
        }
コード例 #8
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();
                    }));
                });
            }
        }