cookbookapp importer more or less broken (more)
This commit is contained in:
@ -10,7 +10,7 @@ import validators
|
||||
import yaml
|
||||
|
||||
from cookbook.helper.ingredient_parser import IngredientParser
|
||||
from cookbook.helper.recipe_url_import import get_images_from_soup, iso_duration_to_minutes
|
||||
from cookbook.helper.recipe_url_import import get_images_from_soup, iso_duration_to_minutes, get_from_scraper
|
||||
from cookbook.helper.scrapers.scrapers import text_scraper
|
||||
from cookbook.integration.integration import Integration
|
||||
from cookbook.models import Ingredient, Keyword, Recipe, Step
|
||||
@ -25,9 +25,9 @@ class CookBookApp(Integration):
|
||||
recipe_html = file.getvalue().decode("utf-8")
|
||||
|
||||
# recipe_json, recipe_tree, html_data, images = get_recipe_from_source(recipe_html, 'CookBookApp', self.request)
|
||||
scrape = text_scraper(text=data)
|
||||
recipe_json = helper.get_from_scraper(scrape, request)
|
||||
images = list(dict.fromkeys(get_images_from_soup(scrape.soup, url)))
|
||||
scrape = text_scraper(text=recipe_html)
|
||||
recipe_json = get_from_scraper(scrape, self.request)
|
||||
images = list(dict.fromkeys(get_images_from_soup(scrape.soup, None)))
|
||||
|
||||
recipe = Recipe.objects.create(
|
||||
name=recipe_json['name'].strip(),
|
||||
@ -45,6 +45,7 @@ class CookBookApp(Integration):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
step = Step.objects.create(instruction=recipe_json['recipeInstructions'], space=self.request.space, )
|
||||
|
||||
if 'nutrition' in recipe_json:
|
||||
|
@ -69,7 +69,9 @@
|
||||
v-if="recipe.imported !== undefined && recipe.imported"
|
||||
target="_blank">{{
|
||||
recipe.recipe_name
|
||||
}}</a> <a target="_blank" :href="`${resolveDjangoUrl('view_search') }?query=${recipe.recipe_name}`" v-else>{{ recipe.recipe_name }}</a>
|
||||
}}</a> <a target="_blank"
|
||||
:href="`${resolveDjangoUrl('view_search') }?query=${recipe.recipe_name}`"
|
||||
v-else>{{ recipe.recipe_name }}</a>
|
||||
<b-badge class="float-right text-white">{{ index + 1 }}</b-badge>
|
||||
</h5>
|
||||
<p class="mb-0">
|
||||
@ -212,6 +214,7 @@ export default {
|
||||
}
|
||||
if (out.info !== '') {
|
||||
let items = out.info.split(/:(.*)/s)[1]
|
||||
if (items !== undefined) {
|
||||
items = items.split(",")
|
||||
out.duplicates_total = items.length
|
||||
out.recipes.forEach((recipe) => {
|
||||
@ -222,6 +225,8 @@ export default {
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
} else {
|
||||
if (out.imported_total > 0) {
|
||||
out.recipes.forEach((recipe) => {
|
||||
|
Reference in New Issue
Block a user