Esempio n. 1
0
        public SeleniumWrapper()
        {
            var driver_path     = Path.Combine(Directory.GetCurrentDirectory(), "chromedriver.exe");
            var driver_zip_path = Path.Combine(Directory.GetCurrentDirectory(), "chromedriver.zip");

            if (!File.Exists(driver_path))
            {
                NetCommon.GetDefaultClient().DownloadFile("https://chromedriver.storage.googleapis.com/72.0.3626.7/chromedriver_win32.zip", driver_zip_path);

                var zip = ZipFile.Open(driver_zip_path, ZipArchiveMode.Read);
                zip.Entries[0].ExtractToFile(driver_path);
                zip.Dispose();
                File.Delete(driver_zip_path);
            }
            var chromeDriverService = ChromeDriverService.CreateDefaultService($"{Directory.GetCurrentDirectory()}");

            chromeDriverService.HideCommandPromptWindow = true;
            var chrome = new ChromeOptions();

            chrome.AddArgument("--headless");
            driver = new ChromeDriver(chromeDriverService, chrome);
        }
Esempio n. 2
0
        public void OnHit(HitData hitData, bool pvp)
        {
            // setup position.
            Vector3 position = Vector3.zero;
            float   rotate   = 0;

            NetCommon.Decode(hitData.HitX, hitData.HitY, hitData.HitZ, hitData.HitDir, ref position, ref rotate);

            // if the pos is too large than [xxx = 1.0f] ignore this hit data
            // to avoid flash moving...
            Vector3 offset = position - mPosition;

            if (pvp && offset.sqrMagnitude > 1.0f)
            {
                return;
            }

            Move(offset);
            SetOrientation(rotate);

            // avoid replay action.
            if (hitData.HitAction != byte.MaxValue && hitData.HitAction != mActionStatus.ActiveAction.ActionCache)
            {
                mActionStatus.ChangeAction(hitData.HitAction, 0);
            }

            // setup straight time.
            mActionStatus.SetStraightTime(hitData.StraightTime, true);

            // setup lash time.
            if (hitData.LashTime > 0)
            {
                mActionStatus.SetLashVelocity(
                    hitData.LashX * 0.01f,
                    hitData.LashY * 0.01f,
                    hitData.LashZ * 0.01f,
                    hitData.LashTime);
            }
        }
Esempio n. 3
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)));
            }
            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'.");
            }
        }
Esempio n. 4
0
        public static void ProcessMangashowme(string url)
        {
            Task.Run(() =>
            {
                MainWindow.Instance.Fade_MiddlePopup(true, "접속중...");
                var html     = NetCommon.DownloadString(url);
                var articles = MangashowmeParser.ParseSeries(html);
                var title    = MangashowmeParser.ParseTitle(html);

                MainWindow.Instance.ModifyText_MiddlePopup($"가져오는중...[0/{articles.Count}]");
                for (int i = 0; i < articles.Count; i++)
                {
                    articles[i].ImagesLink = MangashowmeParser.ParseImages(NetCommon.DownloadString(MangashowmeCommon.GetDownloadMangaImageAddress(articles[i].ArticleLink)));
                    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), "mangashowme"), 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($"mangashow-me: {article.Title}",
                                                           article.ImagesLink.ToArray(),
                                                           article.ImagesLink.Select(x => Path.Combine(dir, HttpUtility.UrlDecode(HttpUtility.UrlDecode(x.Split('/').Last())))).ToArray(),
                                                           se,
                                                           dir + '\\',
                                                           null
                                                           );
                }

                MainWindow.Instance.FadeOut_MiddlePopup($"{count}개({articles.Count} 작품) 항목 다운로드 시작...");
            });
        }
        /// <summary>
        /// 페이지 주소 정보를 출력합니다.
        /// </summary>
        /// <param name="args"></param>
        static void ProcessPaging(string[] args)
        {
            //string url = "https://exhentai.org/?inline_set=dm_l&page=" + args[0];
            //string url2 = "https://exhentai.org/?page=1&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&f_search=language%3Akorean&f_apply=Apply+Filter&inline_set=dm_l";

            var result = new List <EHentaiResultArticle>();

            //var urlx = $"https://exhentai.org/?page=0&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&&f_cats=0&f_sname=on&f_stags=on&f_sh=on&advsearch=1&f_srdd=2&f_sname=on&f_stags=on&f_sdesc=on&f_sh=on&inline_set=dm_e";
            //NetCommon.DownloadExHentaiString(urlx);

            for (int i = 0; i < 20; i++)
            {
                try
                {
                    //var url = $"https://exhentai.org/?page={i}&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&&f_cats=0&f_search=lang:korean&f_sname=on&f_stags=on&f_sh=on&advsearch=1&f_srdd=2&f_sname=on&f_stags=on&f_sdesc=on&f_sh=on&inline_set=dm_e";
                    //var url = $"https://exhentai.org/?page={i}&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&f_search=language%3Akorean&f_apply=Apply+Filter&inline_set=dm_e";
                    //var url2 = $"https://exhentai.org/?page={i}&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&advsearch=1&f_search=language%3Akorean&f_srdd=2&f_sname=on&f_stags=on&f_sdesc=on&f_sh=on&f_apply=Apply+Filter";
                    //           https://exhentai.org/?page=1&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&advsearch=1&f_srdd=2&f_sname=on&f_stags=on&f_sh=on&f_apply=Apply+Filter
                    var url3 = $"https://exhentai.org/?page={i}&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&&f_cats=0&f_sname=on&f_stags=on&f_sh=on&advsearch=1&f_srdd=2&f_sname=on&f_stags=on&f_sdesc=on&f_sh=on";
                    var html = NetCommon.DownloadExHentaiString(url3);
                    //result.AddRange(ExHentaiParser.ParseResultPageExtendedListView(html));
                    File.WriteAllText($"exhentai-page/exhentai-{i}.html", html);
                    Monitor.Instance.Push($"[Paging] {i+1}/1457");
                }
                catch (Exception e)
                {
                    Console.Instance.WriteErrorLine($"[Error] {i} {e.Message}");
                }
                Thread.Sleep(100);
            }

            string json = JsonConvert.SerializeObject(result, Formatting.Indented);

            using (var fs = new StreamWriter(new FileStream("exh.json", FileMode.Create, FileAccess.Write)))
            {
                fs.Write(json);
            }
        }
