• R/O
  • SSH
  • HTTPS

autocodeforsql: Commit


Commit MetaInfo

Revisão377 (tree)
Hora2020-09-10 16:23:54
Autorhilinwei

Mensagem de Log

Mudança Sumário

Diff

--- AutoEpub3/AutoEpub8.vb (revision 376)
+++ AutoEpub3/AutoEpub8.vb (revision 377)
@@ -2,12 +2,12 @@
22 Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
33
44
5- Dim cAutoEpub As New cDep2_002("C:\Users\DTC_PC07\Downloads\K1\")
5+ Dim cAutoEpub As New cDep3_003("C:\Users\DTC_PC07\Downloads\dygw\OEBPS\")
66 cAutoEpub.CreadEpub()
77
88
9- Dim cEpub As New cEpub6(emEpub6.emEncCode.GB2321, emEpub6.emLan.ZH, "F1", "松本清张选集", "松本清张", "SBQZ_202009")
10- cEpub.bConvertToMobi = True
9+ Dim cEpub As New cEpub6(emEpub6.emEncCode.GB2321, emEpub6.emLan.ZH, "A1", "东野圭吾 伽利略系列", "东野圭吾", "DYGW01_202009")
10+ cEpub.bConvertToMobi = False
1111 cEpub.CreateEpub(cAutoEpub.mEpub)
1212 MessageBox.Show("Finished")
1313 System.Diagnostics.Process.Start(cEpub.sOutPutPathFolder)
--- AutoEpub3/Logic/DEP3/cDep3_003.vb (nonexistent)
+++ AutoEpub3/Logic/DEP3/cDep3_003.vb (revision 377)
@@ -0,0 +1,234 @@
1+Imports System.IO
2+
3+Public Class cDep3_003
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+ Dim sText As String = String.Empty
22+ Dim listLine As New List(Of String)
23+
24+ Dim ncxFilePath As String = Path.Combine(bookPath, "toc.ncx")
25+
26+ Dim fs As System.IO.FileStream = New System.IO.FileStream(ncxFilePath, System.IO.FileMode.Open)
27+ Dim serializer As System.Xml.Serialization.XmlSerializer = New System.Xml.Serialization.XmlSerializer(GetType(ncx))
28+ Dim model As ncx = CType(serializer.Deserialize(fs), ncx)
29+ fs.Dispose()
30+ fs = Nothing
31+
32+
33+ Dim linqPick = From dtSeq In model.navMap Where dtSeq.navLabel.text.IndexOf("伽利略") > -1
34+
35+ Dim listPick As List(Of ncxNavPoint) = linqPick.ToList()
36+
37+
38+ For iCtr As Integer = 0 To listPick.Count - 1
39+
40+ Dim ncxSection As ncxNavPoint = listPick(iCtr)
41+
42+ Dim mSection As New modelSection()
43+ mSection.Title = cTools.listNav_SE(ncxSection.navLabel.text, "《", "》", False)(0)
44+
45+ Dim ncxVolume As List(Of ncxNavPointNavPoint) = ncxSection.navPoint.Where(Function(x) x.navLabel.text.IndexOf("第") > -1).ToList()
46+
47+ If ncxVolume.Count = 0 Then
48+ ncxVolume = ncxSection.navPoint.ToList()
49+ End If
50+
51+
52+ For ctrVolume As Integer = 0 To ncxVolume.Count - 1
53+
54+ Dim mVolume As New modelVolume
55+ mVolume.Title = ncxVolume(ctrVolume).navLabel.text
56+
57+
58+ If listSkip.Any(Function(x) mVolume.Title.IndexOf(x) > -1) Then
59+ Continue For
60+ End If
61+
62+
63+ If mVolume.Title.IndexOf("第十九章") > -1 Then
64+ Dim sStop As String = "1"
65+ End If
66+
67+
68+ Dim indexFrom As Integer = ncxSection.navPoint.ToList().IndexOf(ncxVolume(ctrVolume))
69+
70+ Dim indexTo As Integer = ncxSection.navPoint.Count - 1
71+
72+ If ctrVolume < ncxVolume.Count - 1 Then
73+ indexTo = ncxSection.navPoint.ToList().IndexOf(ncxVolume(ctrVolume + 1))
74+ End If
75+
76+ If indexTo - indexFrom <= 1 Then
77+
78+ Dim ncxChapter As ncxNavPointNavPoint = ncxSection.navPoint(indexFrom)
79+
80+ Dim sPath As String = Path.Combine(bookPath, ncxChapter.content.src).Split("#").ToList(0)
81+
82+ Dim sVolume As String = cTools.sFileReader(sPath, cEpub6.encUTF8)
83+ sReplaceHtml(sVolume, emEpub6.emUrlImgDep.Volume)
84+
85+ Dim listText As List(Of String) = cTools.listText_P(sVolume)
86+
87+ mVolume.listText = listText
88+
89+ End If
90+
91+
92+ Dim iTemp As Integer = 1
93+
94+ For ctrChapter As Integer = indexFrom + 1 To indexTo - 1
95+
96+
97+ Dim ncxChapter As ncxNavPointNavPoint = ncxSection.navPoint(ctrChapter)
98+
99+ Dim mChapter As New modelChapter
100+
101+ mChapter.Title = iTemp
102+ mChapter.Scr = ncxChapter.content.src
103+
104+ If listSkip.Any(Function(x) mChapter.Title.IndexOf(x) > -1) Then
105+ Continue For
106+ End If
107+
108+
109+ Dim sPath As String = Path.Combine(bookPath, mChapter.Scr).Split("#").ToList(0)
110+
111+ Dim sChapter As String = cTools.sFileReader(sPath, cEpub6.encUTF8)
112+ sReplaceHtml(sChapter, emEpub6.emUrlImgDep.Section)
113+ Dim listText As List(Of String) = cTools.listText_P(sChapter)
114+
115+ mChapter.listText = listText
116+
117+ mVolume.listChapter.Add(mChapter)
118+
119+ iTemp += 1
120+ Next
121+
122+
123+ mSection.listVolume.Add(mVolume)
124+
125+ Next
126+
127+ mEpub.Add(mSection)
128+ Next
129+
130+
131+ mEpub.Insert(5, addSection)
132+
133+ mEpub.RemoveAt(6)
134+
135+ End Sub
136+
137+ Private Sub ResetImgUrl(ByRef sChapter As String)
138+
139+ Dim listImg As List(Of String) = cTools.listNav_SE(sChapter, "<img", "/>", True)
140+ For Each eachImg As String In listImg
141+ Dim sScr As String = eachImg.Split("/").ToList()(2).Split("""").ToList()(0)
142+ Dim sNewImg As String = cTools.sGaiji(sScr, emEpub6.emUrlImgDep.Volume)
143+
144+ If eachImg.IndexOf("calibre20") > -1 Then
145+ sNewImg = cTools.sMapImg(sScr, emEpub6.emUrlImgDep.Volume)
146+ End If
147+
148+ sChapter = sChapter.Replace(eachImg, sNewImg)
149+ Next
150+
151+
152+ End Sub
153+
154+ Private Function addSection() As modelSection
155+
156+ addSection = New modelSection
157+
158+ addSection.Title = "盛夏的方程式2"
159+
160+ Dim sPath As String = "C:\Users\DTC_PC07\Downloads\BS1\"
161+
162+ Try
163+
164+ Dim ncxFilePath As String = Path.Combine(sPath, "toc.ncx")
165+ Dim fs As System.IO.FileStream = New System.IO.FileStream(ncxFilePath, System.IO.FileMode.Open)
166+ Dim serializer As System.Xml.Serialization.XmlSerializer = New System.Xml.Serialization.XmlSerializer(GetType(ncx))
167+ Dim fileNCX As ncx = CType(serializer.Deserialize(fs), ncx)
168+
169+ For ctrChapter As Integer = 0 To fileNCX.navMap.Count - 1
170+
171+ Dim fileChapter As ncxNavPoint = fileNCX.navMap(ctrChapter)
172+
173+ Dim mVolume As New modelVolume
174+ mVolume.Title = fileChapter.navLabel.text
175+ mVolume.Scr = fileChapter.content.src.Split("#").ToList()(0)
176+
177+ If listSkip.Any(Function(x) mVolume.Title.IndexOf(x) > -1) Then
178+ Continue For
179+ End If
180+
181+ Dim sChapter As String = cTools.sFileReader(sPath & mVolume.Scr, cEpub6.encUTF8)
182+
183+
184+ Dim listText As List(Of String) = cTools.listText_P(sChapter)
185+
186+
187+ mVolume.listText = listText
188+
189+
190+ addSection.listVolume.Add(mVolume)
191+ Next
192+
193+
194+ Catch ex As Exception
195+
196+ MessageBox.Show(ex.Message)
197+
198+ End Try
199+
200+
201+ End Function
202+
203+
204+ Private Sub sReplaceHtml(ByRef sHtml As String, ByVal kbnDep As emEpub6.emUrlImgDep)
205+
206+ 'sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00076.jpg"" /> ", "坚")
207+ sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00076.jpg"" />" & vbCrLf & " ", "坚")
208+
209+ ResetImgUrl(sHtml, kbnDep)
210+ End Sub
211+
212+
213+
214+ Private Sub ResetImgUrl(ByRef sChapter As String, ByVal kbnDep As emEpub6.emUrlImgDep)
215+
216+ Dim listImg As List(Of String) = cTools.listNav_SE(sChapter, "<img", "/>", True)
217+ For Each eachImg As String In listImg
218+ Dim sScr As String = eachImg.Split("/").ToList()(2).Split("""").ToList()(0)
219+ Dim sNewImg As String = cTools.sGaiji(sScr, kbnDep)
220+
221+ If eachImg.IndexOf("calibre20") > -1 Then
222+ sNewImg = cTools.sMapImg(sScr, kbnDep)
223+ End If
224+
225+ sChapter = sChapter.Replace(eachImg, sNewImg)
226+ Next
227+
228+
229+ End Sub
230+
231+
232+
233+
234+End Class
Show on old repository browser