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