private void URLButton_Click(object sender, RoutedEventArgs e)
        {
            if (original_url == URLText.Text)
            {
                HTMLList.DataContext = new CustomCrawlerDataGridViewModel(GetLoadResults());
                return;
            }
            try
            {
                original_url = URLText.Text;
                try { root_url = string.Join("/", URLText.Text.Split(new char[] { '/' }, 4), 0, 3); } catch { }

                if (driverCheck.IsChecked == false)
                {
                    string html;
                    if (!File.Exists(URLText.Text))
                    {
                        html = NetCommon.DownloadString(URLText.Text);
                    }
                    else
                    {
                        html = File.ReadAllText(URLText.Text);
                    }
                    tree = new HtmlTree(html);
                    tree.BuildTree();
                    HTMLList.DataContext = new CustomCrawlerDataGridViewModel(GetLoadResults());
                }
                else
                {
                    var driver = new SeleniumWrapper();
                    driver.Navigate(URLText.Text);
                    tree = new HtmlTree(driver.GetHtml());
                    tree.BuildTree();
                    driver.Close();
                    HTMLList.DataContext = new CustomCrawlerDataGridViewModel(GetLoadResults());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public static void ProcessDC(string url)
        {
            var    article = DCParser.ParseBoardView(NetCommon.DownloadString(url));
            string dir     = Path.Combine(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "dcinside"), $"[{article.GalleryName}] {DeleteInvalid(article.Title)}");

            Directory.CreateDirectory(dir);

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

            se.Referer = url;

            DownloadSpace.Instance.RequestDownload(article.Title,
                                                   article.ImagesLink.ToArray(),
                                                   article.FilesName.Select(x => Path.Combine(dir, DeleteInvalid(x))).ToArray(),
                                                   se,
                                                   dir + '\\',
                                                   null
                                                   );
            MainWindow.Instance.FadeOut_MiddlePopup($"{article.ImagesLink.Count}개 항목 다운로드 시작...");
        }
Beispiel #3
0
        private void tracker(string gall_code, string contents, bool isminor)
        {
            append($"Thread starts! {gall_code} {contents}" + (isminor ? " mg" : " g"));

            for (int i = 1; i < 10; i++)
            {
                var url = "https://gall.dcinside.com/board/lists?id=" + gall_code + $"&page={i}";
                //append("download url " + url + "...");
                var html = NetCommon.DownloadString(url);
                var g    = DCParser.ParseGallery(html);
                //append($"mp={g.max_page},esno={g.esno},krn={g.name},cnt={g.articles.Length} loaded!");

                foreach (var a in g.articles)
                {
                    if (a.nick.ToLower().Contains(contents) || a.title.ToLower().Contains(contents))
                    {
                        append($"article found! title={a.title},no={a.no},nick={a.nick}");
                    }

                    if (a.replay_num != "")
                    {
                        for (int j = 1; j < 100; j++)
                        {
                            //append("download comment " + a.title  + " " + a.no + " " + j);
                            var c = DCCommon.GetComments(g, a, j.ToString());
                            if (c.comments == null || c.comments.Length == 0)
                            {
                                break;
                            }
                            foreach (var b in c.comments)
                            {
                                if (b.name.ToLower().Contains(contents) || b.memo.ToLower().Contains(contents))
                                {
                                    append($"coment found! title={a.title},no={a.no},name={b.name},memo={b.memo}");
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 이미지 링크를 다운로드하고 정보를 출력합니다.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="dl">다운로드 가능한 이미지 링크를 출력할지의 여부를 설정합니다.</param>
        static void ProcessImage(string[] args, string type)
        {
            string html_source = NetCommon.DownloadString($"{HitomiCommon.HitomiGalleryAddress}{args[0]}.js");
            var    image_link  = HitomiParser.GetImageLink(html_source);

            if (type == null)
            {
                Console.Instance.WriteLine(image_link.Select(x => HitomiCommon.GetDownloadImageAddress(args[0], x, false, "")));
            }
            else if (type == "small")
            {
                Console.Instance.WriteLine(image_link.Select(x => $"{HitomiCommon.HitomiThumbnailSmall}{args[0]}/{x}.jpg"));
            }
            else if (type == "big")
            {
                Console.Instance.WriteLine(image_link.Select(x => $"{HitomiCommon.HitomiThumbnailBig}{args[0]}/{x}.jpg"));
            }
            else
            {
                Console.Instance.WriteErrorLine($"'{type}' is not correct type. Please input 'small' or 'big'.");
            }
        }
        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} 작품) 항목 다운로드 시작...");
            });
        }
Beispiel #6
0
        public static List <ChromeDevtoolsListElement> GetDebuggeeList()
        {
            var list = NetCommon.DownloadString($"http://localhost:{Port}/json/list?t=" + GetTime());

            return(JsonConvert.DeserializeObject <List <ChromeDevtoolsListElement> >(list));
        }
        public static void ProcessHiyobi(string url, bool unstable = false)
        {
            Task.Run(() =>
            {
                if (url.StartsWith("https://hiyobi.me/manga/info/"))
                {
                    MainWindow.Instance.Fade_MiddlePopup(true, "접속중...");
                    var html     = NetCommon.DownloadString(url);
                    var articles = HiyobiParser.ParseNonHArticles(html);
                    var title    = HiyobiParser.ParseNonHTitle(html);

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

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

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

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

                    MainWindow.Instance.FadeOut_MiddlePopup($"{count}개({articles.Count} 작품) 항목 다운로드 시작...");
                }
                else if (url.StartsWith("https://hiyobi.me/info/"))
                {
                    if (unstable)
                    {
                        MainWindow.Instance.Fade_MiddlePopup(true, $"불안정한 작업 진행중...[{unstable_request}개]");
                    }
                    else
                    {
                        MainWindow.Instance.Fade_MiddlePopup(true, "접속중...");
                    }
                    var imagelink      = HitomiParser.GetImageLink(NetCommon.DownloadString(HiyobiCommon.GetDownloadImageAddress(url.Split('/').Last())));
                    var article        = HiyobiParser.ParseGalleryConents(NetCommon.DownloadString(url));
                    string dir         = HitomiCommon.MakeDownloadDirectory(article);
                    article.ImagesLink = imagelink;
                    Directory.CreateDirectory(dir);
                    DownloadSpace.Instance.RequestDownload(article.Title,
                                                           imagelink.Select(y => HitomiCommon.GetDownloadImageAddress(article.Magic, y)).ToArray(),
                                                           imagelink.Select(y => Path.Combine(dir, y)).ToArray(),
                                                           Koromo_Copy.Interface.SemaphoreExtends.Default, dir, article);
                    Directory.CreateDirectory(dir);
                    if (unstable)
                    {
                        Interlocked.Decrement(ref unstable_request);
                    }
                    if (unstable && unstable_request != 0)
                    {
                        MainWindow.Instance.Fade_MiddlePopup(true, $"불안정한 작업 진행중...[{unstable_request}개]");
                    }
                    else
                    {
                        MainWindow.Instance.FadeOut_MiddlePopup($"{imagelink.Count}개 이미지 다운로드 시작...");
                    }
                }
            });
        }
Beispiel #8
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);
        }
Beispiel #9
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;
                }));
            }
        }
Beispiel #10
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 = $"대기 중";
            }));
        }
Beispiel #11
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());
                }
            });
        }
Beispiel #12
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();
                    }));
                });
            }
        }