ephes / kptncook

Fetch receipts from kptncook API and export them to mealie or paprika
MIT License
39 stars 3 forks source link

Update to mealie-API of v1.0.0-beta5 #20

Closed alexdetsch closed 1 year ago

alexdetsch commented 1 year ago

I've updated the mealie-client for API-version of v1.0.0-beta5. Since there is yet no documentation of the API changes, I just reverse engineered what the webfrontend does. Additionally, I changed the way, the kptncook-client downloads the recipes (changed the Accept-Header), so the json contains the step-images in a more managable manner and so it now also uploads the assets for step-images in mealie. As mealie v1 introduces a scaling-function for recipes, I added a food- and unit-parser so the quantity of the ingredients gets handled correctly and you can scale the amount of the ingredients to whatever portion count you want. Kptncook has a default portion size of 2, so I divide the amount by 2 to have a default portion count of 1 as mealie can currently only calculate multiple of the default portion count, but not in single steps. I also fixed the tag-setting, as its basically the same as for food and units.

Sorry for not following your naming guideline (sometimes camelCase instead of snake case and use of Alias as of the API of mealie wants camelCase naming and I was in a rush). But you`re welcome to make any refactoring you want :) And sorry for one big Commit and Pull request, I hope the changes are clear enough.

ephes commented 1 year ago

Wow, thanks a lot 😃. I need some time to look at the changes, but this looks very promising.

ephes commented 1 year ago

Ok, spent the best part of the evening getting my mealie fork up to date. Maybe I can try your changes against my fork tomorrow.

alexdetsch commented 1 year ago

I've seen, that sometimes recipes get uploaded again in a later run of sync-with-mealie (with "-1" as slug suffix). Idon't know yet, when and why this happens as I hadn't time to investigate until now, so just as a hint.

ephes commented 1 year ago

Oh, one more thing: do you have a local test installation? If not you might want to take a look at my mealie fork. If you run it locally you get full access to the standard swagger api documentation at api docs. You can also use the jupyter notebooks in the notebooks dir to test adding recipes. Makes debugging a lot easier.

Have a nice weekend, Jochen

ulimanaio commented 1 year ago

At the moment this is working for me but all recepies are English. Here is a quick workaround for getting German KptnCook recipies into Mealie.

  1. Share via email
  2. Open Link in email.
  3. Copy URL
  4. Delete everything after and including "_branch_match_id" ...
  5. Add "lang=de" behind "?"

Example: https://mobile.kptncook.com/recipe/pinterest/Tomaten-Tortelloni-Suppe/513faa3b?lang=de

ephes commented 1 year ago

Hi @ulimanaio,

hmm, weird - the receipts I imported into mealie are all german by default. Maybe it's a setting in your kptncook account or something like this?

But good to know there's a way to set the language explicitly 😄.