snipem / gameprices

PSN and Eshop CLI. Command line tool for searching items and alerting price drops in the Sony Entertainment Network aka Playstation Network and Nintendo Eshop
GNU General Public License v2.0
65 stars 13 forks source link

Switch to new API. Old "chihiro" PSN API is not up to date anymore #13

Open snipem opened 2 years ago

snipem commented 2 years ago

Prices differ between chihiro API, which is used for psnprices, and the new web frontend. For example Tearaway:

image

vs.

> psncli -q "Tearaway" --json | jq . | head -n 15
[
  {
    "id": "EP9000-CUSA00562_00-TEARAWAYUNFOLDED",
    "name": "Tearaway™ Unfolded",
    "type": "FULL_GAME",
    "prices": [
      {
        "price": 100,
        "type": "NORMAL"
      }
    ],
    "platforms": [
      "PS4™"
    ]
  },
...

The API call shows no sign of the 9.99 value. I saw the same for other items. For example "Dreams" valued at 100.

We should switch to the newest PSN Store API.

snipem commented 2 years ago

The PSN api chihiro API seems to be dead for good this time. I created an experimental fix for the new api found in #14.

> psncli -q "ghost of tsushima" --json | jq .
Traceback (most recent call last):
  File "/usr/local/bin/psncli", line 8, in <module>
    sys.exit(psn_main())
  File "/usr/local/lib/python3.9/site-packages/gameprices/cli/cli.py", line 98, in psn_main
    main(Psn("DE/de"))
  File "/usr/local/lib/python3.9/site-packages/gameprices/cli/cli.py", line 73, in main
    print_string = search_for_items_by_name_and_format_output(
  File "/usr/local/lib/python3.9/site-packages/gameprices/cli/cli.py", line 52, in search_for_items_by_name_and_format_output
    items = shop.search(name)
  File "/usr/local/lib/python3.9/site-packages/gameprices/shops/psn.py", line 248, in search
    items = _search_for_items_by_name(name=name, store=self.country)
  File "/usr/local/lib/python3.9/site-packages/gameprices/shops/psn.py", line 171, in _search_for_items_by_name
    data = utils.get_json_response(url)
  File "/usr/local/lib/python3.9/site-packages/gameprices/utils/utils.py", line 17, in get_json_response
    with urllib.request.urlopen(url) as response:
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found