예제 #1
0
        private void ThumbnailItem_Loaded(object sender, RoutedEventArgs e)
        {
            if (loaded)
            {
                return;
            }
            loaded = true;

            switch (Article.type)
            {
            case "icon_recomimg":
            case "icon_pic":
                Icon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Image;
                break;

            default:
                Icon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Pen;
                break;
            }

            if (Article.type == "icon_pic" || Article.type == "icon_recomimg")
            {
                Task.Run(() =>
                {
                    var html = NetTools.DownloadString(URL);
                    if (html == null || html == "")
                    {
                        Extends.Post(() =>
                        {
                            Icon.Kind = MaterialDesignThemes.Wpf.PackIconKind.TrashCanOutline;
                        });
                        return;
                    }
                    downloaded_article = DCInsideUtils.ParseBoardView(html);
                    if (downloaded_article.ImagesLink.Count == 0)
                    {
                        return;
                    }
                    temp_file = TemporaryFiles.UseNew();
                    NetTools.DownloadFile(downloaded_article.ImagesLink[0], temp_file);

                    Extends.Post(() => AnimationBehavior.SetSourceUri(Image, new Uri(temp_file)));
                });
            }
        }
예제 #2
0
        private void start()
        {
            int ps;

            if (!int.TryParse(textBox3.Text, out ps))
            {
                append("숫자만 입력해주세요.");
                return;
            }
            int pe;

            if (!int.TryParse(textBox4.Text, out pe))
            {
                append("숫자만 입력해주세요.");
                return;
            }

            var invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
            var sp      = Path.Combine(Directory.GetCurrentDirectory(), "Archive",
                                       $"몬무스 갤러리 (monmusu)");

            var id = "monmusu";

            Directory.CreateDirectory(sp);

            var starts = ps;

            status("진행중...[0/" + (pe - ps + 1).ToString("#,#") + "]");
            bool real_cookie_receive = false;

            try
            {
                for (; ps <= pe; ps++)
                {
                    string url;

                    if (true)
                    {
                        url = $"https://gall.dcinside.com/mgallery/board/view/?id={id}&no={ps}";
                    }
                    else
                    {
                        url = $"https://gall.dcinside.com/board/view/?id={id}&no={ps}";
                    }

                    Logger.Instance.Push("Downloading String... = " + url);
                    var task = NetTask.MakeDefault(url);
                    task.Cookie = COOKIES;
                    bool y = real_cookie_receive;
                    if (real_cookie_receive == false)
                    {
                        task.HeaderReceive = (ef) =>
                        {
                            append("헤더받음: " + ef);
                            var xx = ef.Split('\n').First(x => x.Contains("Set-Cookie")).Replace("Set-Cookie: ", "").Trim();
                            COOKIES             = "PHPSESSID=" + SESS;
                            COOKIES            += "; PHPSESSKEY=" + xx.Split(new[] { "PHPSESSKEY=" }, StringSplitOptions.None)[1].Split(';')[0].Trim();
                            COOKIES            += "; block_alert_monmusu=1";
                            real_cookie_receive = true;
                            append("쿠키 변경됨: " + COOKIES);
                        };
                    }
                    var html = NetTools.DownloadString(task);
                    if (y == false)
                    {
                        append("PS1");
                        ps--;
                        continue;
                    }
                    Logger.Instance.Push("Downloaded String = " + url);
                    if (string.IsNullOrEmpty(html))
                    {
                        append("실패: " + url);
                        Logger.Instance.Push("Fail: " + url);
                        goto NEXT;
                    }
                    if (html.Length < 1000 && html.Contains("해당 마이너 갤러리는 운영원칙 위반으로 접근이 제한되었습니다."))
                    {
                        append("실패: 접근 거부, 접근 가능한 아이디로 재시도하시기 바랍니다.");
                        break;
                    }
                    if (html.Contains("해당 마이너 갤러리는 운영원칙 위반(사유: 누드패치, 성행위 패치, 음란성 게시물 공지 등록 및 정리 안됨) 으로 접근이 제한되었습니다."))
                    {
                        //goto F**K;
                        return;
                    }
                    var info = DCInsideUtils.ParseBoardView(html, true);
                    Logger.Instance.Push("Parse: " + url);
                    // 해당 마이너 갤러리는 운영원칙 위반으로 접근이 제한되었습니다.\n마이너 갤러리 메인으로 돌아갑니다.

                    var ttitle = $"{info.Title}";
                    foreach (char c in invalid)
                    {
                        ttitle = ttitle.Replace(c.ToString(), "");
                    }

                    Logger.Instance.Push("ttile: " + ttitle);
                    File.WriteAllText(Path.Combine(sp, $"[{ps}]-body-{ttitle}.json"), JsonConvert.SerializeObject(info, Formatting.Indented));
                    Logger.Instance.Push("file-body: " + $"[{ps}]-body-{ttitle}.json");

                    int com;
                    if (int.TryParse(info.CommentCount.Replace(",", ""), out com) && com > 0)
                    {
                        try
                        {
                            var comments = DCInsideUtils.GetAllComments(id, ps.ToString()).Result;
                            File.WriteAllText(Path.Combine(sp, $"[{ps}]-comments-{ttitle}.json"), JsonConvert.SerializeObject(comments, Formatting.Indented));
                            Logger.Instance.Push("file-comment: " + $"[{ps}]-comments-{ttitle}.json");
                        }
                        catch { }
                    }

NEXT:
                    var ss = TimeSpan.FromMilliseconds(720 * (pe - ps));
                    var yy = "";
                    if (ss.Days > 0)
                    {
                        yy += ss.Days.ToString() + "일 ";
                    }
                    if (ss.Days > 0 || ss.Hours > 0)
                    {
                        yy += ss.Hours.ToString() + "시간 ";
                    }
                    if (ss.Days > 0 || ss.Hours > 0 || ss.Minutes > 0)
                    {
                        yy += ss.Minutes.ToString() + "분 ";
                    }
                    if (ss.Days > 0 || ss.Hours > 0 || ss.Minutes > 0 || ss.Seconds > 0)
                    {
                        yy += ss.Seconds.ToString() + "초 남음";
                    }

                    status("진행중...[" + (ps - starts + 1).ToString() + "/" + (pe - starts + 1).ToString("#,#") + "] 남은시간: " + yy);
                    Logger.Instance.Push("next: " + url + $" || {ps}/{pe}/{starts}");
                    Thread.Sleep(700);
                }

                status("완료");
            } catch (Exception e)
            {
                append("실패: " + e.Message + "\r\n" + e.StackTrace);
            }
        }