From 6e85a9d402806f1e99555c3aa727d0212c7d76a2 Mon Sep 17 00:00:00 2001 From: Sunghwan Bang Date: Wed, 19 Jun 2019 03:38:58 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B5=AC=EC=A0=88=20=EB=B0=9B=EC=95=84?= =?UTF-8?q?=EC=98=AC=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bible2PPT/Bibles/Sources/GoodtvBible.cs | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/Bible2PPT/Bibles/Sources/GoodtvBible.cs b/Bible2PPT/Bibles/Sources/GoodtvBible.cs index f8172a8..af44ac6 100644 --- a/Bible2PPT/Bibles/Sources/GoodtvBible.cs +++ b/Bible2PPT/Bibles/Sources/GoodtvBible.cs @@ -54,7 +54,32 @@ protected override List GetBooksOnline(BibleVersion bible) }).ToList(); } - protected override List GetChaptersOnline(BibleBook book) => throw new NotImplementedException(); - protected override List GetVersesOnline(BibleChapter chapter) => throw new NotImplementedException(); + protected override List GetChaptersOnline(BibleBook book) => + Enumerable.Range(1, book.ChapterCount) + .Select(i => new BibleChapter + { + Number = i, + }).ToList(); + private static string StripHtmlTags(string s) => Regex.Replace(s, @"<.+?>", "", RegexOptions.Singleline); + + protected override List GetVersesOnline(BibleChapter chapter) + { + var data = Encoding.UTF8.GetString(client.UploadValues("/bible.asp", new System.Collections.Specialized.NameValueCollection + { + { "bible_idx", chapter.Book.OnlineId }, + { "jang_idx", chapter.Number.ToString() }, + { "bible_version_1", chapter.Book.Bible.OnlineId }, + { "bible_version_2", "0" }, + { "bible_version_3", "0" }, + { "count", "1" }, + })); + data = Regex.Match(data, @"

([\s\S]+?)

").Groups[1].Value; + var matches = Regex.Matches(data, @"(\d+).*?(.*?)
"); + return matches.Cast().Select(i => new BibleVerse + { + Number = int.Parse(i.Groups[1].Value), + Text = StripHtmlTags(i.Groups[2].Value), + }).ToList(); + } } }