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:
Shirish
2025-03-08 22:01:07 +05:30
committed by GitHub
parent 3be165a551
commit 95d9293fe0
13 changed files with 427 additions and 143 deletions

View File

@@ -401,6 +401,7 @@ object MangaController {
pathParam<Int>("mangaId"),
pathParam<Int>("chapterIndex"),
pathParam<Int>("index"),
queryParam<Boolean?>("updateProgress"),
documentWith = {
withOperation {
summary("Get a chapter page")
@@ -409,14 +410,18 @@ object MangaController {
)
}
},
behaviorOf = { ctx, mangaId, chapterIndex, index ->
behaviorOf = { ctx, mangaId, chapterIndex, index, updateProgress ->
ctx.future {
future { Page.getPageImage(mangaId, chapterIndex, index) }
future { Page.getPageImage(mangaId, chapterIndex, index, null) }
.thenApply {
ctx.header("content-type", it.second)
val httpCacheSeconds = 1.days.inWholeSeconds
ctx.header("cache-control", "max-age=$httpCacheSeconds")
ctx.result(it.first)
if (updateProgress == true) {
Chapter.updateChapterProgress(mangaId, chapterIndex, pageNo = index)
}
}
}
},
@@ -437,10 +442,11 @@ object MangaController {
},
behaviorOf = { ctx, chapterId ->
ctx.future {
future { ChapterDownloadHelper.getCbzDownload(chapterId) }
.thenApply { (inputStream, contentType, fileName) ->
ctx.header("Content-Type", contentType)
future { ChapterDownloadHelper.getCbzForDownload(chapterId) }
.thenApply { (inputStream, fileName, fileSize) ->
ctx.header("Content-Type", "application/vnd.comicbook+zip")
ctx.header("Content-Disposition", "attachment; filename=\"$fileName\"")
ctx.header("Content-Length", fileSize.toString())
ctx.result(inputStream)
}
}