Esempio n. 6
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 => { }, Enumerable.Range(0, pages.Length).OfType <object>().ToList()).Select(x => new Tuple <object, string[]> (x.Item1, ExHentaiParser.GetImagesUri(x.Item2))).ToList();
         pages_html.Sort((x, y) => ((int)x.Item1).CompareTo((int)y.Item1));
         List <string> pages_all = new List <string>();
         pages_html.ToList().ForEach(x => pages_all.AddRange(x.Item2));
         var imagelink      = EmiliaJobEXH.Instance.AddJob(pages_all, x => { }, Enumerable.Range(0, pages.Length).OfType <object>().ToList()).Select(x => new Tuple <object, string>(x.Item1, ExHentaiParser.GetImagesAddress(x.Item2))).ToList();
         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);
         imagelink.Sort((x, y) => ((int)x.Item1).CompareTo((int)y.Item1));
         article.ImagesLink = imagelink.Select(x => x.Item2).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.Select(x => x.Item2).ToArray(),
                                                imagelink.Select(y => Path.Combine(dir, y.Item2.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()}개 이미지 다운로드 시작...");
         }
     });
 }
Esempio n. 7
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}개 이미지 다운로드 시작...");
                    }
                }
            });
        }
Esempio n. 8
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}");
             }
         }));
     });
 }
        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);
                    }
                }));
            });
Esempio n. 10
0
        static void ProcessFullParse(string[] args, bool rem, string[] title, string[] nick,
                                     string[] ip, string[] id, bool login, bool fix)
        {
            using (var progressBar = new Console.ConsoleProgressBar())
            {
                Console.Instance.WriteLine("Parse gallery...");

                var rstarts = Convert.ToInt32(args[1]);
                var starts  = Convert.ToInt32(args[1]);
                var ends    = Convert.ToInt32(args[2]);

                LoadGalleryList();

                bool is_minorg = minor_galleries.ContainsValue(args[0]);
                var  articles  = new List <DCPageArticle>();

                //
                //  Parse Gallery
                //
                for (; starts <= ends; starts++)
                {
                    var url = "";
                    if (is_minorg)
                    {
                        url = $"https://gall.dcinside.com/mgallery/board/lists/?id={args[0]}&page={starts}";
                    }
                    else
                    {
                        url = $"https://gall.dcinside.com/board/lists/?id={args[0]}&page={starts}";
                    }

                    if (rem)
                    {
                        url += "&exception_mode=recommend";
                    }

                    var client = NetCommon.GetDefaultClient();
                    if (PHPSESSID != "")
                    {
                        client.Headers.Add(System.Net.HttpRequestHeader.Cookie, "PHPSESSID=" + PHPSESSID);
                    }
                    var       html = client.DownloadString(url);
                    DCGallery gall = null;

                    if (is_minorg)
                    {
                        gall = DCParser.ParseMinorGallery(html);
                    }
                    else
                    {
                        gall = DCParser.ParseGallery(html);
                    }

                    foreach (var article in gall.articles)
                    {
                        if (title != null && !article.title.Contains(title[0]))
                        {
                            continue;
                        }
                        if (nick != null && !article.nick.Contains(nick[0]))
                        {
                            continue;
                        }
                        if (ip != null && !article.ip.Contains(ip[0]))
                        {
                            continue;
                        }
                        if (id != null && !article.uid.Contains(id[0]))
                        {
                            continue;
                        }
                        if (login && !article.islogined)
                        {
                            continue;
                        }
                        if (fix && !article.isfixed)
                        {
                            continue;
                        }

                        //Console.Instance.Write(Monitor.SerializeObject(article));
                        //Console.Instance.WriteLine(",");
                        articles.Add(article);
                    }

                    progressBar.SetProgress((((ends - rstarts + 1) - (ends - starts)) / (float)(ends - rstarts + 1)) * 100);

                    Thread.Sleep(3000);
                }

                Console.Instance.WriteLine("Parse articles...");
                int acnt      = 0;
                var _articles = new List <DCArticle>();

                //
                //  Parse Articles
                //
                foreach (var article in articles)
                {
                    var url = "";
                    if (is_minorg)
                    {
                        url = $"https://gall.dcinside.com/mgallery/board/view/?id={args[0]}&no={article.no}";
                    }
                    else
                    {
                        url = $"https://gall.dcinside.com/board/view/?id={args[0]}&no={article.no}";
                    }

                    var client = NetCommon.GetDefaultClient();
                    if (PHPSESSID != "")
                    {
                        client.Headers.Add(System.Net.HttpRequestHeader.Cookie, "PHPSESSID=" + PHPSESSID);
                    }
                    var html     = client.DownloadString(url);
                    var _article = DCParser.ParseBoardView(html, is_minorg);

                    _articles.Add(_article);

                    acnt++;
                    progressBar.SetProgress(((acnt) / (float)(articles.Count)) * 100);

                    Thread.Sleep(3000);
                }

                var info = new List <Tuple <DCArticle, List <DCComment> > >();

                if (ESNO == "")
                {
                    ESNO = _articles[0].ESNO;
                }

                int ccnt = 0;

                //
                //  Parse Comments
                //
                foreach (var article in _articles)
                {
                    var cc       = new List <DCComment>();
                    var comments = DCCommon.GetComments(new DCArticle {
                        OriginalGalleryName = article.OriginalGalleryName, Id = article.Id, ESNO = article.ESNO
                    }, "1");

                    Thread.Sleep(2000);

                    cc.Add(comments);
                    int tcount = comments.total_cnt;
                    int count  = 100;
                    for (int i = 2; count < tcount; count += 100)
                    {
                        comments = DCCommon.GetComments(new DCArticle {
                            OriginalGalleryName = args[0], Id = args[1], ESNO = ESNO
                        }, i.ToString());
                        if (comments.comment_cnt == 0)
                        {
                            break;
                        }
                        count += comments.comment_cnt;
                        cc.Add(comments);
                        Thread.Sleep(2000);
                    }

                    info.Add(new Tuple <DCArticle, List <DCComment> >(article, cc));

                    ccnt++;
                    progressBar.SetProgress(((ccnt) / (float)(_articles.Count)) * 100);
                }

                var result = new Tuple <List <DCPageArticle>, List <Tuple <DCArticle, List <DCComment> > > >(articles, info);
                File.WriteAllText($"dc-{args[0]}-{args[1]}-{args[2]}-{DateTime.Now.Ticks}.txt", Monitor.SerializeObject(result));
            }
        }
 public void Stop()
 {
     NetCommon.PrintLog();
 }
