Open mikoim opened 2 years ago
Sounds like a good idea, but I'm not sure how much work that would be. I don't really want to maintain both a Calibre plugin and standalone versions for three OSes. Doesn't Calibre support any kind of batch processing?
I'll see if I can write a wrapper around the Calibre plugin to allow using that outside of Calibre somehow, but I'm not sure if that will work properly.
I know that's why Harper dropped the standalones. Not wanting to maintain all 3 versions. Easier on the support side too as the plugin uses calibre's embedded Python.
Calibre supports command line interface access to plugins that define a cli_main function. This has the advantage of providing python and the libraries that the plugin needs. My KFX Input and KFX Output plugins can be invoked that way.
The command to invoke a plugin in calibre is: calibre-debug --run-plugin "plugin name" -- plugin arguments
There is limited documentation in the API documentation for plugins.
I've started implementing that cli_main
function with the latest commit ce0837da3fd4d69bf08d676fc6cb3c7a3a5bf6b0, and I also managed to support running the plugin directly (without Calibre).
This means that with that commit (not yet included in any release) you'll be able to run calibre-debug -r "DeDRM" -- --help
or even just python3 DeDRM_plugin.zip --help
to execute the plugin.
Right now the command line doesn't support anything except printing a help text, but I'll extend that and hopefully make it support all the functions the Calibre plugin has, too.
It might be sensible to separate the core DRM removal functionality from the Calibre plugin and release it as a python package.
Doing so would potentially give rise to more use cases and allow the Calibre plugin to use different drm removal backends, e.g. python-native knock could become a backend for the Calibre plugin.
That seems like even more work, having to maintain public "APIs" for everything so external code can just include DeDRM as python module. Right now if I want to change how a given code / function works or is called, I can just change it, and I just need to make sure I also update all places in the plugin that call that code. If I expose all the internal python functions to external code in the form of a proper Python module, I'll have to make sure I have somewhat stable APIs, which is even more work.
Once the standalone support is finished, external tools can execute the plugin as if it was a Python script with command line parameters. Yes, it's not as easy as "import dedrm", but at least this way means the plugin can also be executed from non-Python code. I don't think having a Python module would be a large advantage over that.
As for knock, that's not a "backend" for DRM removal, that's a tool to convert ACSM to EPUB or PDF, which doesn't really have that much to do with DeDRM. Also, there already is a Calibre plugin for ACSM->EPUB/PDF conversion (which, to my knowledge, works properly with the DeDRM plugin).
Standalone tools were removed at 92bf51bc8f201a2d5b1e8b90b8dc033606dbcfb0. They are useful to execute batch process decrypting the whole library.