• R/O
  • SSH
  • HTTPS

autocodeforsql: Commit


Commit MetaInfo

Revisão355 (tree)
Hora2020-03-17 15:57:08
Autorhilinwei

Mensagem de Log

Mudança Sumário

Diff

--- AutoEpub3/AutoEpub7.vb (revision 354)
+++ AutoEpub3/AutoEpub7.vb (revision 355)
@@ -248,49 +248,106 @@
248248
249249 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
250250
251- Dim dEpubPath As String = "C:\Users\DataTrade\Downloads\CD1\text\"
251+ Dim dEpubPath As String = "C:\Users\DataTrade\Downloads\GZ\"
252252 Dim mEpub As New List(Of modelChapter)
253253 Dim mChapter As New modelChapter
254- Dim sChapter As String
254+ Dim sChapter As String = String.Empty
255255 Dim listText As New List(Of String)
256256 Dim sHtml As String = String.Empty
257257 Dim listError As New List(Of String)
258258
259- Dim listMobiRight As List(Of String) = {"luokuan-r"}.ToList()
259+ Dim listMobiRight As List(Of String) = {"kindle-cn-signature"}.ToList()
260+ Dim listRep As New List(Of cValues)
261+ listRep.Add(New cValues("<br class=""calibre7""/>", "</p><p class=""kindle-cn-poem-left"">"))
260262
261263
262-
263264 Try
264- Dim ncxFilePath As String = dEpubPath & "part0000.html"
265+ Dim ncxFilePath As String = dEpubPath & "toc.ncx"
266+ Dim fs As System.IO.FileStream = New System.IO.FileStream(ncxFilePath, System.IO.FileMode.Open)
267+ Dim serializer As System.Xml.Serialization.XmlSerializer = New System.Xml.Serialization.XmlSerializer(GetType(ncx))
268+ Dim fileNCX As ncx = CType(serializer.Deserialize(fs), ncx)
269+ fs.Dispose()
265270
266- sHtml = cTools.sFileReader(ncxFilePath, cEpub6.encUTF8)
267271
268- Dim listChapter As List(Of String) = cTools.listNav_SE(sHtml, "<a href", "</a>", True)
269- listChapter.RemoveAt(0)
270272
271- For Each uChapter As String In listChapter
273+ For Each eachPoint As ncxNavPoint In fileNCX.navMap
274+ mChapter = New modelChapter
275+ mChapter.Title = eachPoint.navLabel.text.Trim()
276+ mChapter.Scr = eachPoint.content.src.Split("#")(0)
272277
273- listError.Add(uChapter)
278+ If mChapter.Title = "上" OrElse mChapter.Title = "下" Then
274279
275- mChapter = New modelChapter
276- mChapter.Title = cTools.listNav_SE(uChapter, ">", "</a>", False)(0)
277- mChapter.Scr = cTools.listNav_SE(uChapter, "part", ".html", True)(0)
278280
279- sChapter = cTools.sFileReader(dEpubPath & mChapter.Scr, cEpub6.encUTF8)
280- listText = cTools.listText_P(sChapter, listMobiRight)
281- mChapter.listText = listText
281+ For Each eachSubPoint As ncxNavPointNavPoint In eachPoint.navPoint
282282
283- If listText.Count > 0 Then
283+ mChapter = New modelChapter
284+ mChapter.Title = eachSubPoint.navLabel.text.Trim()
285+ mChapter.Scr = eachSubPoint.content.src.Split("#")(0)
286+ sChapter = cTools.sFileReader(dEpubPath & mChapter.Scr, cEpub6.encUTF8)
287+ listText = cTools.listText_P(sChapter, listMobiRight, listRep)
288+
289+ If listText.Count = 2 Then
290+ mChapter.Scr = mChapter.Scr.Replace("000.html", "001.html")
291+ sChapter = cTools.sFileReader(dEpubPath & mChapter.Scr, cEpub6.encUTF8)
292+
293+ Dim listMap As List(Of String) = cTools.listNav_SE(sChapter, "<div class=""kindle-cn-bodycontent-div-alone"">", "</div>", True)
294+
295+ For Each uMap As String In listMap
296+
297+ Dim sMapKey As String = cTools.listNav_SE(uMap, "<div class=""kindle-cn-bodycontent-div-alone"">", "</div>", False)(0)
298+ sChapter = sChapter.Replace(uMap, "<p>" & sMapKey & "</p>")
299+
300+ Next
301+
302+
303+ Dim listImg As List(Of String) = cTools.listNav_SE(sChapter, "<img", "/>", True)
304+ For Each uImg As String In listImg
305+
306+ Dim sImgUrl As String = cTools.listNav_SE(uImg, "src=""", """/>", False)(0)
307+
308+ If uImg.IndexOf("alone") > -1 Then
309+ Dim sImgKey As String = cTools.sMapImg(sImgUrl, emEpub6.emUrlImgDep.Chapter)
310+ sChapter = sChapter.Replace(uImg, sImgKey)
311+ Else
312+ Dim sImgKey As String = cTools.sGaiji(sImgUrl, emEpub6.emUrlImgDep.Chapter)
313+ sChapter = sChapter.Replace(uImg, sImgKey)
314+ End If
315+
316+
317+ Next
318+
319+
320+ 'Dim listImg As List(Of String) = cTools.listNav_SE(sChapter, "<img", "/>", True)
321+ 'For Each eachImg As String In listImg
322+ ' sChapter = sChapter.Replace(eachImg, "<p>" & eachImg & emEpub6.spText_Img & "</p>")
323+ 'Next
324+ listText = cTools.listText_P(sChapter, listMobiRight, listRep)
325+
326+ End If
327+
328+ mChapter.listText = listText
329+ mEpub.Add(mChapter)
330+
331+ Next
332+
333+
334+ Else
335+
336+ sChapter = cTools.sFileReader(dEpubPath & mChapter.Scr, cEpub6.encUTF8)
337+ listText = cTools.listText_P(sChapter, listMobiRight, listRep)
338+ mChapter.listText = listText
284339 mEpub.Add(mChapter)
340+
285341 End If
286342
287343 Next
288344
345+ mEpub.RemoveAt(1)
289346
290- Dim cEpub As New cEpub6(emEpub6.emEncCode.GB2321, emEpub6.emLan.ZH, "SP0", "画梁春尽落香尘", "刘心武", "HLCJLXC_202002")
291- cEpub.bConvertToMobi = False
347+ Dim cEpub As New cEpub6(emEpub6.emEncCode.GB2321, emEpub6.emLan.ZH, "大汉公主", "吴蔚", "DHGZ_202003")
348+ cEpub.bConvertToMobi = True
292349 cEpub.CreateEpub(mEpub)
293- MessageBox.Show("Finished")
350+ System.Diagnostics.Process.Start(cEpub.sOutPutPathFolder)
294351
295352
296353 Catch ex As Exception
--- AutoEpub3/My Project/Application.Designer.vb (revision 354)
+++ AutoEpub3/My Project/Application.Designer.vb (revision 355)
@@ -32,7 +32,7 @@
3232
3333 <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
3434 Protected Overrides Sub OnCreateMainForm()
35- Me.MainForm = Global.AutoEpub3.StudyCode
35+ Me.MainForm = Global.AutoEpub3.AutoEpub7
3636 End Sub
3737 End Class
3838 End Namespace
--- AutoEpub3/cEpub6.vb (revision 354)
+++ AutoEpub3/cEpub6.vb (revision 355)
@@ -1001,6 +1001,7 @@
10011001 sbText.Append(sText)
10021002 sbText.Append("</p>")
10031003 htmlAddText = sbText.ToString()
1004+
10041005 End If
10051006
10061007
--- AutoEpub3/cTools.vb (revision 354)
+++ AutoEpub3/cTools.vb (revision 355)
@@ -145,7 +145,50 @@
145145 End Function
146146
147147
148+ Public Shared Function listText_P(str As String, listMobiRight As List(Of String), listRep As List(Of cValues)) As List(Of String)
148149
150+ For Each eachRep As cValues In listRep
151+ str = str.Replace(eachRep.sValue1, eachRep.sValue2)
152+ Next
153+
154+ str = str.Replace("<P", "<p")
155+ str = str.Replace("</P>", "</p>")
156+ listText_P = New List(Of String)
157+
158+
159+
160+ Dim listTemp As List(Of String) = cTools.listNav_SE(str, "<p", "</p>", False)
161+
162+ For Each eachLine As String In listTemp
163+
164+ Dim dStart As Decimal = eachLine.IndexOf(">")
165+ Dim sTarget As String = eachLine.Substring(dStart + 1)
166+ If listMobiRight.Any(Function(x) eachLine.Contains(x)) Then
167+ sTarget = sTarget + emEpub6.spDl_Right
168+ End If
169+
170+ Dim listHref As List(Of String) = cTools.listNav_SE(sTarget, "href=""", """>", True)
171+
172+
173+ For Each eachHref As String In listHref
174+
175+
176+ Console.WriteLine(eachHref)
177+
178+ Dim sKey As String = eachHref.Split("#")(1).Replace(""">", "")
179+ sTarget = sTarget.Replace(eachHref, "href=""#" & sKey & """>")
180+
181+ Next
182+
183+
184+ listText_P.Add(sTarget)
185+
186+ Next
187+
188+ End Function
189+
190+
191+
149192 Public Shared Function listNav_SE(str As String, s As String, e As String, ByVal bHasSE As Boolean) As List(Of String)
150193
151194 listNav_SE = New List(Of String)
@@ -1142,15 +1185,15 @@
11421185 sScr = "Img/" & listTemp(listTemp.Count - 1)
11431186
11441187 If iDep = emEpub6.emUrlImgDep.Section Then
1145- sScr = "" & sScr
1188+ sScr = "../../../" & sScr
11461189 End If
11471190
11481191 If iDep = emEpub6.emUrlImgDep.Volume Then
1149- sScr = "../" & sScr
1192+ sScr = "../../" & sScr
11501193 End If
11511194
11521195 If iDep = emEpub6.emUrlImgDep.Chapter Then
1153- sScr = "../../" & sScr
1196+ sScr = "../" & sScr
11541197 End If
11551198
11561199 sGaiji = "<img class=""mobiImgChar_Bottom_5px"" alt="""" src=""" & sScr & """/>"
@@ -1158,6 +1201,30 @@
11581201 End Function
11591202
11601203
1204+ Public Shared Function sMapImg(ByVal sScr As String, ByVal iDep As emEpub6.emUrlImgDep) As String
1205+
1206+ Dim listTemp As List(Of String) = sScr.Split("/").ToList()
1207+ sScr = "Img/" & listTemp(listTemp.Count - 1)
1208+
1209+ If iDep = emEpub6.emUrlImgDep.Section Then
1210+ sScr = "../../../" & sScr
1211+ End If
1212+
1213+ If iDep = emEpub6.emUrlImgDep.Volume Then
1214+ sScr = "../../" & sScr
1215+ End If
1216+
1217+ If iDep = emEpub6.emUrlImgDep.Chapter Then
1218+ sScr = "../" & sScr
1219+ End If
1220+
1221+ sMapImg = "<img class=""mobiImgMap"" alt="""" src=""" & sScr & """/>"
1222+
1223+ End Function
1224+
1225+
1226+
1227+
11611228 Public Shared Function bHasHiragana(ByVal str As String) As Boolean
11621229
11631230 Return Regex.IsMatch(str, "^\p{IsHiragana}*$")
Show on old repository browser