Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support import from KptnCook #3249

Closed
a-waider opened this issue Aug 9, 2024 · 16 comments
Closed

Support import from KptnCook #3249

a-waider opened this issue Aug 9, 2024 · 16 comments
Labels
enhancement New feature or request

Comments

@a-waider
Copy link

a-waider commented Aug 9, 2024

Is your feature request related to a problem? Please describe.

KptnCook is a mobile app (https://www.kptncook.com/de-de) which has no web interface for recipes and therefore can't be imported via the default importers into tandoor.

Describe the solution you'd like

There is an API which can be accessed with an account. The api calles are all documented in this repository. The KPTNCOOK_API_KEY seems to be a constant across all api calls and users. The API returns detailed JSON representations of the recipe and is very suitable to be imported into tandoor. The JSON output of a recipe only needs to be converted into the tandoor format.

A sample recipe is attached.
recipe.json

Describe alternatives you've considered

If the Tandoor app can't integrate an importer for KptnCook a separate program must be implemented which can convert the JSON returned by the KptnCook API to the Tandoor format and may be sent directly to the Tandoor API.

Additional context

No response

@a-waider a-waider added the enhancement New feature or request label Aug 9, 2024
@smilerz
Copy link
Collaborator

smilerz commented Aug 9, 2024

KptnCook has a website and is supported by the recipe-scraper.

@smilerz smilerz closed this as completed Aug 9, 2024
@a-waider
Copy link
Author

If I try to import e.g. the following recipe via the Importer, I get the result that is attached in the screenshot. It's missing all steps and there are no ingredients extracted. Do I do anything wrong?

Screenshot_20240812-215835.png

@smilerz
Copy link
Collaborator

smilerz commented Aug 12, 2024

@vabene1111 there is a breaking change in validators.url(url) there are a couple instances in api.py

I'm not sure what expected behavior should be.

image

@smilerz smilerz reopened this Aug 12, 2024
@smilerz
Copy link
Collaborator

smilerz commented Aug 12, 2024

@a-waider that site imports fine on the next version.

@smilerz smilerz closed this as completed Aug 12, 2024
@a-waider
Copy link
Author

Alright, thanks for you quick reply. Do you already have a schedule when the next release will be?

@vabene1111
Copy link
Collaborator

Schedule : no idea
@smilerz i think it's only used to prevent access to local ips/URLs, thanks for the heads up, I will fix it with the next release of I don't forget :)

@vabene1111
Copy link
Collaborator

ok fixed in f6f6754 by removing validators package in favor of a proper validation system without library dependence

@gloriousDan
Copy link
Contributor

I think this issue won't be completely fixed by your changes.

The issue is that kptncook only includes some ingredients in the schema when accessing recipes via the website.

As an example, this recipe: https://mobile.kptncook.com/recipe/pinterest/Low-Carb-Tarte-Flamb%C3%A9e-with-Serrano-Ham-%26-Cream-Cheese/315c3c32
Includes only the following metadata without steps:

{
  "@context": {
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "schema": "http://schema.org/"
  },
  "@id": "https://mobile.kptncook.com/recipe/pinterest/Low-Carb-Tarte-Flamb%C3%A9e-with-Serrano-Ham-%26-Cream-Cheese/315c3c32?_branch_match_id=1354495389685832555&_branch_referrer=H4sIAAAAAAAAA8soKSkottLXL85ILMrMS9fLLijJS87Pz9ZLzs%2FVDwu0MHYtjCzLz02yj49PKkrMS86IT8vJL4%2FPTLE1NDY1MbE0NbawNDcxMDa1MDWwAABoT5PFTQAAAA%3D%3D#Recipe",
  "@type": "schema:Recipe",
  "schema:image": {
    "@id": "https://images.kptncook.com/59b8e92b950000261749a08c.jpg"
  },
  "schema:ingredients": [
    "\n    \n          pepper\n    \n                ",
    "\n    \n          salt\n    \n                ",
    "\n    \n        60 g prosciutto\n    \n                ",
    "\n    \n        1 tsp herbes de Provence, dried\n    \n                ",
    "\n    \n        0.5 tsp chili flake\n    \n                ",
    "\n    \n        20 g arugula\n    \n                ",
    "\n    \n        2  eggs\n    \n                ",
    "\n    \n        80 g cream cheese\n    \n                ",
    "\n    \n        200 g curd cheese\n    \n                ",
    "\n    \n        160 g cherry tomatoes\n    \n                "
  ],
  "schema:name": "\n                Low Carb Tarte Flambée with Serrano Ham & Cream Cheese\n            ",
  "schema:recipeYield": "For 2 Person",
  "schema:totalTime": "PT25M\n            "
}

