meta { name: Download Book KEPUB (On-the-fly Conversion) type: http seq: 1 } get { url: {{base_url}}/opds/devices/{{deviceId}}/download/{{mediaItemId}}?format=kepub body: none auth: inherit } script:post-response { function onResponse(res) { const headers = res.getHeaders(); const kepubHash = headers.get('X-Bookhoard-KEPUB-SHA256'); if (kepubHash) { tests['KEPUB hash present'] = true; tests['Hash is 64 chars'] = kepubHash.length === 64; } else { tests['KEPUB hash present'] = false; } const bookhoardUUID = headers.get('X-Bookhoard-UUID'); tests['Bookhoard UUID present'] = bookhoardUUID !== null; const contentType = headers.get('Content-Type'); tests['Content-Type is KEPUB'] = contentType && contentType.includes('kepub'); } onResponse(res); } settings { encodeUrl: true timeout: 0 } docs { ## Download Book KEPUB (On-the-fly Conversion) Downloads a book in Kobo EPUB (KEPUB) format with on-the-fly conversion if needed. **Method:** GET **Endpoint:** /opds/devices/{deviceId}/download/{mediaItemId}?format=kepub **Authentication:** Bearer token **Path Parameters:** - `deviceId` (string): Device UUID - `mediaItemId` (string): Media item UUID **Query Parameters:** - `format` (string): Must be "kepub" **Response Headers:** - `X-Bookhoard-KEPUB-SHA256` (string): SHA-256 hash of the KEPUB file (64 chars) - `X-Bookhoard-UUID` (string): Bookhoard UUID for the media item - `Content-Type` (string): Will be "application/kepub+json" or similar **Response Body:** Binary KEPUB file data **Status Codes:** - 200: Success - KEPUB file returned - 401: Unauthorized - 404: Media item or device not found - 500: Internal server error or conversion failure **Note:** The KEPUB format adds special Kobo-specific markup to enhance reading features on Kobo devices. The file is converted on-the-fly if the source is not already KEPUB. }