Closed Lilith-NightRose closed 1 year ago
I'd try to just fix this up myself and put in the PR but 1) I am almost certain there is a less kludgy way to do the fallover code 2) I'm not sure how to change what files will be included in PyPl 3) I don't feel comfortable enough with Calibre plugin development to restructure everything so that both the CLI and the Plugin can use the same fallover code.
I confess that I didn't consider that there might be CLI platforms that couldn't use the brotli
library.
Unfortunately, my ability to type is rather reduced right now; I can't do very much coding work at the moment. It may be a while before I do anything about it.
I've looked at this a bit, and including brotlidecpy
directly in the FFF CLI install would be a bit of a pain. It would also be of use to very few users.
What I propose instead is to change FFF just enough to try importing brotlidecpy
if brotli
isn't found, nor is the plugin packaged version calibre_plugins.fanficfare_plugin.brotlidecpy
. I typo'd when I went to upload it, so it's already in main branch: b43bec41268c6817b06dbf3d633fccf62f728806
That leaves is incumbent on you to install brotlidecpy
--which it sounds like you already have, and install FFF while ignoring the missing brotli
package--which again, you appear to have already solved.
If you can get https://github.com/sidney/brotlidecpy released as a pip installable package, I will figure out how to get FFF to require that instead of brotli
for at least your case. You could try to talk @sidney into making it, or figure it out and submit a PR for them?
Referencing my name in the comment did ping me and I'm happy to help if it is something I can figure out, once our region gets power and full Internet access restored after the tropical cyclone we went through this week. That will probably be at least some number of days more. Also I tinker with python code, not an expert, so submitting a PR would be a better choice if it is possible.
FFF part of this, I believe, is done as mentioned above.
As designed currently, FanFicFare_CLI requires installation of the platform-specific Brotli binary. Unfortunately, some Python installations are not currently able to utilize platform-specific binaries (e.g. the Python installation on A-Shell for iOS), but can otherwise use PyPl. FFF for Calibre already comes bundled with a version of Brotli (brotlidecpy) that does not require a platform-specific binary, along with fallback code that permits a transition to the pure-python approach upon failure of Brotli. However, the Pip installation does not include brotlidecpy, and the code is presently designed to only function within the Calibre plugin environment.
At its most simple, to fix this would require adding a second try/except loop to browsercache/base_browsercache.py, as well as including brotlidecpy in the CLI FFF installation via Pip. Alternatively, the structure of the plugin could be refactored to permit both the Plugin and the Pip/CLI version to use the same fallback code by placing brotlidecpy in the same place for both of them.
What I've done: I've found that Brotli is the only platform-specific binary necessary to make FFF functional on a-shell. I did so by bringing the brotlidecpy folder into the Python library installation on A-Shell, then replacing lines 22-28 of browsercache/base_browsercache.py with the following (slightly hacky) snippet:
And attempting to download a fanfiction. Said download works as expected and is able to open in iOS ebooks.