mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-11 06:44:34 -05:00
Add support for opds-pse for undownloaded chapters (#1278)
* Add OPDS page streaming for undownloaded chapters * Add [D] in chapter title prefix when isDownloaded * Removed Chapter.isDownloaded check in query for other opds endpoints * Add chapter progression tracking for streaming and refactor code * dd ❌ Unicode for chapters with 0 pages [post pageRefresh] * Add Library Updates feed and remove redundant metadata fetching for OPDS chapters and manga * Address PR comments & add chapter markAsRead for cbzDownload * Address PR comment/s * Rem. markAsRead for chapter download * Rem. markAsRead for chapter download --------- Co-authored-by: ShowY <showypro@gmail.com>
This commit is contained in:
@@ -13,7 +13,6 @@ import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||
import suwayomi.tachidesk.manga.model.table.toDataClass
|
||||
import suwayomi.tachidesk.server.serverConfig
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
|
||||
object ChapterDownloadHelper {
|
||||
@@ -48,26 +47,28 @@ object ChapterDownloadHelper {
|
||||
return FolderProvider(mangaId, chapterId)
|
||||
}
|
||||
|
||||
suspend fun getCbzDownload(chapterId: Int): Triple<InputStream, String, String> {
|
||||
fun getArchiveStreamWithSize(
|
||||
mangaId: Int,
|
||||
chapterId: Int,
|
||||
): Pair<InputStream, Long> = provider(mangaId, chapterId).getAsArchiveStream()
|
||||
|
||||
fun getCbzForDownload(chapterId: Int): Triple<InputStream, String, Long> {
|
||||
val (chapterData, mangaTitle) =
|
||||
transaction {
|
||||
val row =
|
||||
(ChapterTable innerJoin MangaTable)
|
||||
.select(ChapterTable.columns + MangaTable.columns)
|
||||
.where { ChapterTable.id eq chapterId }
|
||||
.firstOrNull() ?: throw Exception("Chapter not found")
|
||||
.firstOrNull() ?: throw IllegalArgumentException("ChapterId $chapterId not found")
|
||||
val chapter = ChapterTable.toDataClass(row)
|
||||
val title = row[MangaTable.title]
|
||||
Pair(chapter, title)
|
||||
}
|
||||
|
||||
val provider = provider(chapterData.mangaId, chapterData.id)
|
||||
return if (provider is ArchiveProvider) {
|
||||
val cbzFile = File(getChapterCbzPath(chapterData.mangaId, chapterData.id))
|
||||
val fileName = "$mangaTitle - [${chapterData.scanlator}] ${chapterData.name}.cbz"
|
||||
Triple(cbzFile.inputStream(), "application/vnd.comicbook+zip", fileName)
|
||||
} else {
|
||||
throw IOException("Chapter not available as CBZ")
|
||||
}
|
||||
val fileName = "$mangaTitle - [${chapterData.scanlator}] ${chapterData.name}.cbz"
|
||||
|
||||
val cbzFile = provider(chapterData.mangaId, chapterData.id).getAsArchiveStream()
|
||||
|
||||
return Triple(cbzFile.first, fileName, cbzFile.second)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user