mirror of
https://github.com/SinTan1729/recipe-box-for-wikijs.git
synced 2025-04-19 10:00:00 -05:00
Compare commits
No commits in common. "58da47c04afeed673b32321a6d7c4e0b3b135440" and "81269e74eb1e9d60ca07235c5d69325808b20818" have entirely different histories.
58da47c04a
...
81269e74eb
1 changed files with 4 additions and 6 deletions
|
@ -62,9 +62,7 @@ def valid_filename(directory, filename=None):
|
|||
directory = os.path.dirname(directory)
|
||||
|
||||
# Allow for directories.
|
||||
ensure_directory_exists(directory)
|
||||
items = os.listdir(directory)
|
||||
|
||||
items = set(os.listdir(directory))
|
||||
if filename in items:
|
||||
count = 1
|
||||
while test_filename(filename, count) in items:
|
||||
|
@ -84,10 +82,10 @@ def process_recipe(config, scraper, url, verbose=False):
|
|||
recipe_box = ensure_directory_exists(config['recipe_box'])
|
||||
media = ensure_directory_exists(os.path.join(config['recipe_box'], 'images'))
|
||||
|
||||
prefix = scraper.title().strip().replace(' ', '-').lower()
|
||||
prefix = scraper.title().replace(' ', '-').lower()
|
||||
path = os.path.join(recipe_box, prefix + '.md')
|
||||
path = valid_filename(path)
|
||||
recipe = open(path, 'w+')
|
||||
recipe = open(path, 'w')
|
||||
|
||||
try:
|
||||
image_url = scraper.image()
|
||||
|
@ -99,7 +97,7 @@ def process_recipe(config, scraper, url, verbose=False):
|
|||
# Also, os.path.splitext(url), probably not a good idea. ;)
|
||||
filename = os.path.splitext(os.path.basename(path))[0] + os.path.splitext(scraper.image())[1]
|
||||
filepath = os.path.join(media, filename)
|
||||
image = open(filepath, 'wb+')
|
||||
image = open(filepath, 'wb')
|
||||
image.write(response.content)
|
||||
image.close()
|
||||
if verbose:
|
||||
|
|
Loading…
Reference in a new issue