Skip to content

Commit

Permalink
GOODTV 성경소스 목록에 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sunghwan2789 committed Jun 18, 2019
1 parent 41266a9 commit baf5cd6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions Bible2PPT/Bible2PPT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<Compile Include="Bibles\Sources\GodpeopleBible.cs" />
<Compile Include="Bibles\Sources\GodpiaBible.cs" />
<Compile Include="Bibles\Sources\BibleSource.cs" />
<Compile Include="Bibles\Sources\GoodtvBible.cs" />
<Compile Include="BinaryConfig.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
Expand Down
1 change: 1 addition & 0 deletions Bible2PPT/Bibles/Sources/BibleSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ abstract class BibleSource
{
new GodpeopleBible { Id = 0 },
new GodpiaBible { Id = 1 },
new GoodtvBible { Id = 2 },
};

public int Id { get; set; }
Expand Down
60 changes: 60 additions & 0 deletions Bible2PPT/Bibles/Sources/GoodtvBible.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Bible2PPT.Bibles.Sources
{
class GoodtvBible : BibleSource
{
private const string BASE_URL = "http://goodtvbible.goodtv.co.kr";

private BetterWebClient client = new BetterWebClient
{
BaseAddress = BASE_URL,
Encoding = Encoding.UTF8,
};

public GoodtvBible()
{
Name = "GOODTV 성경";
}

protected override List<BibleVersion> GetBiblesOnline()
{
var data = client.DownloadString("/bible.asp");
var matches = Regex.Matches(data, @"bible_check"".+?value=""(\d+)""[\s\S]+?<span.+?>(.+?)<");
return matches.Cast<Match>().Select(i => new BibleVersion
{
OnlineId = i.Groups[1].Value,
Name = i.Groups[2].Value,
}).ToList();
}

protected override List<BibleBook> GetBooksOnline(BibleVersion bible)
{
var oldData = client.UploadValues("/bible_otnt_exc.asp", new System.Collections.Specialized.NameValueCollection
{
{ "bible_idx", "1" },
{ "otnt", "1" },
});
var newData = client.UploadValues("/bible_otnt_exc.asp", new System.Collections.Specialized.NameValueCollection
{
{ "bible_idx", "1" },
{ "otnt", "2" },
});
var data = Encoding.UTF8.GetString(oldData) + Encoding.UTF8.GetString(newData);
var matches = Regex.Matches(data, @"""idx"":(\d+).+?""bible_name"":""(.+?)"".+?""max_jang"":(\d+)");
return matches.Cast<Match>().Select(i => new BibleBook
{
OnlineId = i.Groups[1].Value,
Title = i.Groups[2].Value,
ChapterCount = int.Parse(i.Groups[3].Value),
}).ToList();
}

protected override List<BibleChapter> GetChaptersOnline(BibleBook book) => throw new NotImplementedException();
protected override List<BibleVerse> GetVersesOnline(BibleChapter chapter) => throw new NotImplementedException();
}
}

0 comments on commit baf5cd6

Please sign in to comment.