|
|
@ -127,10 +127,10 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter -> |
|
|
|
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter -> |
|
|
|
BookHelp.getContent(book, chapter)?.let { content -> |
|
|
|
BookHelp.getContent(book, chapter)?.let { content -> |
|
|
|
content.split("\n").forEachIndexed { index, text -> |
|
|
|
content.split("\n").forEachIndexed { index, text -> |
|
|
|
val matcher = AppPattern.imgPattern.matcher(text) |
|
|
|
val matches = AppPattern.imgPattern.toRegex().findAll(input = text) |
|
|
|
if (matcher.find()) { |
|
|
|
matches.forEach { matchResult -> |
|
|
|
matcher.group(1)?.let { |
|
|
|
matchResult.groupValues[1].let { |
|
|
|
val src = NetworkUtils.getAbsoluteURL(chapter.url, it) |
|
|
|
val src=NetworkUtils.getAbsoluteURL(chapter.url, it) |
|
|
|
srcList.add(Triple(chapter.title, index, src)) |
|
|
|
srcList.add(Triple(chapter.title, index, src)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -272,14 +272,16 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
val data = StringBuilder("") |
|
|
|
val data = StringBuilder("") |
|
|
|
content.split("\n").forEach { text -> |
|
|
|
content.split("\n").forEach { text -> |
|
|
|
var text1 = text |
|
|
|
var text1 = text |
|
|
|
val matcher = AppPattern.imgPattern.matcher(text) |
|
|
|
val matches = AppPattern.imgPattern.toRegex().findAll(input = text) |
|
|
|
if (matcher.find()) { |
|
|
|
matches.forEach { matchResult -> |
|
|
|
matcher.group(1)?.let { |
|
|
|
matchResult.groupValues[1].let { |
|
|
|
val src = NetworkUtils.getAbsoluteURL(chapter.url, it) |
|
|
|
val src=NetworkUtils.getAbsoluteURL(chapter.url, it) |
|
|
|
setPic(src, book, epubBook) |
|
|
|
setPic(src, book, epubBook) |
|
|
|
text1 = text.replace(src, MD5Utils.md5Encode16(src) + ".jpg") |
|
|
|
text1 = text1.replace(src, MD5Utils.md5Encode16(src) + ".jpg") |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data.append(text1).append("\n") |
|
|
|
data.append(text1).append("\n") |
|
|
|
} |
|
|
|
} |
|
|
|
return data.toString() |
|
|
|
return data.toString() |
|
|
|