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

Foodsi - new error #31

Open
antonioli86 opened this issue Sep 20, 2023 · 251 comments
Open

Foodsi - new error #31

antonioli86 opened this issue Sep 20, 2023 · 251 comments

Comments

@antonioli86
Copy link

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
Copy link
Author

antonioli86 commented Sep 20, 2023

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
Copy link

yeah. new update...

@Robertnoob12
Copy link

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

@antonioli86
Copy link
Author

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

@Robertnoob12
Copy link

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

@antonioli86
Copy link
Author

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

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

@Robertnoob12
Copy link

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

@Robertnoob12
Copy link

@antonioli86 how is the file named for the api

@antonioli86
Copy link
Author

@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
Copy link

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
Copy link

because here i cant send .apk

@Robertnoob12
Copy link

the zip has too much MB'S @antonioli86

@antonioli86
Copy link
Author

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

@Robertnoob12
Copy link

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

@antonioli86
Copy link
Author

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

I took the 2.10.

@Robertnoob12
Copy link

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

@Robertnoob12
Copy link

look around

@Robertnoob12
Copy link

have u found anything? @antonioli86

@antonioli86
Copy link
Author

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

@Robertnoob12
Copy link

ok

@Robertnoob12
Copy link

ugh... i cant find it

@Robertnoob12
Copy link

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
Copy link

@antonioli86

@antonioli86
Copy link
Author

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
Copy link

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

@Robertnoob12
Copy link

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

@antonioli86 antonioli86 changed the title Foodi - new error Foodsi - new error Sep 20, 2023
@antonioli86
Copy link
Author

antonioli86 commented Sep 20, 2023

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
Copy link

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

@Robertnoob12
Copy link

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

@Robertnoob12
Copy link

@antonioli86 TOO MUCH image

At least now is working properly. 💯 For favorites maybe in the future but for now I will not work on that. Do you have such big range/area? For example in Kraków with range of 15 km from my place I have like 10-20 max normally.

@antonioli86 would be better if u add a version for favorites too lol, i dont know how to do it. its for others that live in a bigger cities that have more than 100 foodsi items available, and are only looking for few of these.

Will be perfect if from API response the items include attribute "favorite" and then will be easy to filter. Problem is - as I wrote before - favorites is a different API endpoint and response is a bit different.

