mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 19:04:39 -05:00
* Añadiendo algunos cambios iniciales para probar OPDS * Add suport to OPDS v1.2 * Added support for OPDS-PSE and reorganized controllers * Rename chapterIndex to chapterId in the API and controller, and update descriptions in OPDS * Refactor OPDS to use formatted timestamps and proxy thumbnail URLs * Refactor OPDS to use formatted timestamps and proxy thumbnail URLs * Update Manga API to download chapters cbz using only chapterId and improve chapter download query * Optimize OPDS queries * Update Manga API to download chapters cbz using only chapterId and improve chapter download query * Optimize OPDS queries * Use SourceDataClass to map sources and optimize thumbnail URL retrieval * Kotlin lint errors in ChapterDownloadHelper and Opds * Kotlin lint errors in ChapterDownloadHelper and Opds
87 lines
2.8 KiB
Kotlin
87 lines
2.8 KiB
Kotlin
package suwayomi.tachidesk.opds.controller
|
|
|
|
import io.javalin.http.HttpStatus
|
|
import suwayomi.tachidesk.opds.impl.Opds
|
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
|
import suwayomi.tachidesk.server.util.handler
|
|
import suwayomi.tachidesk.server.util.pathParam
|
|
import suwayomi.tachidesk.server.util.queryParam
|
|
import suwayomi.tachidesk.server.util.withOperation
|
|
|
|
object OpdsController {
|
|
private const val OPDS_MIME = "application/xml;profile=opds-catalog;charset=UTF-8"
|
|
private const val BASE_URL = "/api/opds/v1.2"
|
|
|
|
val rootFeed =
|
|
handler(
|
|
documentWith = {
|
|
withOperation {
|
|
summary("OPDS Root Feed")
|
|
description("OPDS feed for the list of available manga sources")
|
|
}
|
|
},
|
|
behaviorOf = { ctx ->
|
|
ctx.future {
|
|
future {
|
|
Opds.getRootFeed(BASE_URL)
|
|
}.thenApply { xml ->
|
|
ctx.contentType(OPDS_MIME).result(xml)
|
|
}
|
|
}
|
|
},
|
|
withResults = {
|
|
httpCode(HttpStatus.OK)
|
|
},
|
|
)
|
|
|
|
val sourceFeed =
|
|
handler(
|
|
pathParam<Long>("sourceId"),
|
|
queryParam<Int?>("pageNumber"),
|
|
documentWith = {
|
|
withOperation {
|
|
summary("OPDS Source Feed")
|
|
description("OPDS feed for a specific manga source")
|
|
}
|
|
},
|
|
behaviorOf = { ctx, sourceId, pageNumber ->
|
|
ctx.future {
|
|
future {
|
|
Opds.getSourceFeed(sourceId, BASE_URL, pageNumber ?: 1)
|
|
}.thenApply { xml ->
|
|
ctx.contentType(OPDS_MIME).result(xml)
|
|
}
|
|
}
|
|
},
|
|
withResults = {
|
|
httpCode(HttpStatus.OK)
|
|
httpCode(HttpStatus.NOT_FOUND)
|
|
},
|
|
)
|
|
|
|
val mangaFeed =
|
|
handler(
|
|
pathParam<Int>("mangaId"),
|
|
queryParam<Int?>("pageNumber"),
|
|
documentWith = {
|
|
withOperation {
|
|
summary("OPDS Manga Feed")
|
|
description("OPDS feed for chapters of a specific manga")
|
|
}
|
|
},
|
|
behaviorOf = { ctx, mangaId, pageNumber ->
|
|
ctx.future {
|
|
future {
|
|
Opds.getMangaFeed(mangaId, BASE_URL, pageNumber ?: 1)
|
|
}.thenApply { xml ->
|
|
ctx.contentType(OPDS_MIME).result(xml)
|
|
}
|
|
}
|
|
},
|
|
withResults = {
|
|
httpCode(HttpStatus.OK)
|
|
httpCode(HttpStatus.NOT_FOUND)
|
|
},
|
|
)
|
|
}
|