Esempio n. 12
0
        private void PrepareSync()
        {
            string top_html     = "";
            string inner_counts = "";

            var wc = manager.GetWebClient();

            try
            {
                if (wrapper == null)
                {
                    if (wc != null)
                    {
                        top_html = wc.DownloadString(url);
                    }
                    else
                    {
                        top_html = NetCommon.DownloadString(url);
                    }
                }

                switch (manager.Type)
                {
                case ManagerType.SingleSeriesMultipleArticles:
                {
                    if (wrapper == null)
                    {
                        series = manager.ParseSeries(top_html);
                    }
                    else
                    {
                        wrapper.Navigate(url);
                        try { wrapper.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { }

                        series = manager.ParseSeries(wrapper.GetHtml());
                    }
                    title        = series.Title;
                    thumbnail    = series.Thumbnail;
                    inner_counts = $"작품 {series.Articles.Count}개";

                    if (series_log.Archive.Length < series.Articles.Count)
                    {
                        require_sync = true;
                        Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                       delegate
                            {
                                SyncPanel.Visibility        = Visibility.Collapsed;
                                SyncButton.IsEnabled        = true;
                                RequireSyncPanel.Visibility = Visibility.Visible;
                                SyncText.Text = $"{series.Articles.Count - series_log.Archive.Length}개의 새로운 항목";
                            }));
                    }
                }
                break;
                }

                if (!require_sync)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                   delegate
                    {
                        SyncPanel.Visibility = Visibility.Collapsed;
                    }));
                }
            }
            catch (Exception e)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(
                                                               delegate
                {
                    SyncPanel.Visibility        = Visibility.Collapsed;
                    RequireSyncPanel.Visibility = Visibility.Visible;
                    SyncText.Text = $"동기화를 계속 진행할 수 없음\r\n" + e.Message;
                }));
            }
        }
Esempio n. 13
0
        private void StartFirstDownloads()
        {
            DispatchInformation dispatch_info = new DispatchInformation();

            dispatch_info.DownloadSize    = DownloadSize;
            dispatch_info.DownloadStatus  = DownloadStatus;
            dispatch_info.DownloadRetry   = DownloadRetry;
            dispatch_info.CompleteFile    = CompleteFile;
            dispatch_info.CompleteArticle = CompleteArticle;
            dispatch_info.CompleteSeries  = CompleteSeries;
            dispatch_info.ErrorOccured    = ErrorOcurred;

            Application.Current.Dispatcher.BeginInvoke(new Action(
                                                           delegate
            {
                CollectStatusPanel.Visibility = Visibility.Visible;
                DownloadState.Text            = $"수집 중";
            }));

            switch (manager.EngineType)
            {
            case ManagerEngineType.None:
            {
                //
                // Collect 시작
                //

                int file_count = 0;

                if (manager.Type == ManagerType.SingleArticleMultipleImages)
                {
                    article.ImagesLink = manager.ParseImages(NetCommon.DownloadString(article.Archive), article);
                }
                else if (manager.Type == ManagerType.SingleSeriesMultipleArticles)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                   delegate
                        {
                            ProgressText.Text = $"가져오는 중... [0/{series.Articles.Count}]";
                        }));

                    var result = EmiliaJob.Instance.AddJob(series.Archive.ToList(),
                                                           (count) =>
                        {
                            Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                           delegate
                            {
                                ProgressText.Text = $"가져오는 중...[{count}/{series.Articles.Count}]";
                            }));
                        });

                    for (int i = 0; i < series.Articles.Count; i++)
                    {
                        series.Articles[i].ImagesLink = manager.ParseImages(result[i], series.Articles[i]);
                        file_count += series.Articles[i].ImagesLink.Count;

                        int k = i;
                        Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                       delegate
                            {
                                //ProgressText.Text = $"가져오는 중... [{i}/{series.Articles.Count}] (파일 {file_count}개)";
                                if (k == 0 && string.IsNullOrEmpty(series.Thumbnail))
                                {
                                    LoadThumbnail(thumbnail = series.Articles[0].ImagesLink[0]);
                                }
                            }));
                    }
                }

                Application.Current.Dispatcher.BeginInvoke(new Action(
                                                               delegate
                    {
                        CollectStatusPanel.Visibility  = Visibility.Collapsed;
                        DownloadStatusPanel.Visibility = Visibility.Visible;
                        Progress.Maximum    = file_count;
                        ProgressStatus.Text = $"[0/{file_count}]";
                    }));

                //
                // 다운로드 시작
                //

                EmiliaSeriesSegment series_seg = new EmiliaSeriesSegment();
                series_seg.Index = EmiliaDispatcher.Instance.GetSeriesIndex();
                series_seg.Title = series.Title;
                download_folder  = series_seg.Path = Path.Combine(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), manager.Name.Trim()), DeleteInvalid(series.Title));

                List <EmiliaArticleSegment> article_segs = new List <EmiliaArticleSegment>();
                HashSet <string>            folder_names = new HashSet <string>();
                int ov = 0;
                for (int i = 0; i < series.Articles.Count; i++)
                {
                    EmiliaArticleSegment article_seg = new EmiliaArticleSegment();
                    article_seg.Index = i;
                    article_seg.Name  = series.Articles[i].Title;

                    string folder_name = DeleteInvalid(series.Articles[i].Title).Trim();
                    if (!folder_names.Contains(folder_name))
                    {
                        article_seg.FolderName = DeleteInvalid(series.Articles[i].Title).Trim();
                    }
                    else
                    {
                        article_seg.FolderName = DeleteInvalid(series.Articles[i].Title).Trim() + $" [OV{++ov}]";
                    }
                    folder_names.Add(article_seg.FolderName);
                    article_seg.SereisIndex = series_seg.Index;

                    Directory.CreateDirectory(Path.Combine(series_seg.Path, article_seg.FolderName));

                    List <EmiliaFileSegment> file_segs  = new List <EmiliaFileSegment>();
                    List <string>            file_names = manager.GetDownloadFileNames(series.Articles[i]);
                    if (!Settings.Instance.Model.DownloadWithRawFileName)
                    {
                        file_names = PathFilenameSorter.SortOnlyFilename(file_names.ToArray()).ToList();
                    }
                    for (int j = 0; j < series.Articles[i].ImagesLink.Count; j++)
                    {
                        EmiliaFileSegment file_seg = new EmiliaFileSegment();
                        file_seg.Index        = j;
                        file_seg.ArticleIndex = i;
                        file_seg.SeriesIndex  = series_seg.Index;
                        file_seg.FileName     = file_names[j];
                        file_seg.Url          = series.Articles[i].ImagesLink[j];

                        SemaphoreExtends se = SemaphoreExtends.MakeDefault();
                        se.Referer = url;

                        file_seg.Extends = se;
                        file_segs.Add(file_seg);
                    }

                    article_seg.Files = file_segs;
                    article_segs.Add(article_seg);
                }
                series_seg.Articles = article_segs;

                EmiliaDispatcher.Instance.Add(series_seg, dispatch_info);
            }
            break;

            case ManagerEngineType.UsingDriver:
            {
                int file_count = 0;

                if (manager.Type == ManagerType.SingleArticleMultipleImages)
                {
                    wrapper.Navigate(article.Archive);
                    try { wrapper.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { }
                    article.ImagesLink = manager.ParseImages(wrapper.GetHtml(), article);
                }
                else if (manager.Type == ManagerType.SingleSeriesMultipleArticles)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                   delegate
                        {
                            ProgressText.Text = $"가져오는 중... [0/{series.Articles.Count}]";
                        }));

                    for (int i = 0; i < series.Articles.Count; i++)
                    {
                        wrapper.Navigate(series.Archive[i]);
                        try { wrapper.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { }
                        series.Articles[i].ImagesLink = manager.ParseImages(wrapper.GetHtml(), series.Articles[i]);
                        file_count += series.Articles[i].ImagesLink.Count;

                        int k = i;
                        Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                       delegate
                            {
                                ProgressText.Text = $"가져오는 중... [{i}/{series.Articles.Count}] (파일 {file_count}개)";
                                if (k == 0 && string.IsNullOrEmpty(series.Thumbnail))
                                {
                                    LoadThumbnail(thumbnail = series.Articles[0].ImagesLink[0]);
                                }
                            }));
                    }
                }

                Application.Current.Dispatcher.BeginInvoke(new Action(
                                                               delegate
                    {
                        CollectStatusPanel.Visibility  = Visibility.Collapsed;
                        DownloadStatusPanel.Visibility = Visibility.Visible;
                        Progress.Maximum    = file_count;
                        ProgressStatus.Text = $"[0/{file_count}]";
                    }));

                //
                // 다운로드 시작
                //

                EmiliaSeriesSegment series_seg = new EmiliaSeriesSegment();
                series_seg.Index = EmiliaDispatcher.Instance.GetSeriesIndex();
                series_seg.Title = series.Title;
                download_folder  = series_seg.Path = Path.Combine(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), manager.Name.Trim()), DeleteInvalid(series.Title));

                List <EmiliaArticleSegment> article_segs = new List <EmiliaArticleSegment>();
                for (int i = 0; i < series.Articles.Count; i++)
                {
                    EmiliaArticleSegment article_seg = new EmiliaArticleSegment();
                    article_seg.Index       = i;
                    article_seg.Name        = series.Articles[i].Title;
                    article_seg.FolderName  = DeleteInvalid(series.Articles[i].Title).Trim();
                    article_seg.SereisIndex = series_seg.Index;

                    Directory.CreateDirectory(Path.Combine(series_seg.Path, article_seg.FolderName));

                    List <EmiliaFileSegment> file_segs  = new List <EmiliaFileSegment>();
                    List <string>            file_names = manager.GetDownloadFileNames(series.Articles[i]);
                    if (!Settings.Instance.Model.DownloadWithRawFileName)
                    {
                        file_names = PathFilenameSorter.SortOnlyFilename(file_names.ToArray()).ToList();
                    }
                    for (int j = 0; j < series.Articles[i].ImagesLink.Count; j++)
                    {
                        EmiliaFileSegment file_seg = new EmiliaFileSegment();
                        file_seg.Index        = j;
                        file_seg.ArticleIndex = i;
                        file_seg.SeriesIndex  = series_seg.Index;
                        file_seg.FileName     = file_names[j];
                        file_seg.Url          = series.Articles[i].ImagesLink[j];

                        SemaphoreExtends se = SemaphoreExtends.MakeDefault();
                        se.Referer = url;

                        file_seg.Extends = se;
                        file_segs.Add(file_seg);
                    }

                    article_seg.Files = file_segs;
                    article_segs.Add(article_seg);
                }
                series_seg.Articles = article_segs;

                EmiliaDispatcher.Instance.Add(series_seg, dispatch_info);
            }
            break;
            }

            Application.Current.Dispatcher.BeginInvoke(new Action(
                                                           delegate
            {
                DownloadState.Text = $"대기 중";
            }));
        }
