Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Streaming publication using LCPL file #618

Open
KaramYaaqba opened this issue Feb 18, 2025 · 9 comments
Open

[Bug] Streaming publication using LCPL file #618

KaramYaaqba opened this issue Feb 18, 2025 · 9 comments
Labels
bug Something isn't working triage Triage needed by maintainers

Comments

@KaramYaaqba
Copy link

Describe the bug

I am trying to implement streaming for books and audiobooks using the Readium 3.0 toolkit, following the instructions in the documentation (https://github.com/readium/kotlin-toolkit/blob/develop/docs/guides/lcp.md) under the "Streaming an LCP protected package" section. However, I am getting a "Format Not Supported" error, which does not occur when I load the book from the LCPL file instead of streaming:

org.readium.r2.streamer.PublicationOpener$OpenError$FormatNotSupported@c128feb

Here is the code snippet I am using:

`
suspend fun importPublicationFromStorage(uri: Uri) {
// Instantiate the required components.
val context = app.applicationContext.applicationContext
val httpClient = DefaultHttpClient()
val assetRetriever = AssetRetriever(
contentResolver = context.contentResolver,
httpClient = httpClient
)
val publicationOpener = PublicationOpener(
publicationParser = DefaultPublicationParser(
context,
httpClient = httpClient,
assetRetriever = assetRetriever,
pdfFactory = PdfiumDocumentFactory(context)
)
)
val asset =
assetRetriever.retrieve(uri.toAbsoluteUrl()!!).getOrElse {
null
}

    // Open a `Publication` from the `Asset` which is LCPL file in this case.
    val publication = publicationOpener.open(asset!!, allowUserInteraction = true)
        .getOrElse {
            print("error" + it)
                    }

    print("Opened ${publication}")
}

`

How to reproduce?

1- Load the LCPL file using the provided code.
2- An exception will occur when you do so.

Readium version

3.0

Android API version

35

Additional context

No response

@KaramYaaqba KaramYaaqba added bug Something isn't working triage Triage needed by maintainers labels Feb 18, 2025
@qnga
Copy link
Member

qnga commented Feb 18, 2025

Please try to reproduce this on the testapp (I can't do it). I can help you enable LCP support on Slack if you need it.

@qnga
Copy link
Member

qnga commented Feb 18, 2025

Note that you don't pass aLcpContentProtection to the PublicationOpener, which is likely to result in a FormatNotSupported error, but that should happen when you open a downloaded book too.

NB: I agree that the documentation is a bit misleading, we'll fix it.

@KaramYaaqba
Copy link
Author

KaramYaaqba commented Feb 19, 2025

@qnga I need your help to enable LCP streaming, what is the best way to connect with you on Slack?

@qnga
Copy link
Member

qnga commented Feb 19, 2025

I sent to you instructions on the Readium Slack, as you seem to have access to it.

@hishampro5
Copy link

@qnga we are encounter same issue.
We are confused about the error FormatNotSupported why and how can fix it.

@hishampro5
Copy link

@KaramYaaqba did you get why this error occur

@KaramYaaqba
Copy link
Author

@hishampro5, the first issue in my case is that our backend server does not support the HEAD method. We are fixing it, but until then, we cannot stream publications.

@mickael-menu
Copy link
Member

mickael-menu commented Feb 26, 2025

Also don't forget to pass the LCP content protection when initializing the PublicationOpener, otherwise you might get this error as LCP files won't be recognized.

See the documentation for that: https://github.com/readium/kotlin-toolkit/blob/3.0.3/docs/guides/lcp.md#initializing-the-publicationopener

@qnga
Copy link
Member

qnga commented Mar 28, 2025

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Triage needed by maintainers
Projects
None yet
Development

No branches or pull requests

4 participants