Ejemplo n.º 1
0
        /// <summary>
        /// 아티클 정보를 다운로드하고 정보를 출력합니다.
        /// </summary>
        /// <param name="args"></param>
        static void ProcessArticle(string[] args)
        {
            string         html_source = NetCommon.DownloadExHentaiString(args[0]);
            EHentaiArticle article     = ExHentaiParser.ParseArticleData(html_source);

            Console.Instance.WriteLine(article);
        }
Ejemplo n.º 2
0
        static void ProcessHashing()
        {
            var result = new List <string>();

            for (int i = 2955; i < 13000; i++)
            {
                try
                {
                    var url  = $"https://exhentai.org/?page={i}&f_sname=on&f_stags=on&f_sh=on&advsearch=1";
                    var html = NetCommon.DownloadExHentaiString(url);

                    var regex = new Regex(@"https://exhentai.org/g/\d+/\w+/");
                    var match = regex.Matches(html);

                    foreach (var m in match)
                    {
                        result.Add(((Match)m).Value);
                        Console.Instance.WriteLine(((Match)m).Value);
                    }
                }
                catch (Exception e)
                {
                    Console.Instance.WriteErrorLine($"[Error] {i} {e.Message}");
                }
            }

            var builder = new StringBuilder();

            result.ForEach(x => builder.Append(x + "\r\n"));
            File.WriteAllText("rr.txt", builder.ToString());
        }
Ejemplo n.º 3
0
        /// <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>();

            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_search=language%3Akorean&f_apply=Apply+Filter&inline_set=dm_l";
                    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 html = NetCommon.DownloadExHentaiString(url2);
                    result.AddRange(ExHentaiParser.ParseResultPageListView(html));
                    Monitor.Instance.Push($"[Paging] {i+1}/1457");
                }
                catch (Exception e)
                {
                    Console.Instance.WriteErrorLine($"[Error] {i} {e.Message}");
                }
                Thread.Sleep(500);
            }

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

            using (var fs = new StreamWriter(new FileStream("exh.json", FileMode.Create, FileAccess.Write)))
            {
                fs.Write(json);
            }
        }
Ejemplo n.º 4
0
 public static void ProcessEXHentai(HArticleModel commander, bool unstable = false)
 {
     Task.Run(() =>
     {
         if (unstable)
         {
             MainWindow.Instance.Fade_MiddlePopup(true, $"불안정한 작업 진행중...[{unstable_request}개]");
         }
         var pages               = ExHentaiParser.GetPagesUri(NetCommon.DownloadExHentaiString(commander.URL));
         var pages_html          = EmiliaJobEXH.Instance.AddJob(pages.ToList(), x => { }).Select(x => ExHentaiParser.GetImagesUri(x));
         List <string> pages_all = new List <string>();
         pages_html.ToList().ForEach(x => pages_all.AddRange(x));
         var imagelink      = EmiliaJobEXH.Instance.AddJob(pages_all, x => { }).Select(x => ExHentaiParser.GetImagesAddress(x));
         List <string> tags = new List <string>();
         if (commander.male != null)
         {
             tags.AddRange(commander.male.Select(x => "male:" + x.Replace(' ', '_')));
         }
         if (commander.female != null)
         {
             tags.AddRange(commander.female.Select(x => "female:" + x.Replace(' ', '_')));
         }
         if (commander.misc != null)
         {
             tags.AddRange(commander.misc.Select(x => x.Replace(' ', '_')));
         }
         HitomiArticle article = new HitomiArticle
         {
             Magic      = commander.Magic,
             Title      = commander.Title,
             Artists    = commander.artist,
             Groups     = commander.group,
             Series     = commander.parody,
             Tags       = tags.ToArray(),
             Language   = commander.language != null ? commander.language[0] : "",
             Characters = commander.character
         };
         string dir         = HitomiCommon.MakeDownloadDirectory(article);
         article.ImagesLink = imagelink.ToList();
         Directory.CreateDirectory(dir);
         var se    = Koromo_Copy.Interface.SemaphoreExtends.MakeDefault();
         se.Cookie = "igneous=30e0c0a66;ipb_member_id=2742770;ipb_pass_hash=6042be35e994fed920ee7dd11180b65f;";
         DownloadSpace.Instance.RequestDownload(article.Title,
                                                imagelink.ToArray(),
                                                imagelink.Select(y => Path.Combine(dir, y.Split('/').Last())).ToArray(),
                                                se, dir, article);
         if (unstable)
         {
             Interlocked.Decrement(ref unstable_request);
         }
         if (unstable && unstable_request != 0)
         {
             MainWindow.Instance.Fade_MiddlePopup(true, $"불안정한 작업 진행중...[{unstable_request}개]");
         }
         else
         {
             MainWindow.Instance.FadeOut_MiddlePopup($"{imagelink.Count()}개 이미지 다운로드 시작...");
         }
     });
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 제목으로 특정 아티클을 검색합니다.
        /// </summary>
        /// <param name="magic"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static string GetAddressFromMagicTitle(string magic, string title)
        {
            string html = NetCommon.DownloadExHentaiString($"https://exhentai.org/?f_search={title}&page=0");

            if (html.Contains($"/{magic}/"))
            {
                return(Regex.Match(html, $"(https://exhentai.org/g/{magic}/\\w+/)").Value);
            }
            return("");
        }
        private void CommentWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var html    = NetCommon.DownloadExHentaiString(url);
            var article = ExHentaiParser.ParseArticleData(html);

            foreach (var comment in article.comment)
            {
                Domain.CommentViewModel cvm = new Domain.CommentViewModel
                {
                    Author  = comment.Item2.Trim(),
                    Date    = comment.Item1.ToString(),
                    Content = Regex.Replace(comment.Item3, @"<a\b[^>]+>([^<]*(?:(?!</a)<[^<]*)*)</a>", "$1")
                };

                Comments.Children.Add(new CommentElements {
                    DataContext = cvm
                });
            }
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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;
            }
        }