Ejemplo n.º 1
0
        static void ProcessParseArticle(string[] args)
        {
            LoadGalleryList();

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

            var url = "";

            if (is_minorg)
            {
                url = $"https://gall.dcinside.com/mgallery/board/view/?id={args[0]}&no={args[1]}";
            }
            else
            {
                url = $"https://gall.dcinside.com/board/view/?id={args[0]}&no={args[1]}";
            }

            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);

            Console.Instance.WriteLine(article);
        }
Ejemplo n.º 2
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();

            if (!Settings.Instance.Net.DisableSeleniumHeadless)
            {
                chrome.AddArgument("--headless");
            }
            driver = new ChromeDriver(chromeDriverService, chrome);
        }
Ejemplo n.º 3
0
        public static void download()
        {
            var path = Path.Combine(Directory.GetCurrentDirectory(), "youtube-dl/youtube-dl.exe");

            Directory.CreateDirectory("youtube-dl");
            var html = NetCommon.DownloadString("https://github.com/ytdl-org/youtube-dl/releases");
            var file = "https://github.com" + Regex.Matches(html, @"""(.*?youtube\-dl\.exe)""").Cast <Match>().First().Groups[1];

            NetCommon.GetDefaultClient().DownloadFile(file, path);
        }
Ejemplo n.º 4
0
        static void ProcessParseComments(string[] args)
        {
            LoadGalleryList();

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

            if (ESNO == "")
            {
                var url = "";
                if (is_minorg)
                {
                    url = $"https://gall.dcinside.com/mgallery/board/view/?id={args[0]}&no={args[1]}";
                }
                else
                {
                    url = $"https://gall.dcinside.com/board/view/?id={args[0]}&no={args[1]}";
                }

                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);

                ESNO = article.ESNO;
            }

            var comments = DCCommon.GetComments(new DCArticle {
                OriginalGalleryName = args[0], Id = args[1], ESNO = ESNO
            }, "1");

            Console.Instance.WriteLine(comments);

            using (var progressBar = new Console.ConsoleProgressBar())
            {
                int tcount = comments.total_cnt;
                int count  = comments.comment_cnt;
                for (int i = 2; count < tcount; i++)
                {
                    progressBar.SetProgress(((count) / (float)(tcount)) * 100);
                    comments = DCCommon.GetComments(new DCArticle {
                        OriginalGalleryName = args[0], Id = args[1], ESNO = ESNO
                    }, i.ToString());
                    if (comments.comment_cnt == 0)
                    {
                        break;
                    }
                    Console.Instance.WriteLine(comments);
                    count += comments.comment_cnt;
                }
            }
        }
Ejemplo n.º 5
0
        public DPIB()
        {
#if !DEBUG
            if (!new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
            {
                Monitor.Instance.Push($"[GoodbyeDPI] Not administrator mode.");
                return;
            }

            var dpib_zip_path = Path.Combine(Directory.GetCurrentDirectory(), "goodbyedpi.zip");

            NetCommon.GetDefaultClient().DownloadFile(DownloadURL, dpib_zip_path);

            var zip = ZipFile.Open(dpib_zip_path, ZipArchiveMode.Read);
            zip.ExtractToDirectory(tmp_path = Path.GetTempPath());
            zip.Dispose();
            File.Delete(dpib_zip_path);
#endif
        }
Ejemplo n.º 6
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));
            }
        }
Ejemplo n.º 7
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));
            }
        }
Ejemplo n.º 8
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(",");
                }
            }
        }
Ejemplo n.º 9
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 wc = NetCommon.GetDefaultClient();
                    wc.Headers.Add(System.Net.HttpRequestHeader.Referer, "https://hiyobi.me/reader/" + url.Split('/').Last());
                    var imagelink      = HitomiParser.GetImageLink(wc.DownloadString(HiyobiCommon.GetDownloadImageAddress(url.Split('/').Last())));
                    var article        = HitomiLegalize.MetadataToArticle(HitomiLegalize.GetMetadataFromMagic(url.Split('/').Last()).Value); //HiyobiParser.ParseGalleryConents(NetCommon.DownloadString(url));
                    string dir         = HitomiCommon.MakeDownloadDirectory(article);
                    var se             = Koromo_Copy.Interface.SemaphoreExtends.Default;
                    se.Referer         = "https://hiyobi.me/reader/" + url.Split('/').Last();
                    article.ImagesLink = imagelink;
                    Directory.CreateDirectory(dir);
                    DownloadSpace.Instance.RequestDownload(article.Title,
                                                           imagelink.Select(y => $"https://hiyobi.me/data/{article.Magic}/{y}").ToArray(),
                                                           imagelink.Select(y => Path.Combine(dir, y)).ToArray(),
                                                           se, 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}개 이미지 다운로드 시작...");
                    }
                }
            });
        }