mirror of
https://github.com/SinTan1729/recipe-box-for-wikijs.git
synced 2024-12-25 17:58:35 -06:00
change: Location of images
This commit is contained in:
parent
14b77385c7
commit
cb054e2b5f
1 changed files with 5 additions and 8 deletions
|
@ -1,12 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
""" Scrape a recipe, convert it to Markdown and store it in a Zettelkasten.
|
# Scrape a recipe, convert it to Markdown and store it in Wiki.js
|
||||||
|
|
||||||
A free recipe-box.
|
|
||||||
|
|
||||||
1. https://obsidian.md/
|
|
||||||
2. https://www.ourstate.com/a-kitchens-riches/
|
|
||||||
"""
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -90,9 +85,9 @@ def process_recipe(config, scraper, url, verbose=False):
|
||||||
""" Process the recipe at a given URL.
|
""" Process the recipe at a given URL.
|
||||||
"""
|
"""
|
||||||
recipe_box = ensure_directory_exists(config['recipe_box'])
|
recipe_box = ensure_directory_exists(config['recipe_box'])
|
||||||
media = ensure_directory_exists(os.path.join(config['recipe_box'], 'media'))
|
media = ensure_directory_exists(os.path.join(config['recipe_box'], 'images'))
|
||||||
|
|
||||||
prefix = scraper.title().lower()
|
prefix = scraper.title().replace(' ', '-').lower()
|
||||||
path = os.path.join(recipe_box, prefix + '.md')
|
path = os.path.join(recipe_box, prefix + '.md')
|
||||||
path = valid_filename(path)
|
path = valid_filename(path)
|
||||||
recipe = open(path, 'w')
|
recipe = open(path, 'w')
|
||||||
|
@ -113,6 +108,8 @@ def process_recipe(config, scraper, url, verbose=False):
|
||||||
if verbose:
|
if verbose:
|
||||||
print('Saving {url} -> {path}'.format(url=image_url, path=filepath))
|
print('Saving {url} -> {path}'.format(url=image_url, path=filepath))
|
||||||
|
|
||||||
|
# Make sure to upload the image file inside /images/recipe with the proper name or edit the following
|
||||||
|
# lines to suit your needs.
|
||||||
if filename:
|
if filename:
|
||||||
recipe.write('![{filename}]("/images/recipe/{filename}")\n'.format(filename=filename))
|
recipe.write('![{filename}]("/images/recipe/{filename}")\n'.format(filename=filename))
|
||||||
recipe.write('\n')
|
recipe.write('\n')
|
||||||
|
|
Loading…
Reference in a new issue