Esempio n. 14
0
        private void SeriesManagerElements_Loaded(object sender, RoutedEventArgs e)
        {
            Task.Run(() =>
            {
                if (!string.IsNullOrEmpty(url))
                {
                    manager = SeriesInfo.Instance.SelectManager(url);

                    if (manager == null)
                    {
                        Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                       delegate
                        {
                            Title.Foreground = Brushes.Red;
                            Title.Text       = "오류 - 만족하는 URL 유형을 찾을 수 없습니다.\r\n옳바른 URL인지 확인해주세요.\r\nURL: " + url;
                            CollectStatusPanel.Visibility = Visibility.Collapsed;
                            init_error = true;
                        }));
                        return;
                    }

                    if (manager.EngineType == ManagerEngineType.UsingDriver)
                    {
                        wrapper = new SeleniumWrapper();
                    }

                    string top_html     = "";
                    string inner_counts = "";

                    var wc = manager.GetWebClient();

                    if (wrapper == null)
                    {
                        if (wc != null)
                        {
                            top_html = wc.DownloadString(url);
                        }
                        else
                        {
                            top_html = NetCommon.DownloadString(url);
                        }
                    }

                    switch (manager.Type)
                    {
                    case ManagerType.SingleArticleSingleImage:
                        {
                        }
                        break;

                    case ManagerType.SingleArticleSingleMovie:
                        {
                        }
                        break;

                    case ManagerType.SingleArticleMultipleImages:
                        {
                            if (wrapper == null)
                            {
                                article = manager.ParseArticle(top_html);
                            }
                            else
                            {
                                wrapper.Navigate(url);
                                try { wrapper.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { }

                                article = manager.ParseArticle(wrapper.GetHtml());
                            }
                            title        = article.Title;
                            thumbnail    = article.Thumbnail;
                            inner_counts = $"사진 {article.ImagesLink.Count}장";
                        }
                        break;

                    case ManagerType.SingleSeriesMultipleArticles:
                        {
                            if (wrapper == null)
                            {
                                series = manager.ParseSeries(top_html);
                            }
                            else
                            {
                                wrapper.Navigate(url);
                                try { wrapper.ClickXPath("//a[@class='maia-button maia-button-primary']"); } catch { }

                                series = manager.ParseSeries(wrapper.GetHtml());
                            }
                            title        = series.Title;
                            thumbnail    = series.Thumbnail;
                            inner_counts = $"작품 {series.Articles.Count}개";
                        }
                        break;
                    }

                    Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                   delegate
                    {
                        if (!string.IsNullOrEmpty(thumbnail))
                        {
                            LoadThumbnail(thumbnail);
                        }

                        Title.Text           = title;
                        SiteName.Text        = manager.Name;
                        LatestSyncDate.Text  = MakeSyncDate(new TimeSpan(0, 0, 0, 0));
                        InnerSitesCount.Text = inner_counts;
                        DownloadState.Text   = "다운로드 중";
                    }));

                    Task.Run(() => StartFirstDownloads());
                }
            });
        }