not that perfect.
sometimes:
Foodsi total items: 95
Traceback (most recent call last):
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\anyio_core_tasks.py", line 115, in fail_after
yield cancel_scope
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore_synchronization.py", line 125, in wait
await self._anyio_event.wait()
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\anyio_backends_asyncio.py", line 1621, in wait
await self._event.wait()
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\asyncio\locks.py", line 213, in wait
await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 22862808c90

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore_exceptions.py", line 10, in map_exceptions
yield
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore_synchronization.py", line 124, in wait
with anyio.fail_after(timeout):
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\anyio_core_tasks.py", line 118, in fail_after
raise TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_transports\default.py", line 60, in map_httpcore_exceptions
yield
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_transports\default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore_async\connection_pool.py", line 242, in handle_async_request
raise exc
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore_async\connection_pool.py", line 233, in handle_async_request
connection = await status.wait_for_connection(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore_async\connection_pool.py", line 35, in wait_for_connection
await self._connection_acquired.wait(timeout=timeout)
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore_synchronization.py", line 123, in wait
with map_exceptions(anyio_exc_map):
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpcore_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.PoolTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram\request_httpxrequest.py", line 219, in do_request
res = await self._client.request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_client.py", line 1530, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_client.py", line 1617, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_transports\default.py", line 352, in handle_async_request
with map_httpcore_exceptions():
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx_transports\default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.PoolTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\rober\OneDrive\Pulpit\am_bot-main\watch_script.py", line 290, in refresh
asyncio.run(foodsi())
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\rober\OneDrive\Pulpit\am_bot-main\watch_script.py", line 266, in foodsi
await asyncio.gather(*tasks)
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram_bot.py", line 394, in decorator
result = await func(self, *args, **kwargs) # skipcq: PYL-E1102
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram_bot.py", line 1055, in send_photo
return await self._send_message(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram_bot.py", line 572, in _send_message
result = await self._post(
^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram_bot.py", line 482, in _post
return await self._do_post(
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram_bot.py", line 510, in _do_post
return await request.post(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram\request_baserequest.py", line 168, in post
result = await self._request_wrapper(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram\request_baserequest.py", line 288, in _request_wrapper
raise exc
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram\request_baserequest.py", line 278, in _request_wrapper
code, payload = await self.do_request(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram\request_httpxrequest.py", line 229, in do_request
raise TimedOut(
telegram.error.TimedOut: Pool timeout: All connections in the connection pool are occupied. Request was not sent to Telegram. Consider adjusting the connection pool size or the pool timeout.

@Robertnoob12
Copy link

@antonioli86 make limit 100 foodsi total items, if it goes above that it doesnt get sent because it went over the flood limit

@Robertnoob12
Copy link

it seems to be fine , the servers were dead at the moment

@Robertnoob12
Copy link

@antonioli86 TOO MUCH image

At least now is working properly. 💯 For favorites maybe in the future but for now I will not work on that. Do you have such big range/area? For example in Kraków with range of 15 km from my place I have like 10-20 max normally.

@antonioli86 would be better if u add a version for favorites too lol, i dont know how to do it. its for others that live in a bigger cities that have more than 100 foodsi items available, and are only looking for few of these.

Will be perfect if from API response the items include attribute "favorite" and then will be easy to filter. Problem is - as I wrote before - favorites is a different API endpoint and response is a bit different.

  1. nope , i was testing on Warsaw .
  2. its fine i guess.

@antonioli86
Copy link
Author

it seems to be fine , the servers were dead at the moment

For the httpcore.PoolTimeout error, increase the pool timeout in the code - line 101. Its pool_timeout=20, change to 40 or 50 for example. Another workaround is to build an bot application and increase the connection pool size - https://docs.python-telegram-bot.org/en/v20.5/telegram.ext.applicationbuilder.html.

Such errors will appear but application still running.

@Robertnoob12
Copy link

it seems to be fine , the servers were dead at the moment

For the httpcore.PoolTimeout error, increase the pool timeout in the code - line 101. Its pool_timeout=20, change to 40 or 50 for example. Another workaround is to build an bot application and increase the connection pool size - https://docs.python-telegram-bot.org/en/v20.5/telegram.ext.applicationbuilder.html.

Such errors will appear but application still running.

Have u got this ?
(most recent call last):
File "C:\Users\rober\OneDrive\Pulpit\am_bot-main\watch_script.py", line 290, in refresh
asyncio.run(foodsi())
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rober\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\rober\OneDrive\Pulpit\am_bot-main\watch_script.py", line 182, in foodsi
foodsi_api = requests.get('https://api.foodsi.pl/api/v3/user/offers?filter[package_category_ids][not_eq]=[13]&filter[package_category_ids][eq]=[9,1]&filter[active][eq]=true&filter[current_quantity][gt]=0&filter[pickup_to][gt]='+timestamp_string+'&page[size]=15&sort=distance,pickup_from', headers = {'Content-type':'application/json', 'system-version':'android_3.0.0', 'user-agent':'okhttp/3.12.0', 'Access-Token': access_token, 'Client': client, 'Uid': uid})
^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'access_token' where it is not associated with a value

Seems to be running now but interesting

@antonioli86
Copy link
Author

When access_token is empty (not associated with a value) is when authentication fails. I saw it during testing but not recently (when running normally).

Strange because if it fails should raise error:

            if response.status_code == 200:
                access_token = str(response.headers['Access-Token'])
                client = str(response.headers['Client'])
                uid = str(response.headers['Uid'])
    except Exception as e:
	    telegram_bot_sendtext(str(e))
	    exit(1)

No message in telegram about that? When Exception it sends error to Telegram bot.

@Robertnoob12
Copy link

When access_token is empty (not associated with a value) is when authentication fails. I saw it during testing but not recently (when running normally).

Strange because if it fails should raise error:

            if response.status_code == 200:
                access_token = str(response.headers['Access-Token'])
                client = str(response.headers['Client'])
                uid = str(response.headers['Uid'])
    except Exception as e:
	    telegram_bot_sendtext(str(e))
	    exit(1)

No message in telegram about that? When Exception it sends error to Telegram bot.

Thats the thing , it printed i gave u the text

@antonioli86
Copy link
Author

But still running? Maybe some issue during authentication... hard to debug at this stage.
Only error I have is time to time in the morning with picture - sometimes foodsi API sends invalid URL to some offer and telegram complains about that. And some timeouts - like one error each 2-3 hours.

@Robertnoob12
Copy link

But still running? Maybe some issue during authentication... hard to debug at this stage. Only error I have is time to time in the morning with picture - sometimes foodsi API sends invalid URL to some offer and telegram complains about that. And some timeouts - like one error each 2-3 hours.

still running, but i dont know if its actually working, none product showed yet

@Robertnoob12
Copy link

you probably remember when i said:

  • its very rare if something goes on sale

@antonioli86
Copy link
Author

@Robertnoob12 if you see like
imagem

Thats ok. Timeout errors will happen.

@antonioli86
Copy link
Author

But still running? Maybe some issue during authentication... hard to debug at this stage. Only error I have is time to time in the morning with picture - sometimes foodsi API sends invalid URL to some offer and telegram complains about that. And some timeouts - like one error each 2-3 hours.

still running, but i dont know if its actually working, none product showed yet

Its working. ;) Check in telegram or in the run output if you did not missed something. ;)
Another thing - I have the filter in the query - &filter[package_category_ids][eq]=[9,1]

This is only for meals and pastry/bakery. You can always remove this part and have like:
foodsi_api = requests.get('https://api.foodsi.pl/api/v3/user/offers?filter[package_category_ids][not_eq]=[13]&filter[active][eq]=true&filter[current_quantity][gt]=0&filter[pickup_to][gt]='+timestamp_string+'&page[size]=15&sort=distance,pickup_from', headers = {'Content-type':'application/json', 'system-version':'android_3.0.0', 'user-agent':'okhttp/3.12.0', 'Access-Token': access_token, 'Client': client, 'Uid': uid})

@Robertnoob12
Copy link

But still running? Maybe some issue during authentication... hard to debug at this stage. Only error I have is time to time in the morning with picture - sometimes foodsi API sends invalid URL to some offer and telegram complains about that. And some timeouts - like one error each 2-3 hours.

still running, but i dont know if its actually working, none product showed yet

Its working. ;) Check in telegram or in the run output if you did not missed something. ;)
Another thing - I have the filter in the query - &filter[package_category_ids][eq]=[9,1]

This is only for meals and pastry/bakery. You can always remove this part and have like:
foodsi_api = requests.get('https://api.foodsi.pl/api/v3/user/offers?filter[package_category_ids][not_eq]=[13]&filter[active][eq]=true&filter[current_quantity][gt]=0&filter[pickup_to][gt]='+timestamp_string+'&page[size]=15&sort=distance,pickup_from', headers = {'Content-type':'application/json', 'system-version':'android_3.0.0', 'user-agent':'okhttp/3.12.0', 'Access-Token': access_token, 'Client': client, 'Uid': uid})

Its ok, bread and pastries & meals shows all stuff for me

@kiskowski
Copy link

Hi guys, do you find if it is possible in this API a OR statement? Or a lists of idS?

@antonioli86
Copy link
Author

antonioli86 commented Oct 2, 2023

Hi guys, do you find if it is possible in this API a OR statement? Or a lists of idS?

Is a question to test... depends on the implementation on their side.
https://stackoverflow.com/questions/495426/restful-url-design-how-to-query-using-or-between-parameters
About ids: which ids? from the restaurants? offers?

@antonioli86
Copy link
Author

By restaurants: filter by venue_name:
&filter[venue_name][eq]=["Premium Kebab","Kawiarnia the White Bear Coffee Kraków"]

Filter by ids - tried by package id or the offer id in the URL but no success. :(

@M0NSER
Copy link

M0NSER commented Oct 4, 2023

If You would like to filter by location You can add filters like
&filter[venue_longitude][gt]=20.123&&filter[venue_longitude][lt]=30.456filter[venue_latitude][gt]=50.123&&filter[venue_latitude][lt]=60.456

These numbers are the coordinates of our city. Eg Warsaw is like 52°14'18.9"N 21°00'15.8"E just find it in google maps

@antonioli86
Copy link
Author

If You would like to filter by location You can add filters like &filter[venue_longitude][gt]=20.123&&filter[venue_longitude][lt]=30.456filter[venue_latitude][gt]=50.123&&filter[venue_latitude][lt]=60.456

These numbers are the coordinates of our city. Eg Warsaw is like 52°14'18.9"N 21°00'15.8"E just find it in google maps

@M0NSER Does not work like that now. Coordinates and range are taken from your user profile - user used in the authentication. You need to open the app and select the area and then define the range.

@M0NSER
Copy link

M0NSER commented Oct 4, 2023

If You would like to filter by location You can add filters like &filter[venue_longitude][gt]=20.123&&filter[venue_longitude][lt]=30.456filter[venue_latitude][gt]=50.123&&filter[venue_latitude][lt]=60.456
These numbers are the coordinates of our city. Eg Warsaw is like 52°14'18.9"N 21°00'15.8"E just find it in google maps

@M0NSER Does not work like that now. Coordinates and range are taken from your user profile - user used in the authentication. You need to open the app and select the area and then define the range.

So explain to me, how does it work for eg Poznań
https://api.foodsi.pl/api/v3/user/offers?page[size]=3&filter[active][eq]=true&filter[venue_longitude][gt]=16.8080&&filter[venue_longitude][lt]=17.1345&filter[venue_latitude][gt]=52.3311&&filter[venue_latitude][lt]=52.4601

and for Warsaw
https://api.foodsi.pl/api/v3/user/offers?page[size]=2&filter[active][eq]=true&filter[venue_longitude][gt]=20.8506&&filter[venue_longitude][lt]=21.2710&filter[venue_latitude][gt]=52.0907&&filter[venue_latitude][lt]=52.3676

@antonioli86
Copy link
Author

If You would like to filter by location You can add filters like &filter[venue_longitude][gt]=20.123&&filter[venue_longitude][lt]=30.456filter[venue_latitude][gt]=50.123&&filter[venue_latitude][lt]=60.456
These numbers are the coordinates of our city. Eg Warsaw is like 52°14'18.9"N 21°00'15.8"E just find it in google maps

@M0NSER Does not work like that now. Coordinates and range are taken from your user profile - user used in the authentication. You need to open the app and select the area and then define the range.

So explain to me, how does it work for eg Poznań https://api.foodsi.pl/api/v3/user/offers?page[size]=3&filter[active][eq]=true&filter[venue_longitude][gt]=16.8080&&filter[venue_longitude][lt]=17.1345&filter[venue_latitude][gt]=52.3311&&filter[venue_latitude][lt]=52.4601

and for Warsaw https://api.foodsi.pl/api/v3/user/offers?page[size]=2&filter[active][eq]=true&filter[venue_longitude][gt]=20.8506&&filter[venue_longitude][lt]=21.2710&filter[venue_latitude][gt]=52.0907&&filter[venue_latitude][lt]=52.3676

Maybe works using such filters but for example I dont use these filters and works based on my user profile - the location position that I set and the range.

@NickXDD
Copy link

NickXDD commented Oct 11, 2023

Hi, I edited config file to be as per @Robertnoob12 screenshot and downloaded @antonioli86 's latest script. However I get such error:

[opc@instance am_bot]$ python3 watch_script_new.py
Unexpected error
Traceback (most recent call last):
File "watch_script_new.py", line 27, in
config = load(f)
File "/usr/lib64/python3.6/json/init.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib64/python3.6/json/init.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python3.6/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ':' delimiter: line 12 column 11 (char 252)

My python version is 3.6.8. I've editted 18 line "from zoneinfo import ZoneInfo" to "from backports.zoneinfo import ZoneInfo".
If I would have to update python to higher version, I would prefer to somehow make it work on my current version, beacuse instead I would have to update my oracle linux 7.9 to 8.4 or later to install python 3.9

@antonioli86
Copy link
Author

antonioli86 commented Oct 11, 2023

config = load(f)

Error is here, when trying to load. Something wrong in config.json

{ "telegram": { "bot_token": "6238650623:AA_____________zNNqZ554ukbc", "bot_chatID": -679440000 }, "location": { "lat": 51.058838, "long": 18.6600552, "range": 15 }, "auth": { "email": "zzzzzzz2@zzzz.pl", "password": "terefere" } }

"json.decoder.JSONDecodeError: Expecting ':' delimiter: line 12 column 11 (char 252)"
Check line 12 in config.json

@Robertnoob12
Copy link

Hi, I edited config file to be as per @Robertnoob12 screenshot and downloaded @antonioli86 's latest script. However I get such error:

[opc@instance am_bot]$ python3 watch_script_new.py Unexpected error Traceback (most recent call last): File "watch_script_new.py", line 27, in config = load(f) File "/usr/lib64/python3.6/json/init.py", line 299, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "/usr/lib64/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python3.6/json/decoder.py", line 355, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Expecting ':' delimiter: line 12 column 11 (char 252)

My python version is 3.6.8. I've editted 18 line "from zoneinfo import ZoneInfo" to "from backports.zoneinfo import ZoneInfo". If I would have to update python to higher version, I would prefer to somehow make it work on my current version, beacuse instead I would have to update my oracle linux 7.9 to 8.4 or later to install python 3.9

{
"telegram": {
"bot_token": "x",
"bot_chatID": x
},
"location": {
"lat": xxx,
"long": xxx,
"range": 10
},
"auth": {
"email": "xxxxxx",
"password": "xxx"
}
}

@NickXDD
Copy link

NickXDD commented Oct 11, 2023

Thank you. Yup, my stupid typo:)
So does filtering by favourites work? And what should I edit to receive messages without the photo?

@antonioli86
Copy link
Author

Thank you. Yup, my stupid typo:) So does filtering by favourites work? And what should I edit to receive messages without the photo?

Favorites is a different story - is a different API endpoint (I wrote before) and parsing of message is slightly different.
About the messages without photo - in the line:
tasks.append(asyncio.create_task(bot.send_photo(chat_id=bot_chatID, photo=im, caption=message, parse_mode='Markdown', read_timeout=20, write_timeout=20, connect_timeout=20, pool_timeout=20)))

replace send_photo by send_message and change a bit the parameters:
tasks.append(asyncio.create_task(bot.send_message(chat_id=bot_chatID, text=message, parse_mode='Markdown', read_timeout=20, write_timeout=20, connect_timeout=20, pool_timeout=20)))

https://docs.python-telegram-bot.org/en/v20.6/telegram.chat.html#telegram.Chat.send_message

@Robertnoob12
Copy link

@antonioli86
can u help im trying to run with replit but doesnt seem to work
image

@Robertnoob12
Copy link

i got it working

@wonsky007
Copy link

Hi guys

How do you handle a situation where the API returns two packages (for today and tomorrow) for a given object? The bot automatically sends two messages, but in the application, you can only purchase today's packages. Only when today's packages are unavailable can you proceed with purchasing tomorrow's.

Example below:

{
       "id": "2304086",
        "type": "offers",
        "attributes": {
            "active": true,
            "available_from": "2023-11-15T01:01:04+00:00",
            "available_to": "2023-11-16T22:59:59+00:00",
            "created_at": "2023-11-15T01:01:04+00:00",
            "current_quantity": 2,
            "delivery_time_from_in_days": 2,
            "delivery_time_to_in_days": 2,
            "description": "🥖🍞🥐 W Piekarni Oskroba uratujesz croissanty, bagietki, czy kanapki. Wszystko przygotowane według tradycyjnych receptur i przy użyciu wyłącznie naturalnych składników.  ",
            "name": "paczka niespodzianka",
            "original_price": "30.0",
            "package_category_ids": [
                1
            ],
            "package_created_at": "2022-09-17T22:31:46+00:00",
            "package_delivery_fee": "0.0",
            "package_id": 2722,
            "package_image": "https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2722/6d14968066.jpeg",
            "pickup_from": "2023-11-16T17:45:00+00:00",
            "pickup_to": "2023-11-16T18:00:00+00:00",
            "unit_price": "14.99",
            "venue_latitude": 52.24556975,
            "venue_logo": "https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1857/269448d66a.jpg",
            "venue_longitude": 20.898583970056386,
            "venue_name": "Oskroba Łokuciewskiego",
            "venue_pickup_address": "Łokuciewskiego 2, Warszawa",
            "venue_url": "facebook.com/OskrobaPiekarnia"
        },
        "relationships": {
            "package": {
                "meta": {
                    "included": false
                }
            },
            "venue": {
                "meta": {
                    "included": false
                }
            }
        }
    },
    {
        "id": "2311809",
        "type": "offers",
        "attributes": {
            "active": true,
            "available_from": "2023-11-16T01:01:04+00:00",
            "available_to": "2023-11-17T22:59:59+00:00",
            "created_at": "2023-11-16T01:01:04+00:00",
            "current_quantity": 6,
            "delivery_time_from_in_days": 2,
            "delivery_time_to_in_days": 2,
            "description": "🥖🍞🥐 W Piekarni Oskroba uratujesz croissanty, bagietki, czy kanapki. Wszystko przygotowane według tradycyjnych receptur i przy użyciu wyłącznie naturalnych składników.  ",
            "name": "paczka niespodzianka",
            "original_price": "30.0",
            "package_category_ids": [
                1
            ],
            "package_created_at": "2022-09-17T22:31:46+00:00",
            "package_delivery_fee": "0.0",
            "package_id": 2722,
            "package_image": "https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2722/6d14968066.jpeg",
            "pickup_from": "2023-11-17T17:45:00+00:00",
            "pickup_to": "2023-11-17T18:00:00+00:00",
            "unit_price": "14.99",
            "venue_latitude": 52.24556975,
            "venue_logo": "https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1857/269448d66a.jpg",
            "venue_longitude": 20.898583970056386,
            "venue_name": "Oskroba Łokuciewskiego",
            "venue_pickup_address": "Łokuciewskiego 2, Warszawa",
            "venue_url": "facebook.com/OskrobaPiekarnia"
        },
        "relationships": {
            "package": {
                "meta": {
                    "included": false
                }
            },
            "venue": {
                "meta": {
                    "included": false
                }
            }
        }
    },

@antonioli86
Copy link
Author

antonioli86 commented Nov 16, 2023

Hi guys

How do you handle a situation where the API returns two packages (for today and tomorrow) for a given object? The bot automatically sends two messages, but in the application, you can only purchase today's packages. Only when today's packages are unavailable can you proceed with purchasing tomorrow's.

Example below:

{
       "id": "2304086",
        "type": "offers",
        "attributes": {
            "active": true,
            "available_from": "2023-11-15T01:01:04+00:00",
            "available_to": "2023-11-16T22:59:59+00:00",
            "created_at": "2023-11-15T01:01:04+00:00",
            "current_quantity": 2,
            "delivery_time_from_in_days": 2,
            "delivery_time_to_in_days": 2,
            "description": "🥖🍞🥐 W Piekarni Oskroba uratujesz croissanty, bagietki, czy kanapki. Wszystko przygotowane według tradycyjnych receptur i przy użyciu wyłącznie naturalnych składników.  ",
            "name": "paczka niespodzianka",
            "original_price": "30.0",
            "package_category_ids": [
                1
            ],
            "package_created_at": "2022-09-17T22:31:46+00:00",
            "package_delivery_fee": "0.0",
            "package_id": 2722,
            "package_image": "https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2722/6d14968066.jpeg",
            "pickup_from": "2023-11-16T17:45:00+00:00",
            "pickup_to": "2023-11-16T18:00:00+00:00",
            "unit_price": "14.99",
            "venue_latitude": 52.24556975,
            "venue_logo": "https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1857/269448d66a.jpg",
            "venue_longitude": 20.898583970056386,
            "venue_name": "Oskroba Łokuciewskiego",
            "venue_pickup_address": "Łokuciewskiego 2, Warszawa",
            "venue_url": "facebook.com/OskrobaPiekarnia"
        },
        "relationships": {
            "package": {
                "meta": {
                    "included": false
                }
            },
            "venue": {
                "meta": {
                    "included": false
                }
            }
        }
    },
    {
        "id": "2311809",
        "type": "offers",
        "attributes": {
            "active": true,
            "available_from": "2023-11-16T01:01:04+00:00",
            "available_to": "2023-11-17T22:59:59+00:00",
            "created_at": "2023-11-16T01:01:04+00:00",
            "current_quantity": 6,
            "delivery_time_from_in_days": 2,
            "delivery_time_to_in_days": 2,
            "description": "🥖🍞🥐 W Piekarni Oskroba uratujesz croissanty, bagietki, czy kanapki. Wszystko przygotowane według tradycyjnych receptur i przy użyciu wyłącznie naturalnych składników.  ",
            "name": "paczka niespodzianka",
            "original_price": "30.0",
            "package_category_ids": [
                1
            ],
            "package_created_at": "2022-09-17T22:31:46+00:00",
            "package_delivery_fee": "0.0",
            "package_id": 2722,
            "package_image": "https://foodsi-backend-production.s3.amazonaws.com/uploads/package/image/2722/6d14968066.jpeg",
            "pickup_from": "2023-11-17T17:45:00+00:00",
            "pickup_to": "2023-11-17T18:00:00+00:00",
            "unit_price": "14.99",
            "venue_latitude": 52.24556975,
            "venue_logo": "https://foodsi-backend-production.s3.amazonaws.com/uploads/venue/logo/1857/269448d66a.jpg",
            "venue_longitude": 20.898583970056386,
            "venue_name": "Oskroba Łokuciewskiego",
            "venue_pickup_address": "Łokuciewskiego 2, Warszawa",
            "venue_url": "facebook.com/OskrobaPiekarnia"
        },
        "relationships": {
            "package": {
                "meta": {
                    "included": false
                }
            },
            "venue": {
                "meta": {
                    "included": false
                }
            }
        }
    },

@wonsky007 to be honest I noted that but did not spent time to think about that.
Is quite annoying - I know - but to be honest should be something to be done in Foodsi side- why both offers are in active state?
A way to filter out I think can be to group by venue and return first one only.

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

No branches or pull requests

8 participants