Package: recipe2txt
Introductionrecipe2txtis a CLI-program that you can feed your urls of recipes and it spits out formatted cookbooks containing those recipes. Highlights include:asynchronous fetching of recipesformatted output either as txt- or markdown-filelocal caching of recipescustom recipe formatting viajinjaThe program is a wrapper for therecipe-scrapers-library. Please visit their README.md if you would like to know which websites are supported.WARNINGTHIS SOFTWARE IS AT AN EARLY DEVELOPMENT STAGE.BE CAREFUL SETTING THE--output-FLAG, ANY EXISTING FILES WITH THE SAME NAME WILL BE OVERWRITTEN.TESTED ONLY ON KUBUNTU.UsageInstall withpip install recipe2txt. You can either userecipe2txtorre2txtto run the program.usage: recipes2txt [-h] [--file [FILE ...]] [--output OUTPUT] [--verbosity {debug,info,warning,error,critical}]
                   [--connections CONNECTIONS] [--cache {only,new,default}] [--debug] [--timeout TIMEOUT]
                   [--output-format {md,txt}] [--user-agent USER_AGENT] [--erase-appdata] [--version]
                   [url ...]

Scrapes URLs of recipes into text files

positional arguments:
  url                   URLs whose recipes should be added to the recipe-file (default: '[]')

options:
  -h, --help            show this help message and exit
  --file [FILE ...], -f [FILE ...]
                        Text-files containing URLs whose recipes should be added to the recipe-file (default:
                        '[]')
  --output OUTPUT, -o OUTPUT
                        Specifies an output file. THIS WILL OVERWRITE ANY EXISTING FILE WITH THE SAME NAME.
                        (default: '/home/pc/sciebo/Dokumente/Programming/recipe2txt/recipes')
  --verbosity {debug,info,warning,error,critical}, -v {debug,info,warning,error,critical}
                        Sets the 'chattiness' of the program (default: 'critical')
  --connections CONNECTIONS, -con CONNECTIONS
                        Sets the number of simultaneous connections (default: '4')
  --cache {only,new,default}, -c {only,new,default}
                        Controls how the program should handle its cache: With 'only' no new data will be
                        downloaded, the recipes will be generated from data that has been downloaded previously.
                        If a recipe is not in the cache, it will not be written into the final output. 'new' will
                        make the program ignore any saved data and download the requested recipes even if they
                        have already been downloaded. Old data will be replaced by the new version, if it is
                        available. The 'default' will fetch and merge missing data with the data already saved,
                        only inserting new data into the cache where there was none previously. (default:
                        'default')
  --debug, -d           Activates debug-mode: Changes the directory for application data (default: 'False')
  --timeout TIMEOUT, -t TIMEOUT
                        Sets the number of seconds the program waits for an individual website to respond, eg.
                        sets the connect-value of aiohttp.ClientTimeout (default: '10.0')
  --output-format {md,txt}, -of {md,txt}
                        Sets the format for the output-file. The value defines which .jinja-template will be used
                        to format the file. The templates are available under
                        '/home/pc/.config/recipes2txt/templates'. (default: 'txt')
  --user-agent USER_AGENT, -ua USER_AGENT
                        Sets the user-agent to be used for the requests. (default: 'Mozilla/5.0 (Windows NT 10.0;
                        Win64; x64; rv:115.0) Gecko/20100101 Firefox/115.0')
  --erase-appdata       Erases all data- and cache-files (e.g. the files listed below) (default: 'False')
  --version             Displays the version number (SemVer) (default: 'False')ConfigurationWhen first run the program will generate the config-filerecipe2txt.toml(userecipe2txt --helpto locate it).
Every option listed above has a pendant in that file. Uncomment [^1] the line and change the value after the=-
sign to change the value this program uses when the option is not specified via the CLI-interface.[^1]: Remove the leading#Jinja-TemplatesWhen first run the program will create the config-foldertemplates. Here reside the jinja-templates used for
formatting recipes. Simply modify the existing templates or create your own.Creating your own templatesJinja-templates are provided with:recipes: a Python-list ofRecipe-objects, each containingingredients: the ingredients, separated by newlinesinstructions: the instructions, separated by newlinestitletotal_timeyields: how many people can eat this recipehost: which website the recipe is hosted onimage: an url to an accompanying imagenutrients: Python-dictionary of the nutrientsurl: the url to the recipestatus: an integer representing the completeness of the recipescraper_version: the version of the recipe-scrapers-library used to scrape this recipeThe NA-constantused to represent values in theRecipe-object that are not availableThe functions of therecipe2txt.utils.markdown-moduleUsing your own templatesAll.jinja-files in the folder are collected and their extentions are stripped to create an identifier for that template.
E.g.: The template is namedrst.jinja=> specify--output-format rstto use the template.Examplesrecipe2txtwww.example-url.com/tastyrecipewww.other-examle-url.org/deliciousmeal-o~/Documents/great-recipes.txtDevelopmentVersioningThis project tries to adhere to (Semantic Versioning)[https://semver.org/]. While using '0.'-version-numbers, '0.N+1'-increases mean API changes (breaking and non-breaking), while '0.N.M+1' means no noticable API-changes.ToolsnoxThis project (ab-)usesnoxas test-(and task-)runner. Install nox from PyPi.org (e.g.pipx install nox). Usenox --listto get an overview over the different routines thenoxfileprovides. For example to create the developement enviroment usenox -s dev.mypyThis project usesmypyfor type checking. Theconfiguration filecontains all relevant settings, so a simple call tomypyfrom the current directory should be sufficient to typecheck the project.blackThe project usesblackfor code formatting.TestingThe project uses Python unittest for unit- and integration testing. The tests are defined in thetest.test_...-modules. Thetest/testfiles-folder contains permanent and non-permanent testfiles.Permanent testfiles are used to validate that the output of the program does not drift unintentionally. A reimplementation of the '.jinja'-templates in Python ensures their validity for example. Some of those files are derived from Material not licensed under the GPL3-License. Please seetest/testfiles/permanent/LICENSEfor more information.Non-permanent testfiles are temporary files and folders generated during testing. They are written into the foldertest/testfiles/tmp_testfiles_re2txt. Outside of unittest-runs this folder should never appear.Sytem testing is facilitated via thetest.test4recipe2txt-module. The module is used to create and run different CLI-parameter configurations of the program. At the end of a testrun it saves all files generated during the run and the initial parameters into a zip-file intest/reports_test4recipe2txtfor later review. For each run the program uses thetest/reports_test4recipe2txt-file to optain the urls to use in the testrun. To stress all websites equally and to avoid testing the same websites over and over the urls the file represents a queue, where the urls to use next are at the top and recently used urls will be moved to the bottom. If the file does not exist it will be generated fromtest/testfiles/permanent/all_urls.txt.