Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Can I get the game box art cover from this api? #28

Closed
darias08 opened this issue Dec 1, 2022 · 11 comments
Closed

Can I get the game box art cover from this api? #28

darias08 opened this issue Dec 1, 2022 · 11 comments
Labels
question Further information is requested

Comments

@darias08
Copy link

darias08 commented Dec 1, 2022

Hi,

I am wondering if this api can pull the box art cover of a game? Like if I want to get this as a cover for a game. Would that be possible or this api can't pull cover images.?

gowSS

@isFakeAccount
Copy link
Owner

isFakeAccount commented Dec 1, 2022

You can, with the help of get_details method. Depending on what psnawp version you are using this may vary a little.

If you use the stable version. You can get all the images using this code

    game_details = psnawp.search().get_title_details(title_id="PPSA08330_00")
    details = game_details[0]
    for image in details['media']['images']:
        img_data = requests.get(image.get('url'))
        filename = f"{image.get('type')}.png" if ".png" in image.get('url') else f"{image.get('type')}.jpg"
        with open(filename, 'wb') as fp:
            fp.write(img_data.content)

I have moved this function from the search class to another class. And in future releases this code will work

    game_title = psnawp.game_title("PPSA08330_00")
    details = game_title.get_details()[0]
    for image in details['media']['images']:
        img_data = requests.get(image.get('url'))
        filename = f"{image.get('type')}.png" if ".png" in image.get('url') else f"{image.get('type')}.jpg"
        with open(filename, 'wb') as fp:
            fp.write(img_data.content)

The work is almost done. I need to write test cases. You can install it directly from pip using

pip install "git+https://github.com/isFakeAccount/psnawp.git@trophy_support"

This will have trophy support but expect a few bugs.

@darias08
Copy link
Author

darias08 commented Dec 1, 2022

Here's the thing about this code or should I say programming language. Because I am actually building a react native app and I am trying to see if it's possible to get the game cover image from a psn api call. I can see translating some of this code to javascript, but I am not sure if it will work.

@darias08
Copy link
Author

darias08 commented Dec 1, 2022

Actually can I pull this api from postman or it's not compatible with it?

@isFakeAccount
Copy link
Owner

isFakeAccount commented Dec 1, 2022

All the endpoints are here https://github.com/isFakeAccount/psnawp/blob/trophy_support/src/psnawp_api/utils/endpoints.py

Looks like the endpoint for getting the details is https://m.np.playstation.com/api/catalog/v2/titles/{title_id}/concepts

You can check this class on how to get access_token/refresh token from npsso code.
https://github.com/isFakeAccount/psnawp/blob/trophy_support/src/psnawp_api/core/authenticator.py

You basically get a URL like https://image.api.playstation.com/vulcan/ap/rnd/202109/2821/SZRc7OMwGgv8lJXIOlYyuBU2.jpg, which you should be able to easily embed or download.

@darias08
Copy link
Author

darias08 commented Dec 1, 2022

Got it! Thank you for these wonderful resources!

I am trying to get a list of titles from my profile account, I am using the examples you have with this as my base url "profile_uri": "https://m.np.playstation.com/api/userProfile/v1/internal/users" and this as my endpoint "profiles": "/{account_id}/profiles".

The issue I am having with this api call is that it doesn't give me a list of game titles for my profile. I have tried using different api call but none of them give my profile game titles.

@darias08
Copy link
Author

darias08 commented Dec 1, 2022

The api call for that one I mention only gave me,
my online id, profile pictures, about me, avatar and that's it.

@darias08
Copy link
Author

darias08 commented Dec 1, 2022

Actually nevermind I found it with using this url:

https://m.np.playstation.com/api/trophy/v1/users/{account_id}/trophyTitles

but the issue I am having with this one is that it gives me trophytitleiconurl but not the game cover. Is there a way I can get the cover art within my profile list of games? Like the one you showed me with this link?
https://image.api.playstation.com/vulcan/ap/rnd/202109/2821/SZRc7OMwGgv8lJXIOlYyuBU2.jpg

PSNAPI

@isFakeAccount
Copy link
Owner

No. You have to use the endpoint I mentioned above to get the cover.

You can use the endpoint for universal search get the title id or vist this website

https://andshrew.github.io/PlayStation-Titles/

@darias08
Copy link
Author

darias08 commented Dec 1, 2022

How does universal search work? I tried placing the https://m.np.playstation.com/api/search/v1/universalSearch and then the search endpoint ({title_id}/concepts), but I get this message saying no permission.

ss3

@isFakeAccount
Copy link
Owner

@darias08 My guess is that something is wrong with your authentication process. Have you looked at how I do authentication?

@isFakeAccount
Copy link
Owner

Ok I think I know what's the issue. The {title_id}/concepts is not part of search endpoint.

You need to pass the query params as part of payload. Check the search.py file in master branch and it will make sense.

@isFakeAccount isFakeAccount added the question Further information is requested label Dec 4, 2022
Repository owner locked and limited conversation to collaborators Dec 14, 2022
@isFakeAccount isFakeAccount converted this issue into discussion #32 Dec 14, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants