-
-
Notifications
You must be signed in to change notification settings - Fork 8
Recipes
ping edited this page Mar 21, 2023
·
2 revisions
To custom the recipes you want, it is important to understand a Recipe
definition. With this, you then add the recipes wanted into _recipes_custom.py.
# To be defined in _recipes_custom.py
Recipe(
recipe="example", # actual recipe name
slug="example", # file name slug
src_ext="mobi", # the recipe primary output format
category="news", # category that is used to group the output
name="An Example Publication", # display name, taken from recipe source by default
target_ext=[], # alt formats that the src_ext format will be converted to
timeout=180, # max interval (seconds) for executing the recipe
overwrite_cover=False, # generate a plain cover to overwrite Calibre's. Default: true
enable_on=True, # determines when to run the recipe
retry_attempts=1, # retry attempts on TimeoutExpired, ReadTimeout
cover_options=CoverOptions(), # cover options
tags=["example"], # used in search
title_date_format = "%-d %b, %Y" # used to format the date in the title
),
Recipe(
recipe="Associated Press", # "Associated Press" is a calibre built-in recipe
name="Associated Press",
slug="ap",
src_ext="mobi",
category="Example",
),
Recipe(
recipe="vox", # vox is a newsrack recipe located in the recipes/ folder
slug="vox",
src_ext="epub",
category="Example",
),
Recipe(
recipe="example",
slug="example",
src_ext="epub",
category="Example",
overwrite_cover=False, # Default: True
),
The CoverOptions
class holds the available options for the generated cover.
from _recipe_utils import CoverOptions
Recipe(
recipe="example",
slug="example",
src_ext="epub",
category="Example",
cover_options=CoverOptions(
cover_width=889,
cover_height=1186,
border_offset=25,
border_width=2,
text_colour="black", # or in hex format, e.g. "#000000"
background_colour="white", # or in hex format, e.g. "#FFFFFF"
title_font_path="static/OpenSans-Bold.ttf", # you can define your own font path
title_font_size=80,
datestamp_font_path="static/OpenSans-Semibold.ttf",
datestamp_font_size=72,
logo_path_or_url="" # must be a png/jpg/gif
),
),
Recipe(
recipe="vox",
slug="vox",
src_ext="epub",
category="Example",
title_date_format = "%Y-%m-%d", # Default: "%-d %b, %Y"
),
Recipe(
recipe="example",
slug="example",
src_ext="epub",
category="Example",
tags=["science", "kids"],
),
First add the recipe to the recipes_custom/ folder then define the recipe like so:
Recipe(
recipe="example", # example.recipe.py in recipes_custom/
slug="example",
src_ext="epub", # generate epub
category="Example",
),
# _recipes_custom.py
# Define the categories display order, optional
categories_sort: List[str] = ["First Category", "Second Category"]