I implemented a custom solution for kptncook which got the additional data with extra requests to the kptncook api similar to how the app does it within recipe_scrapers.
But since v15 of recipe_scrapers it's not possible to do additional requests and thus the custom kptncook code got dropped.

It would theorethically be possible to include the API calling code within Tandoor similar to how it was done in recipe_scrapers. @vabene1111 would you be open to that or rather avoid such specific code within tandoor?

@gloriousDan
Copy link
Contributor

I just got another idea/ workaround. It should be possible to write a custom bookmarklet which loads the additional data from kptncook's api and then imports that into tandoor just like the normal bookmarklet does. This wouldn't require changes within core tandoor.

@vabene1111
Copy link
Collaborator

Hi, I am sorry, my comment was only refering to the validation code for URL's, to be honest I didn't read the whole issue because it was closed and I thought it was done.

While from a user perspective some custom import code would be great and preferable I dont want to come in conflict with any recipe page. If they do not provide the data in the schema they might not "want" it to be scraped. Providing a solution that circumvents protective measures is illegal at least in germany so I suggest you choose the second option.

@delta0815
Copy link

Hi all,

I see that this discussion is already closed, but instead of opening a new question I thougt I give it a try and raise it here. @vabene1111 I fully understand your concerns regarding the legal situation so I guess an implementation into Tandoor's core is a no-no. However I had a subscription with KpntCook and I'd love to get the recipes out of that account. I found a possible workaround by going through "My Recipe Box" but as I plan to fully rely on Tandoor's capabilites I was wondering if you see any other option (e.g. adding an option in Tandoor's settings like "Use external recipe_scraper-Importer instead of Tandoor's internal algorithm".

I'd love to hear your thoughts on that.

Best regards,

Oliver

@smilerz
Copy link
Collaborator

smilerz commented Aug 29, 2024

Hi all,

I see that this discussion is already closed, but instead of opening a new question I thougt I give it a try and raise it here. @vabene1111 I fully understand your concerns regarding the legal situation so I guess an implementation into Tandoor's core is a no-no. However I had a subscription with KpntCook and I'd love to get the recipes out of that account. I found a possible workaround by going through "My Recipe Box" but as I plan to fully rely on Tandoor's capabilites I was wondering if you see any other option (e.g. adding an option in Tandoor's settings like "Use external recipe_scraper-Importer instead of Tandoor's internal algorithm".

If you have a subscription - you can navigate to the recipe and use the bookmarklet to save the recipe to Tandoor.

@delta0815
Copy link

Hi all,
I see that this discussion is already closed, but instead of opening a new question I thougt I give it a try and raise it here. @vabene1111 I fully understand your concerns regarding the legal situation so I guess an implementation into Tandoor's core is a no-no. However I had a subscription with KpntCook and I'd love to get the recipes out of that account. I found a possible workaround by going through "My Recipe Box" but as I plan to fully rely on Tandoor's capabilites I was wondering if you see any other option (e.g. adding an option in Tandoor's settings like "Use external recipe_scraper-Importer instead of Tandoor's internal algorithm".

If you have a subscription - you can navigate to the recipe and use the bookmarklet to save the recipe to Tandoor.

Well... that is what I tried but it only imports the ingredients but not the steps which "My Recipe Box" does.

@smilerz
Copy link
Collaborator

smilerz commented Aug 29, 2024

If you have a subscription - you can navigate to the recipe and use the bookmarklet to save the recipe to Tandoor.

Well... that is what I tried but it only imports the ingredients but not the steps which "My Recipe Box" does.

My mistake, sorry. We aren't likely to add any additional integrations - but any external scraper that will convert the site into json+ld format can be manually imported in the 'source' tab.

@vabene1111
Copy link
Collaborator

I guess the most feasable way would probably to write a small script that retrieves data and pushes it to tandoors api. the recipe object in tandoor is quite complex but with a bit of code easy to re-create, just take an existing API response as your base and remove everything you do not need.

@gloriousDan
Copy link
Contributor

There's already anothrr project to sync kptncook with mealie and paprika. Maybe you could contribute or request a tandoor integration there?

https://github.com/ephes/kptncook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants