chapter image fix for bato.to

This commit is contained in:
Aria Moradi 2021-03-28 03:43:52 +04:30
parent 1802271358
commit a567701639
5 changed files with 11 additions and 4 deletions

View File

@ -126,6 +126,13 @@ fun getChapter(chapterIndex: Int, mangaId: Int): ChapterDataClass {
it[this.chapter] = chapterId
}
}
} else {
transaction {
PageTable.update({ (PageTable.chapter eq chapterId) and (PageTable.index eq page.index) }) {
it[url] = page.url
it[imageUrl] = page.imageUrl
}
}
}
}

View File

@ -195,7 +195,7 @@ fun getExtensionIcon(apkName: String): Pair<InputStream, String> {
val saveDir = "${applicationDirs.extensionsRoot}/icon"
return getCachedResponse(saveDir, apkName) {
return getCachedImageResponse(saveDir, apkName) {
network.client.newCall(
GET(iconUrl)
).execute()

View File

@ -93,7 +93,7 @@ fun getThumbnail(mangaId: Int): Pair<InputStream, String> {
val saveDir = applicationDirs.thumbnailsRoot
val fileName = mangaId.toString()
return getCachedResponse(saveDir, fileName) {
return getCachedImageResponse(saveDir, fileName) {
val sourceId = mangaEntry[MangaTable.sourceReference]
val source = getHttpSource(sourceId)
var thumbnailUrl = mangaEntry[MangaTable.thumbnail_url]

View File

@ -58,7 +58,7 @@ fun getPageImage(mangaId: Int, chapterIndex: Int, index: Int): Pair<InputStream,
File(saveDir).mkdirs()
val fileName = index.toString()
return getCachedResponse(saveDir, fileName) {
return getCachedImageResponse(saveDir, fileName) {
source.fetchImage(tachiPage).toBlocking().first()
}
}

View File

@ -55,7 +55,7 @@ private fun BufferedSource.saveTo(stream: OutputStream) {
}
}
fun getCachedResponse(saveDir: String, fileName: String, fetcher: () -> Response): Pair<InputStream, String> {
fun getCachedImageResponse(saveDir: String, fileName: String, fetcher: () -> Response): Pair<InputStream, String> {
val cachedFile = findFileNameStartingWith(saveDir, fileName)
val filePath = "$saveDir/$fileName"
if (cachedFile != null) {