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

PSNAWPNotFound from a TrophyIterator on PS5 games #72

Closed
Frygidairus opened this issue Jun 17, 2024 · 6 comments
Closed

PSNAWPNotFound from a TrophyIterator on PS5 games #72

Frygidairus opened this issue Jun 17, 2024 · 6 comments

Comments

@Frygidairus
Copy link

Frygidairus commented Jun 17, 2024

Hello, I am currently trying to use PSNAWP 2.0.0 to retrieve my trophies from the last title I played.

Unfortunately, I am no able to get the trophies for PS5 titles. The TrophyIterator returned by the method User.trophies() greets me with an error 404 as soon as I try to iterate over it. This error could be raised in the case I have no trophy for this title, yet I have quite a few of those...
For PS4 games, I am able to iterate without any issue.

Here is a code sample to illustrate what I mean:

from psnawp_api import PSNAWP

client = PSNAWP(NPSSO)

user = client.user(online_id="Frygidairus")

#Trophies from Burnout Paradise
trophies = user.trophies(
    'NPWR14842_00',
    'PS4'
)
print(next(trophies))

#Trophies from Diablo IV
trophies = user.trophies(
    'NPWR22810_00',
    'PS5'
)
print(next(trophies))

Here is the result when running the script:

Trophy(trophy_set_version='01.00', has_trophy_groups=True, trophy_id=0, trophy_hidden=False, trophy_type=<TrophyType.PLATINUM: 'platinum'>, trophy_name='Burnout Paradise Elite', trophy_detail='Awarded for successfully collecting all trophies from Burnout Paradise', trophy_icon_url='https://image.api.playstation.com/trophy/np/NPWR14842_00_007326ECF7B78940E23D1587323910E816F1620087/3974A04727EA169D039B773C21E5DD24D907218C.PNG', trophy_group_id='default', trophy_progress_target_value=None, trophy_reward_name=None, trophy_reward_img_url=None)

Traceback (most recent call last):
  File "/Users/gde/greeter/testest.py", line 21, in <module>
    print(next(trophies))

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/models/listing/pagination_iterator.py", line 45, in __next__
    return self.__iterator.__next__()

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/models/trophies/trophy.py", line 157, in fetch_next_page
    response = self.authenticator.get(url=self._url, params=params).json()

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/authenticator.py", line 34, in _impl
    method_out = method(*method_args, **method_kwargs)

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/authenticator.py", line 283, in get
    return self.request_builder.get(**kwargs)

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/request_builder.py", line 143, in get
    return self.request(method="get", **kwargs)

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/request_builder.py", line 122, in request
    response_checker(response)

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/request_builder.py", line 47, in response_checker
    raise PSNAWPNotFound(response.text)

psnawp_api.core.psnawp_exceptions.PSNAWPNotFound: {"error":{"referenceId":"5e2a3823-2ce6-11ef-80fc-adb49a3fbf8c","code":2240525,"message":"Resource not found"}}

As you can see, the TrophyIterator for the PS4 game return the first trophy of the list, but the PS5 TrophyIterator raises an error.

I have a hard time understanding why since I had no issue with the previous version of PSNAWP. I am trying to pin point what is happening, I will keep you updated if I find something!

@Frygidairus
Copy link
Author

Note that I tested this on several PS5 and PS4 games, with similar results

@Frygidairus
Copy link
Author

I was able to query the endpoints directly thanks to my bearer token, resulting in 200 HTTP status codes. Both the trophy set and the progress set were retrieved thanks to the Postman queries as per the screenshots.
I have yet to understand what goes wrong...
image
image

@isFakeAccount
Copy link
Owner

isFakeAccount commented Jun 17, 2024

@Frygidairus

Can you try with the latest version of PSNAWP because it works for me.

image

Also, assuming if you are looking up your own trophies you can use the client class

from psnawp_api import PSNAWP
from psnawp_api.models.trophies import PlatformType

client = psn.me()
trophies = client.trophies("NPWR22810_00", PlatformType.PS5)
print(next(trophies))

This will save you some extra HTTP requests.

@isFakeAccount
Copy link
Owner

I think I might know the issue. I switch platform type from string to Enum and passing in enum threw off the API wrapper.

default case is for PS4 so which it is why it worked. but PS5 didn't

@isFakeAccount
Copy link
Owner

image

Yup, I get the same error when string is passed.

@Frygidairus
Copy link
Author

I just tested it too, and indeed, getting rid of the string fixed it!
Thank you so much :)

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

2 participants