@@ -220,12 +220,15 @@ | ||
220 | 220 | |
221 | 221 | Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click |
222 | 222 | |
223 | - Dim cAutoEpub As New cDep2_006("C:\Users\DTC_PC07\Downloads\w\OEBPS\") | |
223 | + | |
224 | + | |
225 | + | |
226 | + Dim cAutoEpub As New cDep2_007("C:\Users\DTC_PC07\Downloads\db\") | |
224 | 227 | cAutoEpub.CreadEpub() |
225 | 228 | |
226 | 229 | |
227 | - Dim cEpub As New cEpub6(emEpub6.emEncCode.GB2321, emEpub6.emLan.ZH, "中短篇合集", "人民文学社", "ZDPXS_202011") | |
228 | - cEpub.bConvertToMobi = True | |
230 | + Dim cEpub As New cEpub6(emEpub6.emEncCode.GB2321, emEpub6.emLan.ZH, "渡边淳一合集", "渡边淳一", "DB_202012") | |
231 | + cEpub.bConvertToMobi = False | |
229 | 232 | cEpub.CreateEpub(cAutoEpub.mEpub) |
230 | 233 | MessageBox.Show("Finished") |
231 | 234 | System.Diagnostics.Process.Start(cEpub.sOutPutPathFolder) |
@@ -0,0 +1,347 @@ | ||
1 | +Imports System.IO | |
2 | +Imports HtmlAgilityPack | |
3 | + | |
4 | +Public Class cDep2_007 | |
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 | + mVolume.Title = mVolume.Title.Replace("世界十大中短篇小说家.", "") | |
44 | + | |
45 | + If ncxVolume.navPoint Is Nothing Then | |
46 | + mVolume.Title = ncxVolume.navLabel.text | |
47 | + mVolume.Scr = ncxVolume.content.src | |
48 | + Dim sPath As String = Path.Combine(bookPath, mVolume.Scr).Split("#").ToList(0) | |
49 | + Dim sTemp As String = sFileEditRead(sPath) | |
50 | + Dim listText As List(Of String) = GetListText(sTemp) | |
51 | + mVolume.listText = listText | |
52 | + mEpub.Add(mVolume) | |
53 | + Continue For | |
54 | + End If | |
55 | + | |
56 | + | |
57 | + For ctrChapter As Integer = 0 To ncxVolume.navPoint.Count - 1 | |
58 | + | |
59 | + | |
60 | + emCurreDep = emEpub6.emDep.Dep2 | |
61 | + Dim ncxChapter As ncxNavPointNavPoint = ncxVolume.navPoint(ctrChapter) | |
62 | + | |
63 | + | |
64 | + Dim mChapter As New modelChapter | |
65 | + | |
66 | + mChapter.Title = ncxChapter.navLabel.text | |
67 | + mChapter.Scr = ncxChapter.content.src | |
68 | + | |
69 | + If listSkip.Any(Function(x) mChapter.Title.IndexOf(x) > -1) Then | |
70 | + Continue For | |
71 | + End If | |
72 | + | |
73 | + Dim sPath As String = Path.Combine(bookPath, mChapter.Scr).Split("#").ToList(0) | |
74 | + | |
75 | + Dim sChapter As String = sFileEditRead(sPath) | |
76 | + Dim listText As List(Of String) = GetListText(sChapter) | |
77 | + | |
78 | + | |
79 | + If listText.Count = 0 Then | |
80 | + Dim sNewUrl As String = "text/part" & CInt(mChapter.Scr.Substring(9, 4) + 1).ToString().PadLeft(4, "0") & ".html" | |
81 | + mChapter.Scr = Path.Combine(bookPath, sNewUrl) | |
82 | + sChapter = sFileEditRead(mChapter.Scr) | |
83 | + listText = GetListText(sChapter) | |
84 | + End If | |
85 | + | |
86 | + | |
87 | + If ncxChapter.navPoint IsNot Nothing Then | |
88 | + | |
89 | + For ctrSp As Integer = 0 To ncxChapter.navPoint.Count - 1 | |
90 | + Dim ncxSp As ncxNavPointNavPointNavPoint = ncxVolume.navPoint(ctrChapter).navPoint(ctrSp) | |
91 | + sPath = Path.Combine(bookPath, ncxSp.content.src).Split("#").ToList(0) | |
92 | + sChapter = sFileEditRead(sPath) | |
93 | + Dim listTextTemp As List(Of String) = GetListText(sChapter) | |
94 | + listText.AddRange(listTextTemp) | |
95 | + Next | |
96 | + | |
97 | + End If | |
98 | + | |
99 | + mChapter.listText = listText | |
100 | + mVolume.listChapter.Add(mChapter) | |
101 | + | |
102 | + Next | |
103 | + | |
104 | + | |
105 | + mEpub.Add(mVolume) | |
106 | + | |
107 | + Next | |
108 | + | |
109 | + End Sub | |
110 | + | |
111 | + Private Function GetListText(ByVal sHtml) As List(Of String) | |
112 | + | |
113 | + GetListText = New List(Of String) | |
114 | + Dim apHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument() | |
115 | + apHtml.LoadHtml(sHtml) | |
116 | + Dim listHtmlNode = apHtml.DocumentNode.Descendants.Where(Function(x) x.Name = "p" OrElse x.Name = "h2") | |
117 | + For Each uHtmlNode As HtmlAgilityPack.HtmlNode In listHtmlNode | |
118 | + | |
119 | + If uHtmlNode.Name = "p" Then | |
120 | + Dim sTarget As String = uHtmlNode.InnerHtml | |
121 | + If listMobiRight.Any(Function(x) uHtmlNode.OuterHtml.Contains(x)) Then | |
122 | + sTarget = sTarget + emEpub6.spDl_Right | |
123 | + End If | |
124 | + GetListText.Add(sTarget) | |
125 | + End If | |
126 | + | |
127 | + If uHtmlNode.Name = "h2" Then | |
128 | + Dim sTarget As String = uHtmlNode.InnerHtml | |
129 | + sTarget = sTarget + emEpub6.spText_SubTitle | |
130 | + GetListText.Add(sTarget) | |
131 | + End If | |
132 | + | |
133 | + | |
134 | + If uHtmlNode.Name = "img" Then | |
135 | + | |
136 | + Dim imgScr As String = uHtmlNode.Attributes("src").Value | |
137 | + Dim sNewImg As String = cTools.sGaiji(imgScr, emCurreDep) | |
138 | + If uHtmlNode.OuterHtml.IndexOf("image-100") > -1 Then | |
139 | + sNewImg = cTools.sMapImg(imgScr, emCurreDep) | |
140 | + End If | |
141 | + GetListText.Add(sNewImg) | |
142 | + End If | |
143 | + | |
144 | + | |
145 | + Next | |
146 | + | |
147 | + End Function | |
148 | + | |
149 | + | |
150 | + Private Function sFileEditRead(ByVal sPath As String) As String | |
151 | + sFileEditRead = cTools.sFileReader(sPath, cEpub6.encUTF8) | |
152 | + | |
153 | + DelHtml(sFileEditRead) | |
154 | + | |
155 | + EditHref00(sFileEditRead) | |
156 | + EditHref01(sFileEditRead) | |
157 | + EditHref02(sFileEditRead) | |
158 | + EditHref03(sFileEditRead) | |
159 | + ResetImgUrl(sFileEditRead) | |
160 | + | |
161 | + End Function | |
162 | + | |
163 | + | |
164 | + Private Sub DelHtml(ByRef sHtml As String) | |
165 | + | |
166 | + Dim hapHtmlEdit As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument() | |
167 | + hapHtmlEdit.LoadHtml(sHtml) | |
168 | + Dim linqHap = hapHtmlEdit.DocumentNode.SelectNodes(("//img")) | |
169 | + | |
170 | + If linqHap IsNot Nothing Then | |
171 | + For Each uHap As HtmlNode In linqHap | |
172 | + uHap.Remove() | |
173 | + Next | |
174 | + End If | |
175 | + sHtml = hapHtmlEdit.DocumentNode.InnerHtml | |
176 | + | |
177 | + End Sub | |
178 | + | |
179 | + Private Sub EditHref00(ByRef sHtml As String) | |
180 | + | |
181 | + Dim hapHtmlEdit As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument() | |
182 | + hapHtmlEdit.LoadHtml(sHtml) | |
183 | + Dim linqHap = hapHtmlEdit.DocumentNode.SelectNodes(("//a")) | |
184 | + | |
185 | + If linqHap IsNot Nothing Then | |
186 | + | |
187 | + For Each uHap As HtmlNode In linqHap | |
188 | + | |
189 | + | |
190 | + If uHap.Attributes("href") IsNot Nothing Then | |
191 | + Dim sScr As String = uHap.Attributes("href").Value | |
192 | + | |
193 | + If sScr.Split("#").Count = 2 Then | |
194 | + sHtml = sHtml.Replace(sScr, "#" & sScr.Split("#")(1)) | |
195 | + Else | |
196 | + Dim sError As String = "" | |
197 | + End If | |
198 | + | |
199 | + End If | |
200 | + | |
201 | + | |
202 | + Next | |
203 | + | |
204 | + End If | |
205 | + | |
206 | + | |
207 | + End Sub | |
208 | + | |
209 | + | |
210 | + Private Sub EditHref01(ByRef sHtml As String) | |
211 | + | |
212 | + End Sub | |
213 | + | |
214 | + | |
215 | + Private Sub EditHref02(ByRef sHtml As String) | |
216 | + | |
217 | + End Sub | |
218 | + | |
219 | + | |
220 | + Private Sub EditHref03(ByRef sHtml As String) | |
221 | + | |
222 | + End Sub | |
223 | + | |
224 | + | |
225 | + Public Sub chkEPUB001(ByVal sKey As String) | |
226 | + | |
227 | + | |
228 | + For Each uSection As modelSection In mEpub | |
229 | + | |
230 | + For Each uVolume As modelVolume In uSection.listVolume | |
231 | + | |
232 | + Dim listChk = From dtSeq In uVolume.listText Where dtSeq.IndexOf(sKey) > -1 | |
233 | + Dim listStop1 As List(Of String) = listChk.ToList() | |
234 | + | |
235 | + If listStop1.Count > 0 Then | |
236 | + | |
237 | + Dim sString As String = String.Join(vbCrLf, listStop1) | |
238 | + Console.WriteLine(String.Join(vbCrLf, listStop1)) | |
239 | + | |
240 | + | |
241 | + If listStop1.Count > 0 Then | |
242 | + Dim sStop As String = "" | |
243 | + End If | |
244 | + | |
245 | + | |
246 | + Dim sHtml As String = String.Join(vbCrLf, uVolume.listText) | |
247 | + | |
248 | + | |
249 | + Dim listCHK_SP As List(Of String) = cTools.listNav_SE(sHtml, "<", ">", True) | |
250 | + | |
251 | + | |
252 | + If listCHK_SP.Count > 0 Then | |
253 | + Dim sStop As String = "" | |
254 | + End If | |
255 | + | |
256 | + | |
257 | + End If | |
258 | + | |
259 | + | |
260 | + | |
261 | + For Each uChapter As modelChapter In uVolume.listChapter | |
262 | + | |
263 | + Dim listChk2 = From dtSeq In uChapter.listText Where dtSeq.IndexOf(sKey) > -1 | |
264 | + | |
265 | + Dim listStop2 As List(Of String) = listChk.ToList() | |
266 | + | |
267 | + Console.WriteLine(String.Join(vbCrLf, listStop2)) | |
268 | + Dim sString As String = String.Join(vbCrLf, listStop1) | |
269 | + | |
270 | + If listStop2.Count > 0 Then | |
271 | + Dim sStop As String = "" | |
272 | + End If | |
273 | + | |
274 | + Next | |
275 | + | |
276 | + Next | |
277 | + | |
278 | + | |
279 | + Next | |
280 | + | |
281 | + End Sub | |
282 | + | |
283 | + Public Sub chkEPUB002(ByRef listChk As List(Of String)) | |
284 | + | |
285 | + For iCtr As Integer = 0 To listChk.Count - 1 | |
286 | + | |
287 | + Dim sEdit As String = listChk(iCtr) | |
288 | + Dim listEdit01 As List(Of String) = cTools.listNav_SE(sEdit, "<", ">", True) | |
289 | + | |
290 | + For Each uEdit01 As String In listEdit01 | |
291 | + | |
292 | + sEdit = sEdit.Replace(uEdit01, "") | |
293 | + Next | |
294 | + | |
295 | + listChk(iCtr) = sEdit | |
296 | + | |
297 | + Next | |
298 | + | |
299 | + | |
300 | + | |
301 | + End Sub | |
302 | + | |
303 | + Private Sub ReMoveTopTitle() | |
304 | + | |
305 | + | |
306 | + | |
307 | + End Sub | |
308 | + | |
309 | + Private Sub chkListTopLine(ByRef listText As List(Of String), ByVal sTitle As String) | |
310 | + | |
311 | + If listText.Count > 0 AndAlso sTitle.Length > 0 Then | |
312 | + Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument() | |
313 | + hapHtml.LoadHtml(listText(0)) | |
314 | + Dim chkNode = hapHtml.DocumentNode.SelectNodes("span") | |
315 | + | |
316 | + If chkNode IsNot Nothing Then | |
317 | + | |
318 | + If chkNode.Item(0).InnerText.Trim() = sTitle.Trim() Then | |
319 | + listText.RemoveAt(0) | |
320 | + End If | |
321 | + | |
322 | + End If | |
323 | + | |
324 | + | |
325 | + End If | |
326 | + | |
327 | + | |
328 | + End Sub | |
329 | + | |
330 | + Private Sub ResetImgUrl(ByRef sChapter As String) | |
331 | + | |
332 | + Dim hapHtml As HtmlDocument = New HtmlDocument() | |
333 | + hapHtml.LoadHtml(sChapter) | |
334 | + Dim listTarget = hapHtml.DocumentNode.SelectNodes(("//img")) | |
335 | + If listTarget IsNot Nothing Then | |
336 | + For Each uTarget As HtmlNode In listTarget | |
337 | + Dim imgScr As String = uTarget.Attributes("src").Value | |
338 | + Dim sNewImg As String = cTools.sGaiji(imgScr, emCurreDep) | |
339 | + If uTarget.OuterHtml.IndexOf("image-100") > -1 Then | |
340 | + sNewImg = cTools.sMapImg(sNewImg, emCurreDep) | |
341 | + End If | |
342 | + sChapter = sChapter.Replace(uTarget.OuterHtml, sNewImg) | |
343 | + Next | |
344 | + End If | |
345 | + End Sub | |
346 | + | |
347 | +End Class |
@@ -9,13 +9,10 @@ | ||
9 | 9 | |
10 | 10 | |
11 | 11 | For Each unitFile As FileInfo In listFile |
12 | - | |
13 | 12 | Dim sNewFullName As String = unitFile.FullName.Replace("[BeanSub&FZSD&VCB-Studio] ", "").Replace("[Ma10p_1080p][x265_flac_aac]", "") |
14 | 13 | sNewFullName = sNewFullName.Replace("[Ma10p_1080p]", "").Replace("[x265_flac]", "") |
15 | 14 | Console.WriteLine(sNewFullName) |
16 | - | |
17 | 15 | File.Move(unitFile.FullName, sNewFullName) |
18 | - | |
19 | 16 | Next |
20 | 17 | |
21 | 18 |
@@ -32,7 +32,7 @@ | ||
32 | 32 | |
33 | 33 | <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ |
34 | 34 | Protected Overrides Sub OnCreateMainForm() |
35 | - Me.MainForm = Global.AutoEpub3.MainTools | |
35 | + Me.MainForm = Global.AutoEpub3.AutoEpub8 | |
36 | 36 | End Sub |
37 | 37 | End Class |
38 | 38 | End Namespace |