• R/O
  • SSH
  • HTTPS

autocodeforsql: コミット


コミットメタ情報

リビジョン384 (tree)
日時2020-09-25 14:40:02
作者hilinwei

ログメッセージ

変更サマリ

差分

--- AutoEpub3/Logic/DEP3/cDep3_005.vb (nonexistent)
+++ AutoEpub3/Logic/DEP3/cDep3_005.vb (revision 384)
@@ -0,0 +1,355 @@
1+Imports System.IO
2+
3+Public Class cDep3_005
4+
5+ Dim bookPath As String
6+
7+ Public mEpub As New List(Of modelSection)
8+
9+ Dim listSkip As List(Of String) = {"版权", "目录", "书名页", "版权页", "作家榜经典文库", "勇者物语", "书籍导读", "封面", "书名页", "扉页", "书名", "麒麟之翼", "作者简介", "内容简介"}.ToList
10+ Dim listMobiRight As List(Of String) = {"signature"}.ToList()
11+
12+
13+
14+ Sub New(_bookPath As String)
15+ bookPath = _bookPath
16+ End Sub
17+
18+
19+ Public Sub CreadEpub()
20+
21+
22+ Dim sText As String = String.Empty
23+ Dim listLine As New List(Of String)
24+
25+ Dim ncxFilePath As String = Path.Combine(bookPath, "toc.ncx")
26+
27+ Dim fs As System.IO.FileStream = New System.IO.FileStream(ncxFilePath, System.IO.FileMode.Open)
28+ Dim serializer As System.Xml.Serialization.XmlSerializer = New System.Xml.Serialization.XmlSerializer(GetType(ncx))
29+ Dim model As ncx = CType(serializer.Deserialize(fs), ncx)
30+ fs.Dispose()
31+ fs = Nothing
32+
33+ Dim listPick As List(Of ncxNavPoint) = model.navMap.ToList()
34+
35+
36+ For iCtr As Integer = 0 To listPick.Count - 1
37+
38+ Dim ncxSection As ncxNavPoint = listPick(iCtr)
39+
40+ Dim mSection As New modelSection()
41+ mSection.Title = ncxSection.navLabel.text
42+
43+
44+ If ncxSection.navPoint Is Nothing Then
45+
46+ Continue For
47+ End If
48+
49+ Dim ncxVolume As List(Of ncxNavPointNavPoint) = ncxSection.navPoint.ToList()
50+
51+ For ctrVolume As Integer = 0 To ncxVolume.Count - 1
52+
53+ Dim ncVolume As ncxNavPointNavPoint = ncxVolume(ctrVolume)
54+
55+ Dim mVolume As New modelVolume
56+ mVolume.Title = ncVolume.navLabel.text
57+
58+ If listSkip.Any(Function(x) mVolume.Title.IndexOf(x) > -1) Then
59+ Continue For
60+ End If
61+
62+ If ncVolume.navPoint Is Nothing Then
63+ Continue For
64+ End If
65+
66+ Dim ncxChapter As List(Of ncxNavPointNavPointNavPoint) = ncVolume.navPoint.ToList()
67+
68+ For ctrChapter As Integer = 0 To ncxChapter.Count - 1
69+
70+ Dim ncChapter As ncxNavPointNavPointNavPoint = ncxChapter(ctrChapter)
71+
72+ Dim sPath As String = Path.Combine(bookPath, ncChapter.content.src).Split("#").ToList(0)
73+
74+ Dim sHtml As String = sFileEditRead(sPath, emEpub6.emDep.Dep2)
75+
76+ Dim listText As List(Of String) = cTools.listText_P(sHtml)
77+
78+
79+ Dim mChapter As New modelChapter
80+
81+ mChapter.Title = ncChapter.navLabel.text
82+ mChapter.listText = listText
83+
84+ mVolume.listChapter.Add(mChapter)
85+ Next
86+
87+
88+ mSection.listVolume.Add(mVolume)
89+
90+ Next
91+
92+ mEpub.Add(mSection)
93+ Next
94+
95+ ReMoveTopTitle()
96+
97+ chkEPUB001("href")
98+
99+ End Sub
100+
101+
102+
103+ Private Function sFileEditRead(ByVal sPath As String, ByVal KBN_DEP As emEpub6.emDep) As String
104+ sFileEditRead = cTools.sFileReader(sPath, cEpub6.encUTF8)
105+
106+ DelHtml(sFileEditRead)
107+
108+ EditHref00(sFileEditRead)
109+ EditHref01(sFileEditRead)
110+ EditHref02(sFileEditRead)
111+ EditHref03(sFileEditRead)
112+
113+ End Function
114+
115+
116+ Private Sub DelHtml(ByRef sHtml As String)
117+
118+ Dim sHtmlFormat As String = System.Xml.Linq.XElement.Parse(sHtml).ToString()
119+ Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
120+ hapHtml.LoadHtml(sHtmlFormat)
121+ Dim listDel1 = hapHtml.DocumentNode.SelectNodes(("//div[contains(@class, 'calibre1')]"))
122+
123+ If listDel1 IsNot Nothing Then
124+ For Each uDel As HtmlAgilityPack.HtmlNode In listDel1
125+ Console.WriteLine(uDel.InnerText)
126+ sHtml = sHtml.Replace(uDel.OuterHtml, "")
127+ Next
128+ End If
129+
130+
131+
132+ Dim listDel2 = hapHtml.DocumentNode.SelectNodes(("//h[contains(@class, 'calibre8')]"))
133+
134+ If listDel2 IsNot Nothing Then
135+ For Each uDel As HtmlAgilityPack.HtmlNode In listDel2
136+ Console.WriteLine(uDel.InnerText)
137+ sHtml = sHtml.Replace(uDel.OuterHtml, "")
138+ Next
139+ End If
140+
141+
142+
143+
144+
145+
146+ End Sub
147+
148+ Private Sub EditHref00(ByRef sHtml As String)
149+ sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00076.jpg"" />" & vbCrLf & " ", "坚")
150+ sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00015.jpg"" />" & vbCrLf & " ", "坚")
151+ sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00017.jpg"" />" & vbCrLf & " ", "坚")
152+ sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00016.jpg"" />" & vbCrLf & " ", "坚")
153+ sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00016.jpg"" />" & vbCrLf & " ", "坚")
154+ sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00018.jpg"" />" & vbCrLf & " ", "坚")
155+ End Sub
156+
157+
158+ Private Sub EditHref01(ByRef sHtml As String)
159+
160+ Dim sHtmlFormat As String = System.Xml.Linq.XElement.Parse(sHtml).ToString()
161+ Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
162+ hapHtml.LoadHtml(sHtmlFormat)
163+
164+ Dim listMemoC = hapHtml.DocumentNode.SelectNodes(("//span"))
165+ Dim listMemoM = hapHtml.DocumentNode.SelectNodes(("//a[contains(@class, 'calibre2')]"))
166+
167+ If listMemoM Is Nothing OrElse listMemoC Is Nothing Then
168+ Exit Sub
169+ End If
170+
171+
172+
173+ If listMemoC.Count = listMemoM.Count Then
174+
175+ For iMemo As Integer = 0 To listMemoC.Count - 1
176+
177+ Dim sNewC As String = "<a id=""w" & iMemo.ToString().PadLeft(2, "0") & """ href=""#m" & iMemo.ToString().PadLeft(2, "0") & """><sup>[" & (iMemo + 1).ToString().PadLeft(2, "0") & "]</sup></a>"
178+
179+ Dim sNewM As String = "<a id=""m" & iMemo.ToString().PadLeft(2, "0") & """ href=""#w" & iMemo.ToString().PadLeft(2, "0") & """>[" & (iMemo + 1).ToString().PadLeft(2, "0") & "]</a>"
180+
181+ sHtml = sHtml.Replace(listMemoC(iMemo).OuterHtml, sNewC)
182+
183+ sHtml = sHtml.Replace(listMemoM(iMemo).OuterHtml, sNewM)
184+
185+ Next
186+ Else
187+ Throw New Exception(listMemoC.Count & ":" & listMemoM.Count)
188+ End If
189+
190+ End Sub
191+
192+
193+ Private Sub EditHref02(ByRef sHtml As String)
194+
195+ 'Dim sHtmlFormat As String = System.Xml.Linq.XElement.Parse(sHtml).ToString()
196+ Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
197+ hapHtml.LoadHtml(sHtml)
198+ Dim listMemoC = hapHtml.DocumentNode.SelectNodes(("//sup[contains(@class, 'calibre48')]"))
199+ Dim listMemoM = hapHtml.DocumentNode.SelectNodes(("//p[contains(@class, 'calibre_16')]"))
200+ If listMemoM Is Nothing OrElse listMemoC Is Nothing Then
201+ Exit Sub
202+ End If
203+
204+ If listMemoC.Count = listMemoM.Count Then
205+
206+ For iMemo As Integer = 0 To listMemoC.Count - 1
207+ Dim hapHtmlSub As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
208+ hapHtmlSub.LoadHtml(listMemoM(iMemo).InnerHtml)
209+ Dim listMemoSub As String = hapHtmlSub.DocumentNode.SelectNodes(("//span"))(1).InnerText
210+
211+ Dim sNewC As String = "<a id=""w" & iMemo.ToString().PadLeft(2, "0") & """ href=""#m" & iMemo.ToString().PadLeft(2, "0") & """><sup>[" & (iMemo + 1).ToString().PadLeft(2, "0") & "]</sup></a>"
212+
213+ Dim sNewM As String = "<a id=""m" & iMemo.ToString().PadLeft(2, "0") & """ href=""#w" & iMemo.ToString().PadLeft(2, "0") & """>[" & (iMemo + 1).ToString().PadLeft(2, "0") & "]</a>"
214+
215+ sHtml = sHtml.Replace(listMemoC(iMemo).InnerHtml, sNewC)
216+
217+ sHtml = sHtml.Replace(listMemoM(iMemo).InnerHtml, sNewM & listMemoSub)
218+
219+ Next
220+ Else
221+ Throw New Exception(listMemoC.Count & ":" & listMemoM.Count)
222+ End If
223+
224+ End Sub
225+
226+
227+ Private Sub EditHref03(ByRef sHtml As String)
228+
229+
230+ End Sub
231+
232+
233+ Public Sub chkEPUB001(ByVal sKey As String)
234+
235+
236+ For Each uSection As modelSection In mEpub
237+
238+ For Each uVolume As modelVolume In uSection.listVolume
239+
240+ Dim listChk = From dtSeq In uVolume.listText Where dtSeq.IndexOf(sKey) > -1
241+ Dim listStop1 As List(Of String) = listChk.ToList()
242+
243+ If listStop1.Count > 0 Then
244+
245+ Dim sString As String = String.Join(vbCrLf, listStop1)
246+ Console.WriteLine(String.Join(vbCrLf, listStop1))
247+
248+
249+ If listStop1.Count > 0 Then
250+ Dim sStop As String = ""
251+ End If
252+
253+
254+ Dim sHtml As String = String.Join(vbCrLf, uVolume.listText)
255+
256+
257+ Dim listCHK_SP As List(Of String) = cTools.listNav_SE(sHtml, "<", ">", True)
258+
259+
260+ If listCHK_SP.Count > 0 Then
261+ Dim sStop As String = ""
262+ End If
263+
264+
265+ End If
266+
267+
268+
269+ For Each uChapter As modelChapter In uVolume.listChapter
270+
271+ Dim listChk2 = From dtSeq In uChapter.listText Where dtSeq.IndexOf(sKey) > -1
272+
273+ Dim listStop2 As List(Of String) = listChk.ToList()
274+
275+ Console.WriteLine(String.Join(vbCrLf, listStop2))
276+ Dim sString As String = String.Join(vbCrLf, listStop1)
277+
278+ If listStop2.Count > 0 Then
279+ Dim sStop As String = ""
280+ End If
281+
282+ Next
283+
284+ Next
285+
286+
287+ Next
288+
289+ End Sub
290+
291+ Public Sub chkEPUB002(ByRef listChk As List(Of String))
292+
293+ For iCtr As Integer = 0 To listChk.Count - 1
294+
295+ Dim sEdit As String = listChk(iCtr)
296+ Dim listEdit01 As List(Of String) = cTools.listNav_SE(sEdit, "<", ">", True)
297+
298+ For Each uEdit01 As String In listEdit01
299+
300+ sEdit = sEdit.Replace(uEdit01, "")
301+ Next
302+
303+ listChk(iCtr) = sEdit
304+
305+ Next
306+
307+
308+
309+ End Sub
310+
311+ Private Sub ReMoveTopTitle()
312+
313+
314+ For iCtr1 As Integer = 0 To mEpub.Count - 1
315+
316+ chkListTopLine(mEpub(iCtr1).listText, mEpub(iCtr1).Title)
317+
318+ For iCtr2 As Integer = 0 To mEpub(iCtr1).listVolume.Count - 1
319+
320+ chkListTopLine(mEpub(iCtr1).listVolume(iCtr2).listText, mEpub(iCtr1).listVolume(iCtr2).Title)
321+
322+ For iCtr3 As Integer = 0 To mEpub(iCtr1).listVolume(iCtr2).listChapter.Count - 1
323+ chkListTopLine(mEpub(iCtr1).listVolume(iCtr2).listChapter(iCtr3).listText, mEpub(iCtr1).listVolume(iCtr2).listChapter(iCtr3).Title)
324+ chkListTopLine(mEpub(iCtr1).listVolume(iCtr2).listChapter(iCtr3).listText, mEpub(iCtr1).listVolume(iCtr2).Title)
325+
326+ Next
327+ Next
328+ Next
329+
330+ End Sub
331+
332+ Private Sub chkListTopLine(ByRef listText As List(Of String), ByVal sTitle As String)
333+
334+ If listText.Count > 0 AndAlso sTitle.Length > 0 Then
335+ Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
336+ hapHtml.LoadHtml(listText(0))
337+ Dim chkNode = hapHtml.DocumentNode.SelectNodes("span")
338+
339+ If chkNode IsNot Nothing Then
340+
341+ If chkNode.Item(0).InnerText.Trim() = sTitle.Trim() Then
342+ listText.RemoveAt(0)
343+ End If
344+
345+ End If
346+
347+
348+ End If
349+
350+
351+ End Sub
352+
353+
354+
355+End Class
旧リポジトリブラウザで表示