Esempio n. 15
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();
                    }));
                });
            }
        }
Esempio n. 16
0
        public static List <ChromeDevtoolsListElement> GetDebuggeeList()
        {
            var list = NetCommon.DownloadString($"http://localhost:{Port}/json/list?t=" + GetTime());

            return(JsonConvert.DeserializeObject <List <ChromeDevtoolsListElement> >(list));
        }
Esempio n. 17
0
        static void ProcessParseGallery(string[] args, bool rem, string[] title, string[] nick,
                                        string[] ip, string[] id, bool login, bool fix)
        {
            var starts = Convert.ToInt32(args[1]);
            var ends   = Convert.ToInt32(args[2]);

            LoadGalleryList();

            bool is_minorg = minor_galleries.ContainsValue(args[0]);

            for (; starts <= ends; starts++)
            {
                var url = "";
                if (is_minorg)
                {
                    url = $"https://gall.dcinside.com/mgallery/board/lists/?id={args[0]}&page={starts}";
                }
                else
                {
                    url = $"https://gall.dcinside.com/board/lists/?id={args[0]}&page={starts}";
                }

                if (rem)
                {
                    url += "&exception_mode=recommend";
                }

                var client = NetCommon.GetDefaultClient();
                if (PHPSESSID != "")
                {
                    client.Headers.Add(System.Net.HttpRequestHeader.Cookie, "PHPSESSID=" + PHPSESSID);
                }
                var       html = client.DownloadString(url);
                DCGallery gall = null;

                if (is_minorg)
                {
                    gall = DCParser.ParseMinorGallery(html);
                }
                else
                {
                    gall = DCParser.ParseGallery(html);
                }

                foreach (var article in gall.articles)
                {
                    if (title != null && !article.title.Contains(title[0]))
                    {
                        continue;
                    }
                    if (nick != null && !article.nick.Contains(nick[0]))
                    {
                        continue;
                    }
                    if (ip != null && !article.ip.Contains(ip[0]))
                    {
                        continue;
                    }
                    if (id != null && !article.uid.Contains(id[0]))
                    {
                        continue;
                    }
                    if (login && !article.islogined)
                    {
                        continue;
                    }
                    if (fix && !article.isfixed)
                    {
                        continue;
                    }

                    Console.Instance.Write(Monitor.SerializeObject(article));
                    Console.Instance.WriteLine(",");
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 각종 기능을 테스트합니다.
        /// </summary>
        /// <param name="args"></param>
        static void ProcessTest(string[] args)
        {
            switch (args[0].ToInt32())
            {
            //
            //  Save and beautify metadatas
            //
            case 0:
            {
                var hiddendata = JsonConvert.DeserializeObject <List <HitomiArticle> >(File.ReadAllText(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "hiddendata.json")));
                Func <HitomiArticle, NHitomiArticle> r2n = (ha) =>
                {
                    return(new NHitomiArticle
                        {
                            Artists = ha.Artists,
                            Characters = ha.Characters,
                            Groups = ha.Groups,
                            Language = ha.Language,
                            Tags = ha.Tags,
                            Type = ha.Type,
                            DateTime = ha.DateTime,
                            Thumbnail = ha.Thumbnail,
                            Magic = ha.Magic,
                            Title = ha.Title
                        });
                };

                var jj   = hiddendata.Select(x => r2n(x));
                var json = JsonConvert.SerializeObject(jj, Formatting.Indented);
                using (var fs = new StreamWriter(new FileStream("hiddendata_beautify.json", FileMode.Create, FileAccess.Write)))
                {
                    fs.Write(json);
                }

                var json2 = JsonConvert.SerializeObject(jj, Formatting.None);
                using (var fs = new StreamWriter(new FileStream("hiddendata_nonbeautify.json", FileMode.Create, FileAccess.Write)))
                {
                    var bytes = json2.Zip();
                    fs.BaseStream.Write(json2.Zip(), 0, bytes.Length);
                }
            }
            break;

            //
            //  Load metadatas
            //
            case 1:
            {
                var bytes = File.ReadAllBytes("hiddendata_nonbeautify.json");
                var json  = JsonConvert.DeserializeObject <List <NHitomiArticle> >(bytes.Unzip());
                Console.Instance.Write($"{json.Count}");
            }
            break;

            case 2:
            {
                var str = File.ReadAllText("hiddendata.json");
                File.WriteAllBytes("hiddendata.compress", str.Zip());
            }
            break;

            case 3:
            {
                var str = File.ReadAllText("metadata.json");
                File.WriteAllBytes("metadata.compress", str.Zip());
            }
            break;

            case 4:
            {
                var str = JsonConvert.DeserializeObject <List <HitomiArticle> >(File.ReadAllText("hiddendata.json"));
                using (var fs = new StreamWriter(new FileStream("hiddendata.json", FileMode.Create, FileAccess.Write)))
                {
                    fs.Write(JsonConvert.SerializeObject(str, Formatting.None));
                }
            }
            break;

            case 5:
            {
                var bytes = File.ReadAllBytes("metadata.compress");
                File.WriteAllText("metadata.json", bytes.Unzip());
            }
            break;

            case 6:
            {
                var bytes = File.ReadAllBytes("hiddendata.compress");
                File.WriteAllText("hiddendata.json", bytes.Unzip());
            }
            break;

            case 7:
            {
                HitomiExplore.exploreNullSpace().ForEach(x => Console.Instance.WriteLine($"{x.Item1} {x.Item2} {x.Item3}"));
            }
            break;

            case 8:
            {
                // Update index-metadata.json
                HitomiData.Instance.LoadMetadataJson();
                HitomiData.Instance.LoadHiddendataJson();
                HitomiIndex.MakeIndex();
                var str = File.ReadAllBytes("index-metadata.json");
                File.WriteAllBytes("index-metadata.compress", str.ZipByte());
            }
            break;

            case 9:
            {
                //var hidden = JsonConvert.DeserializeObject<List<HitomiArticle>>(File.ReadAllText(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "hiddendata.json")));
                //var gall = JsonConvert.DeserializeObject<List<HitomiArticle>>(File.ReadAllText(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "galleries.json")));


                //for (int i = 0; i < gall.Count; i++)
                //    for (int j = 0; j < hidden.Count; j++)
                //        if (gall[i].Magic == hidden[j].Magic)
                //        {
                //            hidden[j].Groups = gall[i].Groups;
                //            hidden[j].Characters = gall[i].Characters;
                //        }

                //JsonSerializer serializer = new JsonSerializer();
                //serializer.Converters.Add(new Newtonsoft.Json.Converters.JavaScriptDateTimeConverter());
                //serializer.NullValueHandling = NullValueHandling.Ignore;

                //using (StreamWriter sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "hiddendata2.json")))
                //using (JsonWriter writer = new JsonTextWriter(sw))
                //{
                //    serializer.Serialize(writer, hidden);
                //}

                var x = new HitomiIndexDataModel();
                x.index    = HitomiIndex.Instance.index;
                x.metadata = HitomiIndex.Instance.metadata_collection;
                JsonSerializer serializer = new JsonSerializer();
                serializer.Converters.Add(new Newtonsoft.Json.Converters.JavaScriptDateTimeConverter());
                serializer.NullValueHandling = NullValueHandling.Ignore;

                Monitor.Instance.Push("Write file: metadata-index.json");
                using (StreamWriter sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "metadata-index.json")))
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        serializer.Serialize(writer, x);
                    }

                HitomiData.Instance.LoadMetadataJson();
                HitomiData.Instance.LoadHiddendataJson();
                Monitor.Instance.Push("Write file: metadata-noptimized.json");
                using (StreamWriter sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "metadametadata-noptimizedta.json")))
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        serializer.Serialize(writer, HitomiData.Instance.metadata_collection);
                    }
            }
            break;

            case 10:

            {
                foreach (var x in HitomiIndex.Instance.tagdata_collection.artist)
                {
                    Console.Instance.Write(x.Tag + ", ");
                }
            }

            break;

            case 11:
            {
                HitomiData.Instance.LoadMetadataJson();
                HitomiData.Instance.LoadHiddendataJson();
                HitomiData.Instance.RebuildTagData();
            }
            break;

            case 12:
            {
                // Update HitomiTitle
                for (int i = 0; i < 50; i++)
                {
                    try
                    {
                        var url3 = $"https://exhentai.org/?page={i}&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&&f_cats=0&f_sname=on&f_stags=on&f_sh=on&advsearch=1&f_srdd=2&f_sname=on&f_stags=on&f_sdesc=on&f_sh=on";
                        var html = NetCommon.DownloadExHentaiString(url3);
                        File.WriteAllText($"exhentai-page/exhentai-{i}.html", html);
                        Monitor.Instance.Push($"[Paging] {i + 1}/1457");
                    }
                    catch (Exception e)
                    {
                        Console.Instance.WriteErrorLine($"[Error] {i} {e.Message}");
                    }
                    Thread.Sleep(100);
                }
                {
                    const string archive = @"C:\Dev\koromo-copy\Koromo Copy UX\bin\Debug\exhentai-page";
                    var          htmls   = new List <string>();

                    foreach (var file in Directory.GetFiles(archive))
                    {
                        htmls.Add(File.ReadAllText(file));
                    }

                    var result = new List <EHentaiResultArticle>();

                    using (var progressBar = new Console.ConsoleProgressBar())
                    {
                        int x = 0;
                        foreach (var html in htmls)
                        {
                            var content = html;
                            try
                            {
                                var exh = ExHentaiParser.ParseResultPageExtendedListView(content);
                                //Console.Instance.WriteLine("[GET] " + exh.Count + " Articles! - " + html);
                                result.AddRange(exh);
                                if (exh.Count != 25)
                                {
                                    Console.Instance.WriteLine("[Miss] " + html);
                                }
                            }
                            catch (Exception e)
                            {
                                Console.Instance.WriteLine("[Fail] " + html);
                            }
                            x++;
                            progressBar.SetProgress(x / (float)htmls.Count * 100);
                        }
                    }

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

                    Monitor.Instance.Push("Write file: ex-hentai-archive.json");
                    using (StreamWriter sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "ex-hentai-archive2.json")))
                        using (JsonWriter writer = new JsonTextWriter(sw))
                        {
                            serializer.Serialize(writer, result);
                        }
                }
                {
                    var xxx = JsonConvert.DeserializeObject <List <EHentaiResultArticle> >(File.ReadAllText("ex-hentai-archive.json"));
                    var zzz = JsonConvert.DeserializeObject <List <EHentaiResultArticle> >(File.ReadAllText("ex-hentai-archive2.json"));

                    var exists = new HashSet <int>();
                    xxx.ForEach(x => exists.Add(x.URL.Split('/')[4].ToInt32()));

                    foreach (var z in zzz)
                    {
                        var nn = z.URL.Split('/')[4].ToInt32();

                        if (exists.Contains(nn))
                        {
                            Console.Instance.WriteLine("[Duplicate] " + nn);
                        }
                        else
                        {
                            xxx.Add(z);
                        }
                    }

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

                    Monitor.Instance.Push("Write file: ex-hentai-archive3.json");
                    using (StreamWriter sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "ex-hentai-archive3.json")))
                        using (JsonWriter writer = new JsonTextWriter(sw))
                        {
                            serializer.Serialize(writer, xxx);
                        }
                }

                HitomiTitle.MakeTitle();
            }
            break;

            case 13:
                // Fill type
            {
                var md = JsonConvert.DeserializeObject <List <HitomiArticle> >(File.ReadAllText("hiddendata.json"));

                var xxx = JsonConvert.DeserializeObject <List <EHentaiResultArticle> >(File.ReadAllText("ex-hentai-archive.json"));
                //var md = JsonConvert.DeserializeObject<List<HitomiMetadata>>(File.ReadAllText("metadata.json"));

                var types = new Dictionary <string, string>();

                foreach (var xx in xxx)
                {
                    try
                    {
                        types.Add(xx.URL.Split('/')[4], xx.Type.ToLower());
                    }
                    catch (Exception e)
                    {
                        //Console.Instance.WriteLine("[??] " + xx.URL);
                    }
                }

                //for (int i = 0; i < md.Count; i++)
                //{
                //    if (md[i].Type  == null || md[i].Type.Trim() == "")
                //    {
                //        if (types.ContainsKey(md[i].ID.ToString()))
                //        {
                //            var x = md[i];
                //            x.Type = types[md[i].ID.ToString()];
                //            md[i] = x;
                //        }
                //        else
                //        {
                //            Console.Instance.WriteLine("[Fail] " + md[i].ID.ToString());
                //        }
                //    }
                //}

                for (int i = 0; i < md.Count; i++)
                {
                    if (md[i].Type == null || md[i].Type.Trim() == "")
                    {
                        if (types.ContainsKey(md[i].Magic.ToString()))
                        {
                            var x = md[i];
                            x.Type = types[md[i].Magic.ToString()];
                            md[i]  = x;
                        }
                        else
                        {
                            Console.Instance.WriteLine("[Fail] " + md[i].Magic.ToString());
                        }
                    }
                }

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

                Monitor.Instance.Push("Write file: metadata.json");
                using (StreamWriter sw = new StreamWriter(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "hiddendata2.json")))
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        serializer.Serialize(writer, md);
                    }
            }
            break;
            }
        }
