reader done

This commit is contained in:
Aria Moradi
2021-01-20 01:05:24 +03:30
parent 5d9173d3f7
commit a7e63565ef
5 changed files with 55 additions and 5 deletions
@@ -81,9 +81,10 @@ class Main {
ctx.json(getChapterList(mangaId))
}
app.get("/api/v1/chapter/:chapterId") { ctx ->
app.get("/api/v1/manga/:mangaId/chapter/:chapterId") { ctx ->
val chapterId = ctx.pathParam("chapterId").toInt()
ctx.json(getPages(chapterId))
val mangaId = ctx.pathParam("mangaId").toInt()
ctx.json(getPages(chapterId,mangaId))
}
}
@@ -56,10 +56,10 @@ fun getChapterList(mangaId: Int): List<ChapterDataClass> {
}
}
fun getPages(chapterId: Int): List<PageDataClass> {
fun getPages(chapterId: Int, mangaId: Int): List<PageDataClass> {
return transaction {
val chapterEntry = ChapterTable.select { ChapterTable.id eq chapterId }.firstOrNull()!!
val mangaId = chapterEntry[ChapterTable.manga].value
assert(mangaId == chapterEntry[ChapterTable.manga].value) // sanity check
val mangaEntry = MangaTable.select { MangaTable.id eq mangaId }.firstOrNull()!!
val source = getHttpSource(mangaEntry[MangaTable.sourceReference].value)