calibre icon indicating copy to clipboard operation
calibre copied to clipboard

Add support for passing custom configuration to recipies

Open felagund opened this issue 1 month ago • 3 comments

This would bring the changes discussed here: https://bugs.launchpad.net/calibre/+bug/2065877

It also includes changes to the Economist recipe to use the change.

It works on my machine with

ebook-convert recipes/economist.recipe economist.mobi  --test --recipe-config="date=2024-05-18"

However, while developing it, I noticed that only a couple of last issues are accessible nowadays (as of now, 2024-04-27 woks, the issue after does not, and then the later ones work - two hours ago 2024-04-27 did not work).

For some reason, while using the GUI, the config does not seem to be passed to the recipe. I have no idea why, so I acknowledge this is not ready but I think I need a hint here.

There are several more questionable points:

I had an idea that if one passes "help", one would get a message about the format. However, I am not sure how to implement this properly, so maybe it can be discarded. My idea would be that if "help" is passed, other messages from running the recipe are suppressed and just the help message is displayed, but I have no idea how to accomplish that.

I am not sure about where the parse_config function is best called. I now call it in initialization of BasicNewsRecipe, but it only accomplishes to throw an error in case the option is used and a recipe does not implement it. Also using a global variable for edition_date might not be the best idea but I did not want to rework the whole logic of using a previous date in the Economist recipe.

Any feedback is welcome!

felagund avatar May 28 '24 23:05 felagund