Esempio n. 19
0
        static void ProcessCollectArticles(string[] args, bool rem)
        {
            var rstarts = Convert.ToInt32(args[1]);
            var starts  = Convert.ToInt32(args[1]);
            var ends    = Convert.ToInt32(args[2]);

            LoadGalleryList();

            bool is_minorg = minor_galleries.ContainsValue(args[0]);

            var result   = new DCGalleryModel();
            var articles = new List <DCPageArticle>();

            using (var progressBar = new Console.ConsoleProgressBar())
            {
                for (; starts <= ends; starts++)
                {
X:
                    try
                    {
                        var url = "";
                        if (is_minorg)
                        {
                            url = $"https://gall.dcinside.com/mgallery/board/lists/?id={args[0]}&page={starts}";
                        }
                        else
                        {
                            url = $"https://gall.dcinside.com/board/lists/?id={args[0]}&page={starts}";
                        }

                        if (rem)
                        {
                            url += "&exception_mode=recommend";
                        }

                        Console.Instance.WriteLine($"Download URL: {url}");

                        var client = NetCommon.GetDefaultClient();
                        if (PHPSESSID != "")
                        {
                            client.Headers.Add(System.Net.HttpRequestHeader.Cookie, "PHPSESSID=" + PHPSESSID);
                        }
                        var       html = client.DownloadString(url);
                        DCGallery gall = null;

                        if (is_minorg)
                        {
                            gall = DCParser.ParseMinorGallery(html);
                        }
                        else
                        {
                            gall = DCParser.ParseGallery(html);
                        }

                        articles.AddRange(gall.articles);
                    }
                    catch { goto X; }
                    progressBar.SetProgress((((ends - rstarts + 1) - (ends - starts)) / (float)(ends - rstarts + 1)) * 100);
                }

                result.is_minor_gallery = is_minorg;
                result.gallery_id       = args[0];
                result.articles         = articles.ToArray();

                File.WriteAllText($"list-{args[0]}-{DateTime.Now.Ticks}.txt", JsonConvert.SerializeObject(result));
            }
        }
