add support for Archive chapters to Local source

This commit is contained in:
Aria Moradi
2021-09-18 19:14:06 +04:30
parent ea8fb2c70a
commit 52334087ad
14 changed files with 564 additions and 169 deletions

View File

@@ -7,7 +7,7 @@ package suwayomi.tachidesk.manga.impl
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.local.LocalSource
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.HttpSource
import org.jetbrains.exposed.sql.and
@@ -60,6 +60,20 @@ object Page {
pageEntry[PageTable.imageUrl]
)
// we treat Local source differently
if (mangaEntry[MangaTable.sourceReference] == LocalSource.ID) {
// is of archive format
if (LocalSource.pageCache.containsKey(chapterEntry[ChapterTable.url])) {
val pageStream = LocalSource.pageCache[chapterEntry[ChapterTable.url]]!![index]()
return pageStream to "image/jpeg"
}
// is of directory format
return CachedImageResponse.getImageResponse {
source.fetchImage(tachiyomiPage).awaitSingle()
}
}
if (pageEntry[PageTable.imageUrl] == null) {
val trueImageUrl = getTrueImageUrl(tachiyomiPage, source)
transaction {
@@ -69,13 +83,6 @@ object Page {
}
}
// don't cache images for Local Source
if (mangaEntry[MangaTable.sourceReference] == LocalSource.ID) {
return CachedImageResponse.getImageResponse {
source.fetchImage(tachiyomiPage).awaitSingle()
}
}
val chapterDir = getChapterDir(mangaId, chapterId)
File(chapterDir).mkdirs()
val fileName = getPageName(index, chapterDir) // e.g. 001