insanoid/Apple-Store-Reserve-Monitor

Error JSONDecodeError

asyba opened this issue · 6 comments

asyba commented

new error

➜  Downloading Models List...
✔  Found 32 devices matching your config.
➜  Downloading Stock Information for the devices...

4/32 [▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▏                                                                                                                ]Traceback (most recent call last):
  File "store_checker.py", line 243, in <module>
    store_checker.refresh()
  File "store_checker.py", line 83, in refresh
    self.check_stores_for_device(device)
  File "store_checker.py", line 185, in check_stores_for_device
    store_list = product_availability_response.json().get("body").get("stores")
  File "/home/federico/.local/lib/python3.6/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am having the same issue pulling list for pro and promax model.

asyba commented

I am having the same issue pulling list for pro and promax model.

I debug it and its apple website that sometimes throw error on some stores inventory.

asyba commented

I added a try catch to not stop the process and continue with the next search.

Can I see the code?

asyba commented

Can I see the code?

find the function check_stores_for_device and something like this:

    def check_stores_for_device(self, device):
        store_list = {}
        try:
            """Find all stores that have the device requested available (does not matter if it's in stock or not)."""
            #print(self.PRODUCT_AVAILABILITY_URL.format(self.base_url, device.get("model"), self.configuration.zip_code))
        
            product_availability_response = requests.get(
                self.PRODUCT_AVAILABILITY_URL.format(self.base_url, device.get("model"), self.configuration.zip_code)
            )
       
        
            print(product_availability_response)
            store_list = product_availability_response.json().get("body").get("stores")

        except Exception as ee:
            print("ERROR")

operable program or batch file.
1/32 [▉▉▏ ]<Response [200]>
2/32 [▉▉▉▉▎ ]<Response [301]>
ERROR
Traceback (most recent call last):
File "C:\Users\Triggan\AppData\Local\Programs\Python\Python39\lib\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)