Esempio n. 20
0
        /// <summary>
        /// E Hentai Magic Number를 이용해 작품 정보를 가져옵니다.
        /// </summary>
        /// <param name="magic_number"></param>
        /// <returns></returns>
        public static HArticleModel?GetArticleData(int magic_number)
        {
            string magic = magic_number.ToString();

            Monitor.Instance.Push($"[HCommander] [1] {magic}");

            //
            // 1. 히토미 데이터로 찾기
            //
            var search_hitomi = HitomiLegalize.GetMetadataFromMagic(magic);

            if (search_hitomi.HasValue)
            {
                // 히토미 데이터가 존재한다면 데이터의 유효 여부를 판단한다.
                try
                {
                    var url     = $"https://hitomi.la/galleries/{magic}.html";
                    var request = WebRequest.Create(url);
                    using (var response = request.GetResponse())
                    {
                        using (var responseStream = response.GetResponseStream())
                        {
                            // 최종 승인
                            return(ConvertTo(search_hitomi.Value, url, magic));
                        }
                    }
                }
                catch
                {
                }
            }

            Monitor.Instance.Push($"[HCommander] [2] {magic}");

            //
            // 2. Hiyobi를 이용해 탐색한다
            //
            if (search_hitomi.HasValue && search_hitomi.Value.Language == "korean")
            {
                try
                {
                    var html    = NetCommon.DownloadString(HiyobiCommon.GetInfoAddress(magic));
                    var article = HiyobiParser.ParseGalleryConents(html);
                    return(ConvertTo(article, HiyobiCommon.GetInfoAddress(magic), magic));
                }
                catch
                {
                }
            }

            Monitor.Instance.Push($"[HCommander] [3] {magic}");

            //
            // 9.3/4 샰쮘뽣?뛤3쇼뵀?gVA덲탭k융뷠킢쪳1SPS?XF퍵8C샜쁬
            //
            var f = ExHentaiData.data.AsParallel().Where(x => (x >> 40) == magic_number).ToList();

            if (f.Count > 0)
            {
                try
                {
                    //var url = $"https://e-hentai.org/g/{magic}/{f[0] ^ 1L * magic_number << 40:x}/";
                    //var html2 = NetCommon.DownloadExHentaiString(url);
                    //var article = EHentaiParser.ParseArticleData(html2);
                    //return ConvertTo(article, url, magic);
                    throw new Exception();
                }
                catch
                {
                    var url     = $"https://exhentai.org/g/{magic}/{f[0] ^ 1L * magic_number << 40:x}/";
                    var html2   = NetCommon.DownloadExHentaiString(url);
                    var article = ExHentaiParser.ParseArticleData(html2);
                    return(ConvertTo(article, url, magic));
                }
            }

            //
            // 3. GalleryBlock을 이용해 제목을 가져온다.
            //
            string title = "";

            try
            {
                var html    = NetCommon.DownloadString($"{HitomiCommon.HitomiGalleryBlock}{magic}.html");
                var article = HitomiParser.ParseGalleryBlock(html);
                title = article.Title;
            }
            catch
            {
                Monitor.Instance.Push($"[HCommander] [0] {magic}");
                return(null);
            }

            //
            // 4. 'Show Expunged Galleries' 옵션을 이용해 Ex-Hentai에서 검색한 후 정보를 가져온다.
            //
            try
            {
                var html = NetCommon.DownloadExHentaiString($"https://exhentai.org/?f_doujinshi=1&f_manga=1&f_artistcg=1&f_gamecg=1&f_western=1&f_non-h=1&f_imageset=1&f_cosplay=1&f_asianporn=1&f_misc=1&f_search={title}&page=0&f_apply=Apply+Filter&advsearch=1&f_sname=on&f_stags=on&f_sh=on&f_srdd=2");

                if (html.Contains($"/{magic}/"))
                {
                    var url     = Regex.Match(html, $"(https://exhentai.org/g/{magic}/\\w+/)").Value;
                    var html2   = NetCommon.DownloadExHentaiString(url);
                    var article = ExHentaiParser.ParseArticleData(html2);
                    return(ConvertTo(article, url, magic));
                }
            }
            catch
            { }

            Monitor.Instance.Push($"[HCommander] [0] {magic}");
            return(null);
        }
 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;
         }));
     });
 }
