/// <summary> /// "{0}({1}) [{2}/{3}] ({4:P}) [{5}]" /// <code>{0}:웹툰 제목</code> /// <code>{1}:웹툰 아이디</code> /// <code>{2}:현재 포지션</code> /// <code>{3}:총 작업수</code> /// <code>{4}:퍼센트</code> /// <code>{5}:회차 날짜</code> /// </summary> /// <param name="webtoonInfo"></param> /// <param name="ProgressTextFormat"></param> public static void UpdateWebtoonInfo(WebtoonInfo webtoonInfo, string ProgressTextFormat) { Agent agent = Agent.Instance; Parser.Parser parser = Parser.Parser.Instance; WebtoonKey webtoonKey = new WebtoonKey(webtoonInfo.WebtoonTitleId); //comic.naver.com에서 최신 회차의 EpisodeNo를 불러옵니다. agent.LoadPage(webtoonKey.BuildUrl()); int latestEpisodeNo = int.Parse(parser.GetLatestEpisodeNo()); //webtoonInfo중 가장 마지막 회차의 EpisodeNo를 불러옵니다. int lastEpisodeNo = webtoonInfo.GetLastEpisodeNo(); //웹툰 정보를 업데이트합니다. for (int episodeNo = lastEpisodeNo + 1; episodeNo <= latestEpisodeNo; episodeNo++) { EpisodeKey episodeKey = new EpisodeKey(webtoonKey.TitleId, episodeNo); agent.LoadPage(episodeKey.BuildUrl()); string currentEpisodeNo = parser.GetCurrentEpisodeNo(); if (!currentEpisodeNo.Equals(episodeNo.ToString())) { //비어있는 번호 건너뛰기 continue; } string episodeTitle = parser.GetEpisodeTitle(); string episodeDate = parser.GetEpisodeDate(); string[] imageUrls = parser.GetComicContentImageUrls(); webtoonInfo.Episodes.Add(episodeNo, new EpisodeInfo(episodeKey, episodeTitle, imageUrls, episodeDate)); ProgressChangedEvent(string.Format(ProgressTextFormat, webtoonInfo.WebtoonTitle, webtoonInfo.WebtoonTitleId, (episodeNo).ToString("D" + latestEpisodeNo.ToString().Length.ToString()), latestEpisodeNo, (decimal)(episodeNo) / latestEpisodeNo, webtoonInfo.Episodes[episodeNo].EpisodeDate, webtoonInfo.Episodes[episodeNo].EpisodeTitle)); } Console.WriteLine(); }
/// <summary> /// "{0}({1}) [{2}/{3}] ({4:P}) [{5}]" /// <code>{0}:웹툰 제목</code> /// <code>{1}:웹툰 아이디</code> /// <code>{2}:현재 포지션</code> /// <code>{3}:총 작업수</code> /// <code>{4}:퍼센트</code> /// <code>{5}:회차 날짜</code> /// </summary> /// <param name="webtoonInfo"></param> /// <param name="ProgressTextFormat"></param> public void UpdateWebtoonInfo(string ProgressTextFormat, IProgress <string> progress) { WebtoonKey webtoonKey = new WebtoonKey(webtoonInfo.WebtoonTitleId); //comic.naver.com에서 최신 회차의 EpisodeNo를 불러옵니다. agent.LoadPage(webtoonKey.BuildUrl()); int latestEpisodeNo = int.Parse(parser.GetLatestEpisodeNo()); //webtoonInfo중 가장 마지막 회차의 EpisodeNo를 불러옵니다. int lastEpisodeNo = webtoonInfo.GetLastEpisodeNo(); //웹툰 정보를 업데이트합니다. for (int episodeNo = lastEpisodeNo + 1; episodeNo <= latestEpisodeNo; episodeNo++) { EpisodeKey episodeKey = new EpisodeKey(webtoonKey.TitleId, episodeNo); agent.LoadPage(episodeKey.BuildUrl()); string currentEpisodeNo = parser.GetCurrentEpisodeNo(); if (!currentEpisodeNo.Equals(episodeNo.ToString())) { //비어있는 번호 건너뛰기 continue; } string episodeTitle = parser.GetEpisodeTitle(); string episodeDate = parser.GetEpisodeDate(); string[] imageUrls = parser.GetComicContentImageUrls(); webtoonInfo.Episodes.Add(episodeNo, new EpisodeInfo(episodeKey, episodeTitle, imageUrls, episodeDate)); progress.Report(string.Format(ProgressTextFormat, webtoonInfo.WebtoonTitle, webtoonInfo.WebtoonTitleId, (episodeNo).ToString("D" + latestEpisodeNo.ToString().Length.ToString()), latestEpisodeNo, (decimal)(episodeNo) / latestEpisodeNo, webtoonInfo.Episodes[episodeNo].EpisodeDate, webtoonInfo.Episodes[episodeNo].EpisodeTitle)); } Thread.Sleep(500); }