Giter Club home page Giter Club logo

Comments (11)

isFakeAccount avatar isFakeAccount commented on August 23, 2024

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.

from psnawp.

darias08 avatar darias08 commented on August 23, 2024

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.

from psnawp.

darias08 avatar darias08 commented on August 23, 2024

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

from psnawp.

isFakeAccount avatar isFakeAccount commented on August 23, 2024

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.

from psnawp.

darias08 avatar darias08 commented on August 23, 2024

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.

from psnawp.

darias08 avatar darias08 commented on August 23, 2024

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

from psnawp.

darias08 avatar darias08 commented on August 23, 2024

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

from psnawp.

isFakeAccount avatar isFakeAccount commented on August 23, 2024

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/

from psnawp.

darias08 avatar darias08 commented on August 23, 2024

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

from psnawp.

isFakeAccount avatar isFakeAccount commented on August 23, 2024

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

from psnawp.

isFakeAccount avatar isFakeAccount commented on August 23, 2024

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.

from psnawp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.