• R/O
  • SSH
  • HTTPS

autocodeforsql: 提交


Commit MetaInfo

修订版407 (tree)
时间2020-11-11 11:38:44
作者hilinwei

Log Message

更改概述

差异

--- AutoEpub3/AutoEpub8.Designer.vb (revision 406)
+++ AutoEpub3/AutoEpub8.Designer.vb (revision 407)
@@ -28,6 +28,7 @@
2828 Me.Button3 = New System.Windows.Forms.Button()
2929 Me.Button4 = New System.Windows.Forms.Button()
3030 Me.Button6 = New System.Windows.Forms.Button()
31+ Me.Button7 = New System.Windows.Forms.Button()
3132 Me.SuspendLayout()
3233 '
3334 'Button5
@@ -84,11 +85,21 @@
8485 Me.Button6.Text = "El His Mon"
8586 Me.Button6.UseVisualStyleBackColor = True
8687 '
88+ 'Button7
89+ '
90+ Me.Button7.Location = New System.Drawing.Point(328, 209)
91+ Me.Button7.Name = "Button7"
92+ Me.Button7.Size = New System.Drawing.Size(173, 69)
93+ Me.Button7.TabIndex = 22
94+ Me.Button7.Text = "NCX Dep 2"
95+ Me.Button7.UseVisualStyleBackColor = True
96+ '
8797 'AutoEpub8
8898 '
8999 Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
90100 Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
91101 Me.ClientSize = New System.Drawing.Size(800, 450)
102+ Me.Controls.Add(Me.Button7)
92103 Me.Controls.Add(Me.Button6)
93104 Me.Controls.Add(Me.Button4)
94105 Me.Controls.Add(Me.Button3)
@@ -107,4 +118,5 @@
107118 Friend WithEvents Button3 As Button
108119 Friend WithEvents Button4 As Button
109120 Friend WithEvents Button6 As Button
121+ Friend WithEvents Button7 As Button
110122 End Class
--- AutoEpub3/AutoEpub8.vb (revision 406)
+++ AutoEpub3/AutoEpub8.vb (revision 407)
@@ -217,5 +217,21 @@
217217
218218
219219 End Sub
220+
221+ Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
222+
223+ Dim cAutoEpub As New cDep2_006("C:\Users\DTC_PC07\Downloads\w\OEBPS\")
224+ cAutoEpub.CreadEpub()
225+
226+
227+ Dim cEpub As New cEpub6(emEpub6.emEncCode.GB2321, emEpub6.emLan.ZH, "中短篇合集", "合集", "DYGW01_202009")
228+ cEpub.bConvertToMobi = False
229+ cEpub.CreateEpub(cAutoEpub.mEpub)
230+ MessageBox.Show("Finished")
231+ System.Diagnostics.Process.Start(cEpub.sOutPutPathFolder)
232+
233+
234+ End Sub
235+
220236 End Class
221237
--- AutoEpub3/Logic/DEP2/cDep2_006.vb (nonexistent)
+++ AutoEpub3/Logic/DEP2/cDep2_006.vb (revision 407)
@@ -0,0 +1,309 @@
1+Imports System.IO
2+Imports HtmlAgilityPack
3+
4+Public Class cDep2_006
5+
6+ Dim bookPath As String
7+ Dim emCurreDep As emEpub6.emDep
8+
9+ Public mEpub As New List(Of modelVolume)
10+
11+ Dim listSkip As List(Of String) = {"版权", "目录", "书名页", "版权页", "作家榜经典文库", "勇者物语", "书籍导读", "封面", "书名页", "扉页", "书名", "麒麟之翼", "作者简介", "内容简介", "版权信息", "总目录"}.ToList
12+ Dim listMobiRight As List(Of String) = {"right"}.ToList()
13+
14+ Sub New(_bookPath As String)
15+ bookPath = _bookPath
16+ End Sub
17+
18+ Public Sub CreadEpub()
19+
20+ Dim sText As String = String.Empty
21+ Dim listLine As New List(Of String)
22+
23+ Dim ncxFilePath As String = Path.Combine(bookPath, "toc.ncx")
24+
25+ Dim fs As System.IO.FileStream = New System.IO.FileStream(ncxFilePath, System.IO.FileMode.Open)
26+ Dim serializer As System.Xml.Serialization.XmlSerializer = New System.Xml.Serialization.XmlSerializer(GetType(ncx))
27+ Dim model As ncx = CType(serializer.Deserialize(fs), ncx)
28+ fs.Dispose()
29+ fs = Nothing
30+
31+
32+ For iCtrVolume As Integer = 0 To model.navMap.Count - 1
33+
34+ emCurreDep = emEpub6.emDep.Dep1
35+
36+ Dim ncxVolume As ncxNavPoint = model.navMap(iCtrVolume)
37+ Dim mVolume As New modelVolume()
38+ mVolume.Title = ncxVolume.navLabel.text
39+ If listSkip.Any(Function(x) mVolume.Title.IndexOf(x) > -1) Then
40+ Continue For
41+ End If
42+
43+ If ncxVolume.navPoint Is Nothing Then
44+ mVolume.Title = ncxVolume.navLabel.text
45+ mVolume.Scr = ncxVolume.content.src
46+ Dim sPath As String = Path.Combine(bookPath, mVolume.Scr).Split("#").ToList(0)
47+ Dim sTemp As String = sFileEditRead(sPath)
48+ Dim listText As List(Of String) = GetListText(sTemp)
49+ mVolume.listText = listText
50+ mEpub.Add(mVolume)
51+ Continue For
52+ End If
53+
54+
55+ For ctrChapter As Integer = 0 To ncxVolume.navPoint.Count - 1
56+
57+
58+ emCurreDep = emEpub6.emDep.Dep2
59+ Dim ncxChapter As ncxNavPointNavPoint = ncxVolume.navPoint(ctrChapter)
60+
61+ Dim mChapter As New modelChapter
62+
63+ mChapter.Title = ncxChapter.navLabel.text
64+ mChapter.Scr = ncxChapter.content.src
65+
66+ If listSkip.Any(Function(x) mChapter.Title.IndexOf(x) > -1) Then
67+ Continue For
68+ End If
69+
70+ Dim sPath As String = Path.Combine(bookPath, mChapter.Scr).Split("#").ToList(0)
71+
72+ Dim sChapter As String = sFileEditRead(sPath)
73+ Dim listText As List(Of String) = GetListText(sChapter)
74+
75+ mChapter.listText = listText
76+ mVolume.listChapter.Add(mChapter)
77+
78+
79+
80+ Next
81+
82+
83+ mEpub.Add(mVolume)
84+
85+ Next
86+
87+ End Sub
88+
89+ Private Function GetListText(ByVal sHtml) As List(Of String)
90+
91+ GetListText = New List(Of String)
92+ Dim apHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
93+ apHtml.LoadHtml(sHtml)
94+ Dim listHtmlNode = apHtml.DocumentNode.Descendants.Where(Function(x) x.Name = "p" OrElse x.Name = "h2")
95+ For Each uHtmlNode As HtmlAgilityPack.HtmlNode In listHtmlNode
96+
97+ If uHtmlNode.Name = "p" Then
98+ Dim sTarget As String = uHtmlNode.InnerHtml
99+ If listMobiRight.Any(Function(x) uHtmlNode.OuterHtml.Contains(x)) Then
100+ sTarget = sTarget + emEpub6.spDl_Right
101+ End If
102+ GetListText.Add(sTarget)
103+ End If
104+
105+ If uHtmlNode.Name = "h2" Then
106+ Dim sTarget As String = uHtmlNode.InnerHtml
107+ sTarget = sTarget + emEpub6.spText_SubTitle
108+ GetListText.Add(sTarget)
109+ End If
110+
111+
112+ If uHtmlNode.Name = "img" Then
113+
114+ Dim imgScr As String = uHtmlNode.Attributes("src").Value
115+ Dim sNewImg As String = cTools.sGaiji(imgScr, emCurreDep)
116+ If uHtmlNode.OuterHtml.IndexOf("image-100") > -1 Then
117+ sNewImg = cTools.sMapImg(imgScr, emCurreDep)
118+ End If
119+ GetListText.Add(sNewImg)
120+ End If
121+
122+
123+ Next
124+
125+ End Function
126+
127+
128+ Private Function sFileEditRead(ByVal sPath As String) As String
129+ sFileEditRead = cTools.sFileReader(sPath, cEpub6.encUTF8)
130+
131+ DelHtml(sFileEditRead)
132+
133+ EditHref00(sFileEditRead)
134+ EditHref01(sFileEditRead)
135+ EditHref02(sFileEditRead)
136+ EditHref03(sFileEditRead)
137+ ResetImgUrl(sFileEditRead)
138+
139+ End Function
140+
141+
142+ Private Sub DelHtml(ByRef sHtml As String)
143+
144+
145+ End Sub
146+
147+ Private Sub EditHref00(ByRef sHtml As String)
148+
149+ 'Dim hapHtmlEdit As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
150+ 'hapHtmlEdit.LoadHtml(sHtml)
151+ 'Dim linqHap = hapHtmlEdit.DocumentNode.SelectNodes(("//a"))
152+
153+ 'If linqHap IsNot Nothing Then
154+
155+ ' For Each uHap As HtmlNode In linqHap
156+
157+ ' Dim sScr As String = uHap.Attributes("href").Value
158+
159+ ' If sScr.Split("#").Count = 2 Then
160+ ' sHtml = sHtml.Replace(sScr, "#" & sScr.Split("#")(1))
161+ ' Else
162+ ' Dim sError As String = ""
163+ ' End If
164+ ' Next
165+
166+ 'End If
167+
168+
169+ End Sub
170+
171+
172+ Private Sub EditHref01(ByRef sHtml As String)
173+
174+ End Sub
175+
176+
177+ Private Sub EditHref02(ByRef sHtml As String)
178+
179+ End Sub
180+
181+
182+ Private Sub EditHref03(ByRef sHtml As String)
183+
184+ End Sub
185+
186+
187+ Public Sub chkEPUB001(ByVal sKey As String)
188+
189+
190+ For Each uSection As modelSection In mEpub
191+
192+ For Each uVolume As modelVolume In uSection.listVolume
193+
194+ Dim listChk = From dtSeq In uVolume.listText Where dtSeq.IndexOf(sKey) > -1
195+ Dim listStop1 As List(Of String) = listChk.ToList()
196+
197+ If listStop1.Count > 0 Then
198+
199+ Dim sString As String = String.Join(vbCrLf, listStop1)
200+ Console.WriteLine(String.Join(vbCrLf, listStop1))
201+
202+
203+ If listStop1.Count > 0 Then
204+ Dim sStop As String = ""
205+ End If
206+
207+
208+ Dim sHtml As String = String.Join(vbCrLf, uVolume.listText)
209+
210+
211+ Dim listCHK_SP As List(Of String) = cTools.listNav_SE(sHtml, "<", ">", True)
212+
213+
214+ If listCHK_SP.Count > 0 Then
215+ Dim sStop As String = ""
216+ End If
217+
218+
219+ End If
220+
221+
222+
223+ For Each uChapter As modelChapter In uVolume.listChapter
224+
225+ Dim listChk2 = From dtSeq In uChapter.listText Where dtSeq.IndexOf(sKey) > -1
226+
227+ Dim listStop2 As List(Of String) = listChk.ToList()
228+
229+ Console.WriteLine(String.Join(vbCrLf, listStop2))
230+ Dim sString As String = String.Join(vbCrLf, listStop1)
231+
232+ If listStop2.Count > 0 Then
233+ Dim sStop As String = ""
234+ End If
235+
236+ Next
237+
238+ Next
239+
240+
241+ Next
242+
243+ End Sub
244+
245+ Public Sub chkEPUB002(ByRef listChk As List(Of String))
246+
247+ For iCtr As Integer = 0 To listChk.Count - 1
248+
249+ Dim sEdit As String = listChk(iCtr)
250+ Dim listEdit01 As List(Of String) = cTools.listNav_SE(sEdit, "<", ">", True)
251+
252+ For Each uEdit01 As String In listEdit01
253+
254+ sEdit = sEdit.Replace(uEdit01, "")
255+ Next
256+
257+ listChk(iCtr) = sEdit
258+
259+ Next
260+
261+
262+
263+ End Sub
264+
265+ Private Sub ReMoveTopTitle()
266+
267+
268+
269+ End Sub
270+
271+ Private Sub chkListTopLine(ByRef listText As List(Of String), ByVal sTitle As String)
272+
273+ If listText.Count > 0 AndAlso sTitle.Length > 0 Then
274+ Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
275+ hapHtml.LoadHtml(listText(0))
276+ Dim chkNode = hapHtml.DocumentNode.SelectNodes("span")
277+
278+ If chkNode IsNot Nothing Then
279+
280+ If chkNode.Item(0).InnerText.Trim() = sTitle.Trim() Then
281+ listText.RemoveAt(0)
282+ End If
283+
284+ End If
285+
286+
287+ End If
288+
289+
290+ End Sub
291+
292+ Private Sub ResetImgUrl(ByRef sChapter As String)
293+
294+ Dim hapHtml As HtmlDocument = New HtmlDocument()
295+ hapHtml.LoadHtml(sChapter)
296+ Dim listTarget = hapHtml.DocumentNode.SelectNodes(("//img"))
297+ If listTarget IsNot Nothing Then
298+ For Each uTarget As HtmlNode In listTarget
299+ Dim imgScr As String = uTarget.Attributes("src").Value
300+ Dim sNewImg As String = cTools.sGaiji(imgScr, emCurreDep)
301+ If uTarget.OuterHtml.IndexOf("image-100") > -1 Then
302+ sNewImg = cTools.sMapImg(sNewImg, emCurreDep)
303+ End If
304+ sChapter = sChapter.Replace(uTarget.OuterHtml, sNewImg)
305+ Next
306+ End If
307+ End Sub
308+
309+End Class
Show on old repository browser