isFakeAccount / psnawp

PlayStation Network API Python
https://pypi.org/project/PSNAWP/
Other
96 stars 21 forks source link

Searching PS3 and PSVita Video Games using Universal Search endpoint. #52

Open isFakeAccount opened 10 months ago

isFakeAccount commented 10 months ago

Originally posted by @glebmiller in https://github.com/isFakeAccount/psnawp/discussions/44

PlayStation API universal search endpoint does not return any PS3 or PSVITA games. This happens even on the app itself. Due to this the trophy_titles_for_title method cannot be used since we don't have title ids.

Note: If you get all of the trophy titles using the client.trophy_titles(limit=100) method, then it will include the PS3 and PSVITA trophies.

platinumachievements commented 1 week ago

Hey, is this still a thing that we can’t access ps3 and Vita trophies? I think this is the only thing holding me back jumping fully into this api.

isFakeAccount commented 1 week ago

Hey, is this still a thing that we can’t access ps3 and Vita trophies? I think this is the only thing holding me back jumping fully into this api.

@platinumachievements What is your gamertag and can you see ps3 and ps vita trophies on PlayStation Android/iOS app?

If you can see your trophies on Android/iOS app then I can add it to api.

platinumachievements commented 1 week ago

@isFakeAccount Thanks for the quick reply, yes I can see the ps3 trophies for my games on the IOS app. I dont have any Vita trophies so I can’t check that. so they must be able to be gotten, I would need to get other peoples ps3 trophies not just Mine. I can also see friends ps3 trophies via the app as well

isFakeAccount commented 1 week ago

@isFakeAccount Thanks for the quick reply, yes I can see the ps3 trophies for my games on the IOS app. I dont have any Vita trophies so I can’t check that. so they must be able to be gotten, I would need to get other peoples ps3 trophies not just Mine. I can also see friends ps3 trophies via the app as well

@platinumachievements If your friends have ps vita then it would help a lot. Also, can you add me as friend.

Gamertag: VaultTec-Co

platinumachievements commented 1 week ago

@isFakeAccount added, I’ll see if I can find anyone with vita/psp. Just scroll to the bottom of my list for ps3 games.

platinumachievements commented 1 week ago

@isFakeAccount i can see friends Vita games as well, they are under PSVITA.

isFakeAccount commented 1 week ago

@platinumachievements You can use this code example to get all your PS3/PSVITA Trophies, Trophy titles, groups, etc...

from os import getenv

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

load_dotenv()

def main() -> None:
    psn = PSNAWP(getenv("NPSSO_CODE", "NPSSO_CODE"))
    client = psn.me()

    print("Trophy Titles")
    trophy_titles = client.trophy_titles(limit=100)
    for trophy_title in trophy_titles:
        if PlatformType.PS3 in trophy_title.title_platform:
            print(trophy_title.title_name, trophy_title.title_platform, trophy_title.earned_trophies, trophy_title.np_communication_id)

    print("\nTrophies")
    for trophy in client.trophies("NPWR05167_00", PlatformType.PS3, limit=10):
        print(trophy.trophy_name)

    print("\nTrophy Group Summary")
    the_lego_movie_tgs = client.trophy_groups_summary("NPWR05167_00", platform=PlatformType.PS3, include_progress=True)
    print(the_lego_movie_tgs)

if __name__ == "__main__":
    main()

The main issue is that you cannot search for PlayStation games using Search class. Since you can't find title ids using search function, you can't use client.trophy_titles_for_title because it requires title ids.

But remaining methods and endpoints work fine.

platinumachievements commented 1 week ago

Thanks! I think I understand the limitations now, you can retrieve them, but can’t individual search for them as you can’t retrieve the title ID.

isFakeAccount commented 1 week ago

Thanks! I think I understand the limitations now, you can retrieve them, but can’t individual search for them as you can’t retrieve the title ID.

Yeah pretty much. You have to fetch all and manually filter on client end trophy_titles. Once you have the np_communication_id then you don't need the title_ids anyways. @platinumachievements

I'd recommend saving np_communication_id with title_name in a file or database.