mirror of
https://github.com/gotson/komga.git
synced 2026-04-28 18:02:37 +02:00
add endpoint aliases so that all opds feed urls use the same base path
This commit is contained in:
parent
659cea480b
commit
37fa1d0719
2 changed files with 26 additions and 19 deletions
|
|
@ -251,10 +251,10 @@ class OpdsController(
|
|||
id = id.toString(),
|
||||
content = "$name (${fileExtension().toUpperCase()}) (${fileSizeHumanReadable()})",
|
||||
links = listOf(
|
||||
OpdsLinkImageThumbnail("image/jpeg", "/api/v1/series/${series.id}/books/$id/thumbnail"),
|
||||
OpdsLinkImage(metadata.pages[0].mediaType, "/api/v1/series/${series.id}/books/$id/pages/1"),
|
||||
OpdsLinkFileAcquisition(metadata.mediaType, "/api/v1/series/${series.id}/books/$id/file/${fileName()}"),
|
||||
OpdsLinkPageStreaming("image/jpeg", "/api/v1/series/${series.id}/books/$id/pages/{pageNumber}?convert=jpeg&zero_based=true", metadata.pages.size)
|
||||
OpdsLinkImageThumbnail("image/jpeg", "${ROUTE_BASE}books/$id/thumbnail"),
|
||||
OpdsLinkImage(metadata.pages[0].mediaType, "${ROUTE_BASE}books/$id/pages/1"),
|
||||
OpdsLinkFileAcquisition(metadata.mediaType, "${ROUTE_BASE}books/$id/file/${fileName()}"),
|
||||
OpdsLinkPageStreaming("image/jpeg", "${ROUTE_BASE}books/$id/pages/{pageNumber}?convert=jpeg&zero_based=true", metadata.pages.size)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit
|
|||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/v1", produces = [MediaType.APPLICATION_JSON_VALUE])
|
||||
@RequestMapping(produces = [MediaType.APPLICATION_JSON_VALUE])
|
||||
class BookController(
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val seriesRepository: SeriesRepository,
|
||||
|
|
@ -47,7 +47,7 @@ class BookController(
|
|||
private val bookLifecycle: BookLifecycle
|
||||
) {
|
||||
|
||||
@GetMapping("books")
|
||||
@GetMapping("api/v1/books")
|
||||
fun getAllBooks(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@RequestParam(name = "search", required = false) searchTerm: String?,
|
||||
|
|
@ -89,7 +89,7 @@ class BookController(
|
|||
}
|
||||
|
||||
|
||||
@GetMapping("books/latest")
|
||||
@GetMapping("api/v1/books/latest")
|
||||
fun getLatestSeries(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
page: Pageable
|
||||
|
|
@ -109,14 +109,14 @@ class BookController(
|
|||
|
||||
|
||||
@Deprecated("since 0.9.0 the /books/{bookId} is preferred")
|
||||
@GetMapping("series/{seriesId}/books/{bookId}")
|
||||
@GetMapping("api/v1/series/{seriesId}/books/{bookId}")
|
||||
fun getOneBookFromSeries(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable seriesId: Long,
|
||||
@PathVariable bookId: Long
|
||||
): BookDto = getOneBook(principal, bookId)
|
||||
|
||||
@GetMapping("books/{bookId}")
|
||||
@GetMapping("api/v1/books/{bookId}")
|
||||
fun getOneBook(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable bookId: Long
|
||||
|
|
@ -128,14 +128,17 @@ class BookController(
|
|||
|
||||
|
||||
@Deprecated("since 0.9.0 the /books/{bookId}/thumbnail is preferred")
|
||||
@GetMapping(value = ["series/{seriesId}/books/{bookId}/thumbnail"], produces = [MediaType.IMAGE_PNG_VALUE])
|
||||
@GetMapping(value = ["api/v1/series/{seriesId}/books/{bookId}/thumbnail"], produces = [MediaType.IMAGE_PNG_VALUE])
|
||||
fun getBookThumbnailFromSeries(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable seriesId: Long,
|
||||
@PathVariable bookId: Long
|
||||
): ResponseEntity<ByteArray> = getBookThumbnail(principal, bookId)
|
||||
|
||||
@GetMapping(value = ["books/{bookId}/thumbnail"], produces = [MediaType.IMAGE_PNG_VALUE])
|
||||
@GetMapping(value = [
|
||||
"api/v1/books/{bookId}/thumbnail",
|
||||
"opds/v1.2/books/{bookId}/thumbnail"
|
||||
], produces = [MediaType.IMAGE_PNG_VALUE])
|
||||
fun getBookThumbnail(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable bookId: Long
|
||||
|
|
@ -154,8 +157,8 @@ class BookController(
|
|||
|
||||
@Deprecated("since 0.9.0 the /books/{bookId}/file is preferred")
|
||||
@GetMapping(value = [
|
||||
"series/{seriesId}/books/{bookId}/file",
|
||||
"series/{seriesId}/books/{bookId}/file/*"
|
||||
"api/v1/series/{seriesId}/books/{bookId}/file",
|
||||
"api/v1/series/{seriesId}/books/{bookId}/file/*"
|
||||
])
|
||||
fun getBookFileFromSeries(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
|
|
@ -164,8 +167,9 @@ class BookController(
|
|||
): ResponseEntity<ByteArray> = getBookFile(principal, bookId)
|
||||
|
||||
@GetMapping(value = [
|
||||
"books/{bookId}/file",
|
||||
"books/{bookId}/file/*"
|
||||
"api/v1/books/{bookId}/file",
|
||||
"api/v1/books/{bookId}/file/*",
|
||||
"opds/v1.2/books/{bookId}/file/*"
|
||||
])
|
||||
fun getBookFile(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
|
|
@ -190,14 +194,14 @@ class BookController(
|
|||
|
||||
|
||||
@Deprecated("since 0.9.0 the /books/{bookId}/pages is preferred")
|
||||
@GetMapping("series/{seriesId}/books/{bookId}/pages")
|
||||
@GetMapping("api/v1/series/{seriesId}/books/{bookId}/pages")
|
||||
fun getBookPagesFromSeries(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable seriesId: Long,
|
||||
@PathVariable bookId: Long
|
||||
): List<PageDto> = getBookPages(principal, bookId)
|
||||
|
||||
@GetMapping("books/{bookId}/pages")
|
||||
@GetMapping("api/v1/books/{bookId}/pages")
|
||||
fun getBookPages(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable bookId: Long
|
||||
|
|
@ -212,7 +216,7 @@ class BookController(
|
|||
|
||||
|
||||
@Deprecated("since 0.9.0 the /books/{bookId}/page/{pageNumber} is preferred")
|
||||
@GetMapping("series/{seriesId}/books/{bookId}/pages/{pageNumber}")
|
||||
@GetMapping("api/v1/series/{seriesId}/books/{bookId}/pages/{pageNumber}")
|
||||
fun getBookPageFromSeries(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable seriesId: Long,
|
||||
|
|
@ -222,7 +226,10 @@ class BookController(
|
|||
@RequestParam(value = "zero_based", defaultValue = "false") zeroBasedIndex: Boolean
|
||||
): ResponseEntity<ByteArray> = getBookPage(principal, bookId, pageNumber, convertTo, zeroBasedIndex)
|
||||
|
||||
@GetMapping("books/{bookId}/pages/{pageNumber}")
|
||||
@GetMapping(value = [
|
||||
"api/v1/books/{bookId}/pages/{pageNumber}",
|
||||
"opds/v1.2/books/{bookId}/pages/{pageNumber}"
|
||||
])
|
||||
fun getBookPage(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable bookId: Long,
|
||||
|
|
|
|||
Loading…
Reference in a new issue