Esempio n. 22
0
        void Hit(IActUnit self, IActUnit target)
        {
            ActionStatus targetActionStatus = target.ActStatus;

            // hit target.
            self.OnHitTarget(target);

            // sound.

            /*
             * if (!string.IsNullOrEmpty(mData1.HitedSound) && mHitSoundCount < MAX_HIT_SOUND)
             * {
             *  if (mData1.HitedSoundIndex == -2)
             *  {
             *      mData1.HitedSoundIndex = SoundManager.Instance.GetSoundIndex(mData1.HitedSound);
             *      if (mData1.HitedSoundIndex < 0)
             *          Debug.LogError(string.Format("Fail to load hit sound: [{0}/{1}]", mOwner.UnitID, mData1.HitedSound));
             *  }
             *  if (mData1.HitedSoundIndex > 0)
             *      SoundManager.Instance.Play3DSound(mData1.HitedSoundIndex, mOwner.Position, 1.0f);
             *  mHitSoundCount++;
             * }*/

            // effect
            if (!string.IsNullOrEmpty(mAttackDef.HitedEffect))
            {
                Vector3 effectPos = target.Position;
                effectPos.y += targetActionStatus.Bounding.y * 0.5f;

                ActionSystem.Instance.EffectMgr.PlayEffect(mAttackDef.HitedEffect, mAttackDef.HitedEffectDuration * 0.001f,
                                                           null, effectPos,
                                                           0 == mAttackDef.BaseGround ? Quaternion.identity : Quaternion.Euler(0f, 0f, UnityEngine.Random.Range(0f, 360f)));
            }

            // do not process my hit result in pvp mode.
            //if (PvpClient.Instance != null && self.UnitType == EUnitType.EUT_LocalPlayer)
            //    return;

            HitData tmpHitData = new HitData();

            tmpHitData.TargetUUID = target.UUID;

            // 击中转向
            float targetRotate = target.Orientation;
            bool  rotateOnHit  = targetActionStatus.RotateOnHit;

            if (rotateOnHit)
            {
                if (mAttackDef.FramType == ActData.HitDefnitionFramType.CylinderType)
                {
                    float x      = target.Position.x - mPos.x;
                    float z      = target.Position.z - mPos.z;
                    float modify = Mathf.Atan2(x, 0);
                    targetRotate = modify + Mathf.PI;
                }
                else
                {
                    targetRotate = self.Orientation + Mathf.PI;
                }
            }

            NetCommon.Encode(
                target.Position,
                targetRotate,
                ref tmpHitData.HitX,
                ref tmpHitData.HitY,
                ref tmpHitData.HitZ,
                ref tmpHitData.HitDir);

            // 单位在墙边上的时候,近战攻击者需要反弹。
            bool bounceBack = mAttackDef.IsRemoteAttacks == 0 && target.OnTouchWall;

            // 单位处于非霸体状态,需要被击中移动~
            bool processLash = true;

            //受击动作
            ActData.HeightStatusFlag targetHeightStatus = targetActionStatus.HeightState;

            if (targetActionStatus.ActiveAction.SuperArmor || target.IsPabodyState)
            {
                // 设置受击者的霸体硬直时间?
                tmpHitData.HitAction = byte.MaxValue;

                // 单位处于霸体状态,不需要移动~
                processLash = false;

                // 攻击结果为霸体的情况系,非远程攻击的冲击速度转换为攻击者。受击者不受冲击速度影响
                bounceBack = mAttackDef.IsRemoteAttacks == 0;
            }
            else if (targetActionStatus.OnHit(mAttackDef.HitResult, mAttackDef.IsRemoteAttacks != 0))
            {
                tmpHitData.HitAction = (byte)targetActionStatus.ActiveAction.ActionCache;
            }

            // 处理buff的东东
            if (targetActionStatus.SkillItem != null && targetActionStatus.SkillItem.SkillInput != null)
            {
                targetActionStatus.SkillItem.SkillInput.OnHit(self);
            }

            // 设置攻击者的冲击速度及冲击时间。
            int     attackerLashTime = mAttackDef.AttackerTime;
            Vector3 attackerLash     = attackerLashTime == 0 ? self.ActStatus.Velocity : new Vector3(
                mAttackDef.AttackerLash.X * 0.01f,
                mAttackDef.AttackerLash.Y * 0.01f,
                mAttackDef.AttackerLash.Z * 0.01f);

            if (bounceBack)
            {
                attackerLash.x   = mAttackDef.AttackeeLash.X * 0.01f;
                attackerLash.z   = mAttackDef.AttackeeLash.Z * 0.01f;
                attackerLashTime = mAttackDef.AttackeeTime;
            }

            if (attackerLashTime > 0)
            {
                self.ActStatus.SetLashVelocity(
                    attackerLash.x,
                    attackerLash.y,
                    attackerLash.z,
                    attackerLashTime);
            }

            // 处理受击者的冲击速度~
            LashProcess(mAttackDef, ref tmpHitData, target, targetHeightStatus, processLash, rotateOnHit);

            // I was hited, tell the others.
            //if (self.UnitType == EUnitType.EUT_OtherPlayer && target.UnitType == EUnitType.EUT_LocalPlayer)
            //{
            //    if (target.ActStatus.Listener != null)
            //        target.ActStatus.Listener.OnHitData(tmpHitData);
            //}

            target.OnHit(tmpHitData, false);
        }