|
|
|
@ -121,6 +121,14 @@ class EpubFile(var book: Book) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun getContent(chapter: BookChapter): String? { |
|
|
|
|
/** |
|
|
|
|
* <image width="1038" height="670" xlink:href="cover.jpeg"/> |
|
|
|
|
* <img width="1038" height="670" src="cover.jpeg"/> |
|
|
|
|
* titlepage.xhtml |
|
|
|
|
*/ |
|
|
|
|
if (chapter.url == "titlepage.xhtml") { |
|
|
|
|
return "<img src=\"cover.jpeg\" />" |
|
|
|
|
} |
|
|
|
|
/*获取当前章节文本*/ |
|
|
|
|
epubBook?.let { epubBook -> |
|
|
|
|
val nextUrl = chapter.getVariable("nextUrl") |
|
|
|
@ -139,10 +147,10 @@ class EpubFile(var book: Book) { |
|
|
|
|
* content src text/000001.html(当前章节) |
|
|
|
|
- * content src text/000001.html#toc_id_x (下一章节) |
|
|
|
|
*/ |
|
|
|
|
if (!nextUrl.isNullOrBlank() && res.href == nextUrl!!.substringBeforeLast("#")) break |
|
|
|
|
if (res.href == nextUrl?.substringBeforeLast("#")) break |
|
|
|
|
} else if (isChapter) { |
|
|
|
|
// fix 最后一章存在多个html时 内容缺失 |
|
|
|
|
if (!nextUrl.isNullOrBlank() && res.href == nextUrl.substringBeforeLast("#")) { |
|
|
|
|
if (res.href == nextUrl?.substringBeforeLast("#")) { |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
elements.add(getBody(res, startFragmentId, endFragmentId)) |
|
|
|
@ -188,6 +196,7 @@ class EpubFile(var book: Book) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun getImage(href: String): InputStream? { |
|
|
|
|
if (href == "cover.jpeg") return epubBook?.coverImage?.inputStream |
|
|
|
|
val abHref = href.replace("../", "") |
|
|
|
|
return epubBook?.resources?.getByHref(abHref)?.inputStream |
|
|
|
|
} |
|
|
|
@ -276,8 +285,12 @@ class EpubFile(var book: Book) { |
|
|
|
|
while (i < contents.size) { |
|
|
|
|
val content = contents[i] |
|
|
|
|
if (!content.mediaType.toString().contains("htm")) continue |
|
|
|
|
/*检索到第一章href停止*/ |
|
|
|
|
if (refs[0].completeHref == content.href) break |
|
|
|
|
/** |
|
|
|
|
* 检索到第一章href停止 |
|
|
|
|
* completeHref可能有fragment(#id) 必须去除 |
|
|
|
|
* fix https://github.com/gedoor/legado/issues/1932 |
|
|
|
|
*/ |
|
|
|
|
if (refs[0].completeHref.substringBeforeLast("#") == content.href) break |
|
|
|
|
val chapter = BookChapter() |
|
|
|
|
var title = content.title |
|
|
|
|
if (TextUtils.isEmpty(title)) { |
|
|
|
|