kacpi2442 / am_bot

Using the toogoodtogo and foodsi APIs to notify me via a Telegram bot for open offers
41 stars 18 forks source link

Foodsi - new error #31

Open antonioli86 opened 1 year ago

antonioli86 commented 1 year ago

Hi,

Seems with latest update they changed something:

Error occured: 
 (most recent call last):
  File "/home/cmjr86/.local/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cmjr86/Downloads/am_bot-main1/watch_script.py", line 247, in refresh
    foodsi()
  File "/home/cmjr86/Downloads/am_bot-main1/watch_script.py", line 166, in foodsi
    items += parse_foodsi_api(foodsi_api.json())
  File "/home/cmjr86/.local/lib/python3.10/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Someone already debug it?

antonioli86 commented 1 year ago

It seems they moved the API URL: imagem

Maybe will need to extract the app APK to check the new url - application was updated during night.

For the auth still the same: imagem

Robertnoob12 commented 1 year ago

yeah. new update...

Robertnoob12 commented 1 year ago

can yall send the python code after so i can update my bot

antonioli86 commented 1 year ago

First I need to know the new endpoint. :( I decompiled the APK and still see v2/restaurants. -.-

Robertnoob12 commented 1 year ago

how can i decomply the apk. ill try then i updated the apk today

antonioli86 commented 1 year ago

how can i decomply the apk. ill try then i updated the apk today

I used this http://www.javadecompilers.com/apk

Robertnoob12 commented 1 year ago

okay i will check it out & will let u know.

Robertnoob12 commented 1 year ago

@antonioli86 how is the file named for the api

antonioli86 commented 1 year ago

@antonioli86 how is the file named for the api

In the past I used apps like AnyTXT to search content in all files. v2/restaurants is in a couple of lib...so files.

Robertnoob12 commented 1 year ago

do you have discord, i will give u the apk file in dms. u can search thru it. i got in and its the recent one.

Robertnoob12 commented 1 year ago

because here i cant send .apk

Robertnoob12 commented 1 year ago

the zip has too much MB'S @antonioli86

antonioli86 commented 1 year ago

I took in the morning the APK from APKPure. I did not found the changes... :(

Robertnoob12 commented 1 year ago

maybe u took a old version it should be 2.10 not 2.05

antonioli86 commented 1 year ago

maybe u took a old version it should be 2.10 not 2.05

I took the 2.10.

Robertnoob12 commented 1 year ago

maybe its hidden somewhere they keeped the restaurant v2 in there but actually it isnt used

Robertnoob12 commented 1 year ago

look around

Robertnoob12 commented 1 year ago

have u found anything? @antonioli86

antonioli86 commented 1 year ago

Only in the evening I will take a look...

Robertnoob12 commented 1 year ago

ok

Robertnoob12 commented 1 year ago

ugh... i cant find it

Robertnoob12 commented 1 year ago

some dude told me its impossible to find these files inside the code. he said i must do spoofing with skipping certificates of the app

Robertnoob12 commented 1 year ago

@antonioli86

antonioli86 commented 1 year ago

some dude told me its impossible to find these files inside the code. he said i must do spoofing with skipping certificates of the app

This is the normal approach. Anyway keep in mind I'm doing this only in my free time - I cannot promise anything. Even I tried some combinations of URL. Also I compared the libs from old version to new one and now are using some additional packages.

Robertnoob12 commented 1 year ago

hopefully it will be done soon, i realized all my packages got to status "sold out" not "unavailable"

Robertnoob12 commented 1 year ago

maybe try the spoofing method, it might be easier to do @antonioli86 and faster

antonioli86 commented 1 year ago

A couple of things: I needed to edit the APK to accept user certificates - in order to enable Fiddler to capture decrypted SSL traffic from the app. App: https://drive.google.com/file/d/12uVDk9JleiPzHBydNCSrZ8R6EzeIheP4/view?usp=drive_link

I followed this guide: https://medium.com/@roy2477/decrypting-android-app-ssl-traffic-c480e2143743

I did a couple of Fiddler traces - based on some clicking in the app: foodsi.zip

Host seems is control.kochava.com.

Maybe someone based on this can help.

Robertnoob12 commented 1 year ago

the control.kochava.com doesnt seem to do anything. just prints success "1"

Robertnoob12 commented 1 year ago

i noticed some apis in foodsi.saz file in api.bug.fender.com/log/batch

Robertnoob12 commented 1 year ago

going to api.foods.pl/api/v3/user

Robertnoob12 commented 1 year ago

like.. t=Received response from https://api.foodsi.pl/api/v3/user/offers?filter%5Bpackage_category_ids%5D%5Bnot_eq%5D=%5B13%5D&filter%5Bpickup_to%5D%5Bgt%5D=2023-09-20T23%3A18%3A31%2B02%3A00&filter%5Bpackage_category_ids%5D%5Beq%5D=%5B9%2C+1%5D&filter%5Bactive%5D%5Beq%5D=true&filter%5Bcurrent_quantity%5D%5Bgt%5D=0&sort=distance%2Cpickup_from with statusCode: 200

Robertnoob12 commented 1 year ago

kochava seems to be checking what u are doing on the website at the specific time

Robertnoob12 commented 1 year ago

like if u are in pickup menu it shows in the code. but if u are on the page checking products it shows that. gives u ids and keys no apis though i noticed the log/batch gives apis but no restaurants some offers filters most of them. / could you track the app 1 more time by doing the things im saying?

Robertnoob12 commented 1 year ago

@antonioli86

Robertnoob12 commented 1 year ago

Ugh... they update foodsi too often. Hopefully it will be possible to make notify bot when something will be available. Because for me in my city its so rare untill they sell anything.

antonioli86 commented 1 year ago

Ok... some new and work done. So the method should be GET instead POST and the response changed a bit - so it is necessary to change the parser. Output in Kraków (request format as before but changed from requests.post to requests.get:

{'data': [{'id': '1900767', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': ' 🥐🥪🍰 W Cukierni-Piekarni Wenta znajdziecie zarówno pieczywo jak i ciasteczka, ciasta i bułki drożdżowe, szarlotki, serniki, pulchne pączki i wiele innych smakołyków.', 'name': 'duża paczka', 'original_price': '65.0', 'package_category_ids': [1], 'package_created_at': '2022-09-17T22:30:32+00:00', 'package_delivery_fee': '0.0', 'package_id': 251, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/251/01dc8bd3bd.jpg', 'pickup_from': '2023-09-21T14:00:00+00:00', 'pickup_to': '2023-09-21T14:30:00+00:00', 'unit_price': '21.59', 'venue_latitude': 54.5205108162831, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/211/f0a3f07822.jpg', 'venue_longitude': 18.532497886639185, 'venue_name': 'Cukiernia Piekarnia Wenta Dworcowa', 'venue_pickup_address': 'Dworcowa 9, Gdynia', 'venue_url': 'www.cukierniawenta.pl'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900768', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🧀🫒🍷 Produkty włoskie takie jak ser y, makarony, oliwki, wino, ciasteczka czy gorąca czekolada oraz niektóre ciekawe produkty z różnych zakątków świata.', 'name': 'paczka premium mała', 'original_price': '30.0', 'package_category_ids': [2], 'package_created_at': '2022-09-17T22:30:33+00:00', 'package_delivery_fee': '0.0', 'package_id': 296, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/296/3bcd0d2610.jpeg', 'pickup_from': '2023-09-21T16:00:00+00:00', 'pickup_to': '2023-09-21T18:00:00+00:00', 'unit_price': '14.99', 'venue_latitude': 52.223802358345466, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/249/892d6ef5aa.jpeg', 'venue_longitude': 21.008179636126673, 'venue_name': 'Barbastel', 'venue_pickup_address': 'Emilii Plater 8, Warszawa', 'venue_url': 'https://barbastel.pl/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900770', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🌮🌯🥗🍜 Vege MIASTO to warszawskie bistro serwujące dania w 100% roślinne (certyfikat V-Label VEGAN), które cieszą się uznaniem zarówno wegan, jak i osób na diecie tradycyjnej. Ze względu na to w lokalu jest zawsze tłumnie i trudno o wolny stolik. Tym bardziej cieszymy się, że ich dania dostępne są w Zestawach Foodsi. ', 'name': 'paczka niespodzianka', 'original_price': '34.0', 'package_category_ids': [4, 9, 10, 3], 'package_created_at': '2022-09-17T22:31:24+00:00', 'package_delivery_fee': '0.0', 'package_id': 2043, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2043/3b0647e462.jpeg', 'pickup_from': '2023-09-21T15:00:00+00:00', 'pickup_to': '2023-09-21T18:15:00+00:00', 'unit_price': '16.99', 'venue_latitude': 52.24603532966488, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1434/3c31e1a66a.jpg', 'venue_longitude': 21.005011796951294, 'venue_name': 'Vege MIASTO', 'venue_pickup_address': 'Aleja Solidarności 60A, Warszawa', 'venue_url': 'www.vegemiasto.pl'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900771', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🥑🌯🥗 W Salad Story uratujesz świeże wrapy, sałatki, koktajle i soki. Wszystko, co tam znajdziesz to produkty jednodniowe ze świeżych i najlepszych jakościowo składników. Pychota! ', 'name': 'mega paczka', 'original_price': '50.0', 'package_category_ids': [4], 'package_created_at': '2022-09-17T22:30:35+00:00', 'package_delivery_fee': '0.0', 'package_id': 353, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/353/1e7a74e021.jpg', 'pickup_from': '2023-09-21T08:00:00+00:00', 'pickup_to': '2023-09-21T19:00:00+00:00', 'unit_price': '25.0', 'venue_latitude': 50.06749405, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/281/6754d2aec6.jpeg', 'venue_longitude': 19.946487355187834, 'venue_name': 'Salad Story Galeria Krakowska', 'venue_pickup_address': 'Pawia 5, Kraków, (Galeria Krakowska)', 'venue_url': 'http://www.saladstory.com'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900772', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🥞🍰🥪 Pyszne naleśniki na słodko i wytrawnie, kanapki i różne rodzaje ciast.', 'name': 'średnia paczka', 'original_price': '45.0', 'package_category_ids': [4, 9, 1], 'package_created_at': '2022-09-17T22:31:38+00:00', 'package_delivery_fee': '0.0', 'package_id': 2479, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2479/0c5d95fefb.jpeg', 'pickup_from': '2023-09-21T15:28:00+00:00', 'pickup_to': '2023-09-21T15:53:00+00:00', 'unit_price': '14.99', 'venue_latitude': 53.41896085663807, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1722/45954e9572.jpg', 'venue_longitude': 14.544421559539796, 'venue_name': 'Elegancko Cafe', 'venue_pickup_address': 'Potulicka 5, Szczecin', 'venue_url': 'www.facebook.com/profile.php?id=100064150266057'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900773', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🥗🥘🍝 Pyszne, domowe sałatki, kanapki, lunche, zupy czy słodkie wypieki. ', 'name': 'paczka niespodzianka', 'original_price': '50.0', 'package_category_ids': [9, 1], 'package_created_at': '2022-12-06T09:43:37+00:00', 'package_delivery_fee': '0.0', 'package_id': 4334, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/4334/e7fdb19f50.jpg', 'pickup_from': '2023-09-21T17:00:00+00:00', 'pickup_to': '2023-09-21T19:30:00+00:00', 'unit_price': '15.99', 'venue_latitude': 52.236435549999996, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/2687/403352ed83.png', 'venue_longitude': 21.01785383272189, 'venue_name': "N'JOY Good Food", 'venue_pickup_address': 'Nowy Świat 57/59, Warszawa', 'venue_url': ''}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900774', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🍰�🎂  W paczce niespodziance od Fit Cake uratujesz przepyszne ciasta i wypieki.', 'name': 'paczka niespodzianka', 'original_price': '66.0', 'package_category_ids': [1], 'package_created_at': '2022-12-17T22:44:19+00:00', 'package_delivery_fee': '0.0', 'package_id': 4482, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/4482/f04e96810f.jpg', 'pickup_from': '2023-09-21T09:00:00+00:00', 'pickup_to': '2023-09-21T15:30:00+00:00', 'unit_price': '19.99', 'venue_latitude': 54.56689615, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/2759/0954f7160b.jpg', 'venue_longitude': 18.483660566360086, 'venue_name': 'Fit Cake Pogórze', 'venue_pickup_address': 'Mickiewicza 20, Pogórze', 'venue_url': 'https://www.facebook.com/FitCakePogorze/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900775', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🍰🍪 Fit Cake to wyjątkowe miejsce. Znajdziesz tu ciasta, słoiczki, donuty czy batony przygotowywane bez cukru i glutenu z opcjami wegańskimi.', 'name': 'duża paczka', 'original_price': '60.0', 'package_category_ids': [1, 10], 'package_created_at': '2023-05-15T15:08:41+00:00', 'package_delivery_fee': '0.0', 'package_id': 6550, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/6550/6b9e38eca6.jpg', 'pickup_from': '2023-09-21T10:00:00+00:00', 'pickup_to': '2023-09-21T17:00:00+00:00', 'unit_price': '19.99', 'venue_latitude': 52.16317015, 'venue_logo': None, 'venue_longitude': 21.070958161997595, 'venue_name': 'Fit Cake Wilanów', 'venue_pickup_address': 'Aleja Rzeczypospolitej 12 lok. U6, Warszawa', 'venue_url': 'https://www.facebook.com/fitcake.warszawa.ursynow/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900777', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': ' 🌭🥗🌯 Paczki zawierać mogą szaszłyk z grilla, kiełbasę z grilla, pieczone ziemniaki.  ', 'name': 'paczka niespodzianka', 'original_price': '40.0', 'package_category_ids': [4, 9], 'package_created_at': '2022-09-17T22:30:54+00:00', 'package_delivery_fee': '0.0', 'package_id': 1041, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/1041/bbae5153fe.jpeg', 'pickup_from': '2023-09-21T17:30:00+00:00', 'pickup_to': '2023-09-21T18:00:00+00:00', 'unit_price': '19.99', 'venue_latitude': 54.17859704171261, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/798/005ed99810.jpeg', 'venue_longitude': 16.209686270420608, 'venue_name': 'Grill Park', 'venue_pickup_address': 'ul. Sybiraków  , Koszalin, (parking przy plaży Wodna Dolina) ', 'venue_url': 'http://www.facebook.com/Grill-Park-Wodna-Dolina-parking-przy-pla%C5%BCy-106800491605680'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900778', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🍰W Bonbon Boutique uratujesz przepyszne francuskie słodkości.', 'name': 'duża paczka słodka', 'original_price': '35.0', 'package_category_ids': [1], 'package_created_at': '2022-09-17T22:31:33+00:00', 'package_delivery_fee': '0.0', 'package_id': 2333, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2333/36cab6fb1f.jpg', 'pickup_from': '2023-09-21T08:00:00+00:00', 'pickup_to': '2023-09-21T18:00:00+00:00', 'unit_price': '14.99', 'venue_latitude': 50.0468664, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1623/91ba9f3385.jpg', 'venue_longitude': 19.9510672, 'venue_name': 'Bonbon boutique', 'venue_pickup_address': 'Nadwiślańska 11, Kraków', 'venue_url': 'https://bybonbon.pl/menu/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900779', 'type': 'offers', 'attributes': {'active': False, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 2, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🥗 🥐🚗 Na stacji CircleK uratujesz pyszne kanapki, sałatki, słodkie wypieki lub artykuły spożywcze. Wszystkie posiłki przygotowujemy na miejscu. Zawsze świeżo i smacznie.', 'name': 'mała paczka', 'original_price': '20.0', 'package_category_ids': [2], 'package_created_at': '2022-10-28T11:58:38+00:00', 'package_delivery_fee': '0.0', 'package_id': 3563, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/3563/e433834845.jpg', 'pickup_from': '2023-09-21T07:30:00+00:00', 'pickup_to': '2023-09-21T15:30:00+00:00', 'unit_price': '9.99', 'venue_latitude': 53.2602929, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/2264/77b8b9df63.jpg', 'venue_longitude': 19.3950431, 'venue_name': 'Circle K Sądowa', 'venue_pickup_address': 'Sądowa 6, Brodnica', 'venue_url': 'https://www.circlek.pl/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900769', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🥖🍞🍰 Rzemieślnicze pieczywo z Wytwórni Chleba oraz pyszne ciasta i słodkie wypieki.', 'name': 'paczka niespodzianka', 'original_price': '30.0', 'package_category_ids': [1], 'package_created_at': '2022-09-17T22:30:53+00:00', 'package_delivery_fee': '0.0', 'package_id': 1025, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/1025/0117eea6b9.jpeg', 'pickup_from': '2023-09-21T10:30:00+00:00', 'pickup_to': '2023-09-21T17:40:00+00:00', 'unit_price': '9.99', 'venue_latitude': 52.25803855416548, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/787/27b9e0466a.jpeg', 'venue_longitude': 20.963468843574287, 'venue_name': 'Czarna Mańka Żoliborz', 'venue_pickup_address': 'Powązkowska 13/lok.U4, Warszawa', 'venue_url': 'www.facebook.com/czarnamankacafe'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900780', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🥗 🥐🚗 Na stacji CircleK uratujesz pyszne kanapki, sałatki, słodkie wypieki lub artykuły spożywcze. Wszystkie posiłki przygotowujemy na miejscu. Zawsze świeżo i smacznie.', 'name': 'mała paczka', 'original_price': '20.0', 'package_category_ids': [2], 'package_created_at': '2022-10-28T12:00:18+00:00', 'package_delivery_fee': '0.0', 'package_id': 3565, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/3565/77be41f5dc.jpg', 'pickup_from': '2023-09-21T10:00:00+00:00', 'pickup_to': '2023-09-21T18:00:00+00:00', 'unit_price': '9.99', 'venue_latitude': 52.382236859112815, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/2266/acfe5db46d.jpg', 'venue_longitude': 16.973721860178678, 'venue_name': 'Circle K Bobrzańska', 'venue_pickup_address': 'Bobrzańska 21, Poznań', 'venue_url': 'https://www.circlek.pl/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900781', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🌵🪴🌺 rośliny doniczkowe, balkonowe i
 ogrodowe wraz z osłonkami. Zadbaj o nie, a odwdzięczą się pięknem.', 'name': 'mała paczka z roślinami doniczkowymi', 'original_price': '60.0', 'package_category_ids': [8], 'package_created_at': '2023-07-10T14:35:39+00:00', 'package_delivery_fee': '0.0', 'package_id': 7378, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/7378/401130d8d8.jpeg', 'pickup_from': '2023-09-21T06:00:00+00:00', 'pickup_to': '2023-09-21T17:30:00+00:00', 'unit_price': '29.99', 'venue_latitude': 53.1226588, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/4065/f6ad3b8f05.jpeg', 'venue_longitude': 18.0381082, 'venue_name': 'Blumen 2000 (Skłodowskiej-Curie)', 'venue_pickup_address': 'ul. Marii Skłodowskiej-Curie 28, Bydgoszcz', 'venue_url': 'https://www.facebook.com/KwiaciarniaBlumen2000'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900782', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🍰🍪 Pyszne ciasta, desery i wypieki, czasem także rzemieślnicza kawa w ziarnach.', 'name': 'duża paczka', 'original_price': '50.0', 'package_category_ids': [1, 8, 10], 'package_created_at': '2022-09-17T22:31:37+00:00', 'package_delivery_fee': '0.0', 'package_id': 2421, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2421/e88ed66f9e.jpeg', 'pickup_from': '2023-09-21T15:00:00+00:00', 'pickup_to': '2023-09-21T16:00:00+00:00', 'unit_price': '16.99', 'venue_latitude': 54.38130341484121, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1685/ee62fbdb1d.jpeg', 'venue_longitude': 18.590616303231055, 'venue_name': 'Struśkawka', 'venue_pickup_address': 'Słowackiego 19, Gdańsk', 'venue_url': 'https://www.facebook.com/Stru%C5%9Bkawka_Gda%C5%84sk-103711665075813'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900786', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '�🍝🍜  Xpress Pizza to mała pizzeria z prawdziwą, włoską kuchnią, gdzie uratujesz pizze, luncze, slice, makarony, sałatki, czasem również desery i napoje.', 'name': 'paczka niespodzianka', 'original_price': '45.0', 'package_category_ids': [4, 9], 'package_created_at': '2022-09-17T22:30:54+00:00', 'package_delivery_fee': '0.0', 'package_id': 1067, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/1067/9c1b79144e.jpg', 'pickup_from': '2023-09-21T15:36:00+00:00', 'pickup_to': '2023-09-21T16:59:00+00:00', 'unit_price': '14.99', 'venue_latitude': 50.26110982866997, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/818/66c5a3791e.jpg', 'venue_longitude': 19.016869471066546, 'venue_name': 'Xpress Pizza', 'venue_pickup_address': 'Chopina 10, Katowice', 'venue_url': 'http://www.facebook.com/xpresspizzakato'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900787', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🍰🍪 FIT ciasta, torty, batony, pączki, donuty czy owsianki - wszystko BEZ cukru i glutenu, z wersjami wegańskimi. NO SUGAR, NO PROBLEM! ', 'name': 'mała paczka', 'original_price': '30.0', 'package_category_ids': [1, 10], 'package_created_at': '2022-09-17T22:31:37+00:00', 'package_delivery_fee': '0.0', 'package_id': 2425, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2425/72d73e9425.jpg', 'pickup_from': '2023-09-21T16:00:00+00:00', 'pickup_to': '2023-09-21T17:00:00+00:00', 'unit_price': '9.99', 'venue_latitude': 51.10037961457777, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1688/af0cc2dcb0.jpeg', 'venue_longitude': 17.0331424, 'venue_name': 'Fit Cake Wrocław', 'venue_pickup_address': 'Piłsudskiego 89a, Wrocław', 'venue_url': 'https://www.facebook.com/FitCakeWroclawStareMiasto'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900788', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🥗 🥐🚗 Na stacji CircleK uratujesz pyszne kanapki, sałatki, słodkie wypieki lub artykuły spożywcze. Wszystkie posiłki przygotowujemy na miejscu. Zawsze świeżo i smacznie.', 'name': 'mała paczka', 'original_price': '20.0', 'package_category_ids': [2], 'package_created_at': '2022-10-04T12:25:08+00:00', 'package_delivery_fee': '0.0', 'package_id': 3144, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/3144/58e50e71b2.jpg', 'pickup_from': '2023-09-21T04:03:00+00:00', 'pickup_to': '2023-09-21T19:15:00+00:00', 'unit_price': '9.99', 'venue_latitude': 52.198551922522356, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/2055/ff1f97a52c.jpg', 'venue_longitude': 21.023402794490682, 'venue_name': 'Circle K Puławska 86', 'venue_pickup_address': 'Puławska 86, Warszawa', 'venue_url': 'https://www.circlek.pl/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900789', 'type': 'offers', 'attributes': {'active': True, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': '🥗 🥐🚗 Na stacji CircleK uratujesz pyszne kanapki, sałatki, słodkie wypieki lub artykuły spożywcze. Wszystkie posiłki przygotowujemy na miejscu. Zawsze świeżo i smacznie.', 'name': 'mała paczka ', 'original_price': '20.0', 'package_category_ids': [2], 'package_created_at': '2022-10-28T12:22:53+00:00', 'package_delivery_fee': '0.0', 'package_id': 3569, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/3569/ce14d0ba5c.jpg', 'pickup_from': '2023-09-21T08:00:00+00:00', 'pickup_to': '2023-09-21T21:00:00+00:00', 'unit_price': '9.99', 'venue_latitude': 52.1521077, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/2267/437aa6685b.jpg', 'venue_longitude': 21.0169127, 'venue_name': 'Circle K Puławska 274', 'venue_pickup_address': 'Puławska 274, Warszawa', 'venue_url': 'https://www.circlek.pl/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}, {'id': '1900785', 'type': 'offers', 'attributes': {'active': False, 'available_from': '2023-09-20T00:01:01+00:00', 'available_to': '2023-09-21T21:59:59+00:00', 'created_at': '2023-09-20T00:01:01+00:00', 'current_quantity': 0, 'delivery_time_from_in_days': 2, 'delivery_time_to_in_days': 2, 'description': 'Data dostawy: Paczki kupione na "dziś" zostaną dostarczone na jutro\r\nPaczki kupione na "jutro" zostaną dostarczone na pojutrze  \r\n\r\n🥗🌮🍝 2 paczki cateringu dietetycznego od Gastro Paczki w cenie 1! Smakcja to miejsce, w którym złożysz zamówienie z dostawą. Każda paczka składa się z 4-5 pysznych, pełnowartościowych i zdrowych posiłków o łącznej wartości ok 1700-2000 kcal. Wszystkie posiłki należy spożyć najpóźniej w dniu dostawy.', 'name': 'paczka z dostawą jutro lub pojutrze', 'original_price': '115.0', 'package_category_ids': [4, 9], 'package_created_at': '2023-01-09T11:53:46+00:00', 'package_delivery_fee': '0.0', 'package_id': 4609, 'package_image': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/4609/efc389d965.jpeg', 'pickup_from': '2023-09-21T04:00:00+00:00', 'pickup_to': '2023-09-21T12:30:00+00:00', 'unit_price': '54.99', 'venue_latitude': 51.76652429225431, 'venue_logo': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/2831/7a8834ba1c.jpeg', 'venue_longitude': 19.459278262051985, 'venue_name': 'Smakcja Łódź', 'venue_pickup_address': 'Paczka zostanie wysłana pod wskazany adres na terenie Łodzi. ', 'venue_url': 'https://gastropaczka.pl/'}, 'relationships': {'package': {'meta': {'included': False}}, 'venue': {'meta': {'included': False}}}}], 'links': {'self': 'https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=1&page%5Bsize%5D=20', 'first': 'https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=1&page%5Bsize%5D=20', 'last': 'https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=681&page%5Bsize%5D=20', 'next': 'https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=2&page%5Bsize%5D=20'}, 'meta': {}}

Then error raises in

Traceback (most recent call last):
  File "C:\Users\carlo\Downloads\am_bot-main\watch_script.py", line 246, in refresh
    foodsi()
  File "C:\Users\carlo\Downloads\am_bot-main\watch_script.py", line 165, in foodsi
    items += parse_foodsi_api(foodsi_api.json())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\carlo\Downloads\am_bot-main\watch_script.py", line 114, in parse_foodsi_api
    current_item['opened_at'] = dateutil.parser.parse(restaurant['package_day']['collection_day']['opened_at']).strftime('%H:%M')
                                                      ~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'package_day'

Thanks @Robertnoob12 to point me out in the trace the api.bug.fender.com/log/batch - there we have the API calls :)

Robertnoob12 commented 1 year ago

Could you get it working and send me the code after so i can replace. I have alot of good things on foodsi @antonioli86 as i mentioned there are other apis like the api.foodsi.pl/user/ etc

antonioli86 commented 1 year ago

Could you get it working and send me the code after so i can replace. I have alot of good things on foodsi @antonioli86 as i mentioned there are other apis like the api.foodsi.pl/user/ etc

I can only check this in the weekend or later... even the request json must be different because as you can see in the answer is coming everything... Warsaw, Gdynia... I think the most difficult was the first point. Now that we have the endpoint, the answer... is try to "play" with that.

The script only with the change of post to get - I added some prints to debug. watch_script.zip

Robertnoob12 commented 1 year ago

We would need to find package days etc. To make it working though. Its not done yet

Robertnoob12 commented 1 year ago

Could you send the watch_script.py file after u will get it done @antonioli86

antonioli86 commented 1 year ago

Could you send the watch_script.py file after u will get it done @antonioli86

Would be better if someone can do it before me or at least some things. :)

Robertnoob12 commented 1 year ago

Could you send the watch_script.py file after u will get it done @antonioli86

Would be better if someone can do it before me or at least some things. :)

Im at school right now. I can help after. What do you need help in?

Robertnoob12 commented 1 year ago

I really want it to be done lol. They sell so rarely on foodsi in my city. I dont want to miss anything. And as i mentioned i have good things on there better than on TGTG

Robertnoob12 commented 1 year ago

Sorry for bothering.

Robertnoob12 commented 1 year ago

I think i told u all important things i found on fiddler files @antonioli86 in the foodsi app. I will help no problem if u need any help

antonioli86 commented 1 year ago

Sorry for bothering.

No problem. Another thing changed is to "browse" the results... because no longer we have "total pages" in the response but we have links:

   "links": {
        "self": "https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=1&page%5Bsize%5D=20",
        "first": "https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=1&page%5Bsize%5D=20",
        "last": "https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=682&page%5Bsize%5D=20",
        "next": "https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=2&page%5Bsize%5D=20"
    },

There are some work to do. First would be nice to found the proper request body in order to filter the results - as you can see it is 682 (!) pages with 20 results each.

Response in previous version:

{'total_pages': 1, 'current_page': 1, 'data': [{'id': 1268582, 'address': 'Henryka Kamieńskiego 11, Kraków', 'address_notes': '', 'distance': '1.2', 'image': {'url': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2805/d53173efeb.jpg'}, 'important_notes': '', 'latitude': '50.02861492917916', 'logo': {'url': 'https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1906/6c94f65f63.jpg'}, 'longitude': '19.95326270135493', 'meal': {'description': '🥗🥘🍝 Restauracja Olimp to miejsce, w którym uratujesz pyszne dania obiadowe, surówki i zupy.  ', 'original_price': '54.0', 'price': '17.99'}, 'name': 'OLIMP BONARKA', 'package_day': {'availability_label': 'OSTATNIA PACZKA', 'availability_label_number': 1, 'isNew': False, 'collection_day': {'id': 1268582, 'week_day': 7, 'schedule_id': 1, 'active': True, 'closed_at': '2000-01-01T17:30:00.000Z', 'opened_at': '2000-01-01T16:00:00.000Z'}, 'meals_left': 1, 'soldOut': None}, 'package_id': 2805, 'package_type': 'paczka niespodzianka'   ...

Now:

{
    "data": [
        {
            "id": "1900767",
            "type": "offers",
            "attributes": {
                "active": true,
                "available_from": "2023-09-20T00:01:01+00:00",
                "available_to": "2023-09-21T21:59:59+00:00",
                "created_at": "2023-09-20T00:01:01+00:00",
                "current_quantity": 0,
                "delivery_time_from_in_days": 2,
                "delivery_time_to_in_days": 2,
                "description": " 🥐🥪🍰 W Cukierni-Piekarni Wenta znajdziecie zarówno pieczywo jak i ciasteczka, ciasta i bułki drożdżowe, szarlotki, serniki, pulchne pączki i wiele innych smakołyków.",
                "name": "duża paczka",
                "original_price": "65.0",
                "package_category_ids": [
                    1
                ],
                "package_created_at": "2022-09-17T22:30:32+00:00",
                "package_delivery_fee": "0.0",
                "package_id": 251,
                "package_image": "https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/251/01dc8bd3bd.jpg",
                "pickup_from": "2023-09-21T14:00:00+00:00",
                "pickup_to": "2023-09-21T14:30:00+00:00",
                "unit_price": "21.59",
                "venue_latitude": 54.5205108162831,
                "venue_logo": "https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/211/f0a3f07822.jpg",
                "venue_longitude": 18.532497886639185,
                "venue_name": "Cukiernia Piekarnia Wenta Dworcowa",
                "venue_pickup_address": "Dworcowa 9, Gdynia",
                "venue_url": "www.cukierniawenta.pl"
            },
            "relationships": {
                "package": {
                    "meta": {
                        "included": false
                    }
                },
                "venue": {
                    "meta": {
                        "included": false
                    }
                }
            }
        },
...
Robertnoob12 commented 1 year ago

Sorry for bothering.

No problem. Another thing changed is to "browse" the results... because no longer we have "total pages" in the response but we have links:

   "links": {
        "self": "https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=1&page%5Bsize%5D=20",
        "first": "https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=1&page%5Bsize%5D=20",
        "last": "https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=682&page%5Bsize%5D=20",
        "next": "https://api.foodsi.pl/api/v3/user/offers?page%5Bnumber%5D=2&page%5Bsize%5D=20"
    },

There are some work to do. First would be nice to found the proper request body in order to filter the results - as you can see it is 682 (!) pages with 20 results each.

It cant check the results while going into the link and show if its available right ? @antonioli86

Robertnoob12 commented 1 year ago

Oh god, i realized we have to use links for specific product ? @antonioli86

Robertnoob12 commented 1 year ago

How will it work if we will need to add more than 1 product like 9 that u wanna follow ? @antonioli86

Robertnoob12 commented 1 year ago

How will it check if a specific product jumps to 1 qty. Instead of 0. In that code u sent i saw theres 0 qty