Open koenieee opened 3 years ago
Hi koenieee,
Glad you are enjoying the repo. I started this project with the exact same idea, sadly life required me to spend my time elsewhere and put this project on hold.
Picnic does not provide any way to use the barcode, so a self made dataset with barcodes and product ids would probably the only solution. I tried some tinkering with EAN-API services (this one for example) and use the output from those sites to query the products, but it proved to be unreliable at best.
I'd love to join and help you continuing this idea, please keep me posted on any updates!
Hi Mike,
Thanks for pointing out. Indeed I have the same idea. I am going to use the AH api/Jumbo api (Supermarktconnector python) to find the barcode with the product name and match the name in my picnic order list using fuzzy text matching. I will start a repository with some code and scripts for homeassistant. Just bought a barcode scanner to have some scanning fun haha, it's nice to play winkeltje! I also had to idea to match a picture of an union using opencv with a image of picnic product item. So you can hold something in front of a webcam to find out what it is.. Maybe my Google Home assistant can tell me what product it is (using TTS and HomeAssistant).
This will be a long term project, but well I have some time at the moment :)
Hi! Just wanting to know I'm too thinkering with this idea. I made a PHP-client several months ago. But found out that urls arent working anymore. Thanks to this repo I could find the right url again (and User-Agent... ;) )!
Back to the idea.. I wasted some hours creating a barcode scanner myself in Android based on the Google Vision barcode scanner. I now have a app which scans the EAN and sends it back to a backend. This is basically a POC. If the mobile version works I'm going to embed a barcode scanner in my kitchen, maybe using a Arduino. Now just where you guys were, I'm at this point where I wanted to match the EAN with the Picnic products. I saw several services which provides a EAN-database but they are all paid. So thats a no-go. I did found out that the site of Coop uses the ean in the url... So maybe that's a entry point. The only way you could match it is by name then and that's not going to be fail proof. I can imagine that I'm going to map the products by myself since my basket is basically the same every week.
It's very funy but also very scarry that I had the same ideas as @koenieee last week... Maybe we can join forces and create something out of this?
Hi Mike and Fan1200,
I just started a repository to import picnic deliveries in grocy. With all the product information, such as weight and how much. I have two friends who are also interested in this project. Good idea to join forces. Indeed fan1200, I think we acutally have to set the barcodes ourself. Maybe barcodebuddy can help with that. Would also be great to share recipes and the product database!
https://github.com/koenieee/Grocy-Picnic
The code is't nice yet, normally I program in C++ and I'm learning python with this project
I just stubled upon this repo. First of all: kudo's that it already exists. I was already making preperations to make this my first py + github thing ever (I'm a PowerShell guy, so py should be doable). I'm exactly thinking the same way. I'm not using Grocy yet, but if Picnic integration is available, then it would be awesome.
As far as barcodes: GS1 is an international company who has a lot of barcodes is their system. I'm not sure if there is a free api available though.
If there is anything I can do regarding testing or whatever, I'm very happy to help!
Ok, I think I've a project for this weekend :)
I just looked at GS1 as @marti28 suggested but that only brings up information about the issuer/company behind the EAN. The only information you can use to match the product is by matching them with the company information provided on the PDP. So that's little to no use.
After another try to figure out how to identifying the product based on what Picnic gives it leaves with me with only one option and that is matching by name. Given an EAN I could try to render it through the website of Coop. It uses the EAN in the url, so that makes it easy to find something. If not available I could to try to use other sources. For example I found https://nl.openfoodfacts.org/. It seems to be a open source project to link any food related information to a product. Such as the ingredients. You could enter a EAN and it could you give more product information. The database seems to be completly free of access as you could download a nightly export. You could even use the API for a single search. With the information given on openfoodfacts you could match it against the name, 'ingredients_blob' and 'nutritional_values'.
It's not failproof but I think that even if you try to match by name it could result into a really nice dataset from which you could kickstart. Anyways, tomorrow I'm going to try this. I'll keep you posted!
@koenieee is there a link available for barcodebuddy? I'm willing to enter my share of codes and products ;)
Hello @fan1200 and @marti28. Thanks for wanting to help with this project. I can add you and @MikeBrink to my repository so we can work together on this. Next week i have some extra time to continue the product import for picnic.
Barcodebuddy can be found here Have a look at: https://github.com/Forceu/barcodebuddy
Can you add a list of products with their picnic id and barcode in the repo?
So, after some hours wasted. I managed to create a "system" that looks up eans and finds product names. Pretty much like Barcodebuddy does. It only takes 2 sources: Coop and OpenFoodFacts. From the 26 random products I scanned in my kitchen and bathroom it found 17 names. The products that could't been found were either not Googleable or found on some website I can't really scrape.
With the names found it was time to match it up against the product database from Picnic. That became harder than I thought. An simple solution you could think of was using the "like" function in Mysql. Well, that was not really helpful (as expected). Then I knew I could use the PHP-function "similar_text". The function could match two strings and gives back a percentage of how similar one is to another. The function seems to work fine on paper but I'm not going use it since I have to check all products against the available ean results. Since "similar_text" is a levenshtein distance method I found a Mysql procedure function that I could use. That would give me a option to match the given product name against the Picnic ones. It worked! I got 10 out of 16 results right. But it's painfully slow. Each calculation took around a minute to process. So I trashed that idea as well.
Now still with those thoughts of matching product names I only had one option left. Using the Elasticsearch. The major benefit of this method is that you have more control on searching thru several aspects and within a matter of a few seconds. After indexing the products (name and description) I could make some queries. I used a multi match query and a boosted one. Both seem to have it's advantages but still could bring up some false-positives results. For example: "Zuivelmeester Yoghurt Griekse stijl 10% vet" would give me "Optimel Griekse stijl yoghurt kers 0% vet" as a multi match result and "Bio+ yoghurt Griekse stijl 10%" as a boosted result. While "Palmolive Vloeibare zeep amandel" gives back "Palmolive handzeep melk & amandel" as a multi match result. And that's the right one!
So after all those tries. I still came to the conclusion that you can't automate this process with enough satisfaction. It could give some good results but most of the time it's not reliable. I still want to proceed with these ideas but I'm going to wrap it in a GUI. It would find some results. Take the top 5 products. Show them and I've to choose which product it is. Doing it in a web UI could give me some joy thru all the CLI-darkness. And it could be a nice project to learn VueJS.
As for BarcodeBuddy and Grocery... I can't really find any use of it. The Grocery app does too much and the UI looks outdated. It's a shame that BarcodeBuddy doesn't stand on its own and relies on Grocery. Otherwise it could have been great for this purpose. And the fact that you have run locally or host it yourself doesn't help us either to complete our goal ;)
For now I added my results: product names, eans and product ids, in a json file stored within the repo of @koenieee https://github.com/koenieee/Grocy-Picnic maybe we can create a webservice where we can put our results per request and pulling it out with a simple request?
Wow I love the progress guys! Sadly I don't have much time to contribute to this effort yet, I am currently wrapping up my masters degree. However, I do have an idea for a possible approach:
There is also a huge interest for the retrieval of images (getting multiple emails a month asking for this), but I did not intent this wrapper for that purpose initially (also picnic might not be thrilled with us scraping huge amounts of image data). However, it might be interesting for a "product recognition AI"? If so I can dedicate some time in two weeks maybe.
I was hoping that some of the people emailing me about the images would pick up this endeavor, but it doesn't seem so. It also takes some time for me to reverse engineer the API.
@MikeBrink I could save you time by sharing my code. I already made some scripts to scrape products and categories. The only thing is that it was written PHP. But I think Picnic is not going to be so thrilled about this. It's like 7000 products 😅. And Coop can be easier, they also have a app and thus an API that you could use.
@fan1200 thanks for the first product list, I added the a python function inside the picnic import script to search for EAN connected to the PicnicID. So whenever someone adds an item to the list it will be automatically found. I made my import script a little more user friendly. But it's working quite nice already, @MikeBrink pictures are also imported in Grocy from picnic. You can just append the img_id to a base url and get the picture.
@fan1200 @MikeBrink @marti28 I updated my repository with some new code, would be nice if someone could test it and give me feedback. I tried to make it a little bit more user friendly, also with installing and setting up the grocy database :) It should work with adding the products, importing and increasing stock.
We still have to scan more products to get some barcodes... Now I'm going to try to see if scraping a recipe website and match them with grocy products is possible...
@koenieee I'm afraid I can't test your implementation since I don't use Python but it seems fine. I made some progress of making a "Barcode Searcher"-package. Since I need to use it for my personal use I thought it would be nice to share it with the rest of the world. It is written PHP and kind of relies on the Laravel Framework which I mostly use. The available providers are: Albert Heijn, CodeChecker, Coop, Jumbo, OpenFoodFact, UpcDatabase and UpcItemDb. I took some inspiration out of all the available code that was already Github. And added some of my own.
Tomorrow I'll will update the ean list with codes and product ids ;)
It's still in development but the code is here: https://github.com/fan1200/barcode_seacher/tree/develop
@koenieee I updated the product list with 37 new products.
I'm not sure if I'm of any help to you guys, but I created a very messy but working Python script containing a hunting mode 🥚 This is the way I connect ean codes to picnic products :) I am in no way a professionall Python developer, so don't expect to much.
I'm not sure if I'm of any help to you guys, but I created a very messy but working Python script containing a hunting mode This is the way I connect ean codes to picnic products :) I am in no way a professionall Python developer, so don't expect to much.
So, after a year I'm going to bump this thread into 2022 with some news. By accident I noticed that a product package that I recently bought had a QR-code. It was a Picnic Branded product. So when scanning the QR I got greeted with a URL that included the EAN and it would have redirected me to the PDP of the product in the app.
The url is: https://picnic.app/qr/gtin/8720326001681 it redirects to https://picnic.app/nl/deeplink/?path=store/storefront/product-detail;id=11455430 which would give us the product id. It seems like they finally integrated some support for EAN usage. It also works on non-picnic branded products.
So I'm just leaving this message here. Do what you like with it. I kind of abandoned the project due to lack of time and constraints. I may continue some kind of project since it now should be easy to integrate EAN based operations into some home automation without the hassle of using third party searching or keeping up an database.
If there are any Go users that want to quickly get a picnic ID from an eancode, I created a very small but nice package. You can find it at https://pkg.go.dev/github.com/larsverp/go-eantopicnic
A big thanks to @fan1200 for sharing this information! ❤️
Can someone confirm that https://picnic.app/qr/gtin is still working? I have no luck using it.
To make the work of others easier:
import json
from python_picnic_api import PicnicAPI
p = PicnicAPI("XXX","XXX",'de');
def getProductIdFromEAN(p, EAN):
response = p.session.get("https://picnic.app/qr/gtin/" + EAN)
url = response.url
if ";id=" in url:
return url.split(";id=",1)[1]
else:
return None
id = getProductIdFromEAN(p, "4037400434315")
print(id)
if (id):
print(json.dumps(p.get_article(id), indent=4))
The issue might be there are a few more redirects. I see the following redirects in the chrome debugger:
This library should follow the Location
header till there is something like product-detail;id=
.
If that's too complex, you could change the base url to https://gtin-resolver-prod.nl.picnicinternational.com/qr/gtin/[EAN]/
.
But picnic could change the underlying infra, so it's best to keep using https://picnic.app/qr/gtin/ because that's what they put in the QR's and should be supported.
Hi Mike,
Nice to see your work on the picnic api. Just tried it and works awesome! I want to integrate my picnic orders in Home Assistant with the addon Grocy.
My plan is as follows:
As an alternative it could say to my Google Home assistant:
But it would be nice to use a barcode with an IP camera in my pantry. Unfortanly I can't find the barcodes in from picnic products in the app. I tried searching my kippendijfilet but the kip wasn't found :)
Do you know if there is a way to connect the barcode to a product? Searching for the product ID in the app is working fine.. (Example is from barcode tomatos in plastic..)