Leseratte10 / lcpl-calibre-plugin

Calibre plugin for LCPL->EPUB and LCPL->PDF conversion.
https://www.mobileread.com/forums/showthread.php?t=342165
Other
26 stars 2 forks source link

The plugin doesn't seem to work #3

Open JollyPanda opened 2 years ago

JollyPanda commented 2 years ago

Bug description

When importing a lpcl file either through the "add book" menu or by dragging and dropping the file inside the Calibre window there is no ebook or pdf generated. Calibre adds the lpcl file just as if the plugin was not installed. I'm using Calibre 5.42 and tried with Calibre 4.11 with no luck.

The plugin was installed through the Calibre plugin explorer and when it didn't work I removed it and installed it from the zip file in this repo. I restarted Calibre after each installation. Files used were the LCP test books provided by EDRLab and one file provided by my local library.

Maybe there's a step I'm missing? As I understand the conversion should happen automatically when dragging and dropping the file inside Calibre.

Operating system

Windows

Which version of Calibre are you running?

5.42

Which version of the LCPL Input plugin are you running?

v0.0.5

Further information

No response

Leseratte10 commented 2 years ago

Does the name of the file you're trying to import end with ".lcpl"? Calibre will only execute this plugin if that's the case.

That's how the plugin should work, you're not missing a step.

If it is, please post a debug output (open the "Preferences" drop down menu, select "Restart in debug mode", then try again and then close Calibre, a log file should then pop up).

JollyPanda commented 2 years ago

Yes, all of them have the .lcpl extension.

The log from the EDRLab test file just fails:

'C:\Users\user\Downloads\lcpl\wasteland.lcpl'] LCPL Input v0.0.5: Trying to parse file wasteland.lcpl LCPL Input v0.0.5: Looks like this is a LCPL license file LCPL Input v0.0.5: Found LCPL for book ID [ID] LCPL Input v0.0.5: Downloading book from [URL] with default UA ... LCPL Input v0.0.5: Downloading book failed! LCPL Input v0.0.5: Failed, return original ... Added wasteland to db in: 0.2 Added 1 books in 14.6 seconds

On the other hand, the file from the library claims there is no URL:

Starting QuickView LCPL Input v0.0.5: Trying to parse file 29-4-2022.lcpl LCPL Input v0.0.5: Looks like this is a LCPL license file LCPL Input v0.0.5: Found LCPL for book ID [ID] LCPL Input v0.0.5: No download link found in LCPL LCPL Input v0.0.5: Failed, return original ... [4.94] splash screen hidden [4.94] Started up in 4.94 seconds with 8 books Added 29-4-2022 to db in: 0.2 Added 1 books in 0.8 seconds

Maybe there were some changes behind the scenes?

Leseratte10 commented 2 years ago

Okay, I just attempted to download the test file myself, and it looks like the SSL certificate of the Readium server expired a month ago. Looks like my plugin fails to download books when the server has no valid SSL certificate. Ideally, that would be fixed by Readium - how can you not notice your SSL cert expired a month ago ...

I can try to make it ignore that as long as the file hash is included in the LCPL file so that the file integrity can still be verified.

As for the file from your library that doesn't even have a URL, that's hard to say without having access to the file itself.

Can you open the LCPL file in a text editor and copy-paste the "links" array into this issue? That defines where the book is supposed to be downloaded from, maybe they've indeed updated the format.

The 'example' from the wasteland test file would be this

"links":[{"rel":"publication","href":"https://lcp-prod.edrlab.org/contents/65df4ad5-21c2-4ec7-a70b-19f53697f610","type":"application/epub+zip","title":"wasteland","length":435037,"hash":"a38f272ef9bd61507b02e460ce64f28151f699e75628739ec955090182a1d046"},{"rel":"hint","href":"https://front-prod.edrlab.org"},{"rel":"status","href":"https://lsd-prod.edrlab.org/licenses/9679f657-4a90-4e39-8f35-63784e269e6c/status","type":"application/vnd.readium.license.status.v1.0+json"}]

and I would need to see the same entry from your libraries' file. It would probably be a good idea to censor everything that looks like a unique ID, I don't need to know the specific hash and download URLs, just the general format to see if (and how) they've changed it.

JollyPanda commented 2 years ago

The link section of that particular file doesn't have a "application/epub+zip" or "application/pdf" type, intstead it's a "application/pdf+lcp" file. It's also the third link instead of the first one like in the EDRLab test file.

"links":[{"rel":"hint","href":"_redacted_","type":"text/html"}, {"rel":"status","href":"_redacted_","type":"application/vnd.readium.license.status.v1.0+json"}, {"rel":"publication","href":"_redacted_","type":"application/pdf+lcp"}]

Leseratte10 commented 2 years ago

That would be what causes the error then, the plugin currently only searches for application/epub+zip or application/pdf. I'm going to just add application/pdf+lcp to that list later today and hope that these are implemented in the exact same way.

If you want to test it right now you could edit the __init__.py file in the plugin ZIP and replace application/pdf with application/pdf+lcp and see if it works then and creates a valid file.

JollyPanda commented 2 years ago

I ended up downloading the Thorium Reader, but just out of curiosity, I tested the plugin anyway.

Adding the "application/pdf+lcp" to the "init.py" file does result in a PDF file, but it seems to be corrupted and it can't be opened even by Thorium Reader. Thorium Reader itself creates a "lcpdf" file after importing the initial "lcpl" file.

This is Calibre's log:

ValueError: Could not read info dict from PDF LCPL Input v0.0.5: Trying to parse file 29-4-2022.lcpl LCPL Input v0.0.5: Looks like this is a LCPL license file LCPL Input v0.0.5: Found LCPL for book ID redacted LCPL Input v0.0.5: Downloading book from redacted with default UA ... Syntax Warning: May not be a PDF file (continuing anyway)

macaju commented 5 days ago

I have the same problem with Calibre 7.13 and PDFs (for EPUB works fine). I have applied your suggestion (https://github.com/Leseratte10/lcpl-calibre-plugin/issues/3#issuecomment-1122288375) but as @a19a, it creates a pdf file but unreadable.

More info; I renamed to zip and is a zip (with META-INF, manifest.json and publication.pdf), but the pdf inside is still unreadable