PSN API in 2.2.1
See original GitHub issueI’ve just seen the update for the SuccesStory, but it doesn’t solve the problem for me - there’s still no trophies.
There are two kinds of IDs in the PSN APIs - titleId
(usually CUSAxxxxx_xx) and communicationId
(usually NPWRxxxxxx_xx).
All PS4 and PS5 games use titleId
as Playnite’s GameId, as it’s the most universal one.
Only PS3/PSP/PSVITA games use communicationId
as GameId directly, as those don’t have their titleId
exposed.
private const string UrlAchievementsDetails = @"https://m.np.playstation.net/api/trophy/v1/npCommunicationIds/{0}/trophyGroups/all/trophies";
private const string UrlAchievements = @"https://m.np.playstation.net/api/trophy/v1/users/me/npCommunicationIds/{0}/trophyGroups/all/trophies";
(...)
Url = string.Format(UrlAchievements, GameId) + "?npServiceName=trophy"; // all without ps5
UrlDetails = string.Format(UrlAchievementsDetails, GameId) + "?npServiceName=trophy"; // all without ps5
From your code, it seems that you are using the GameId directly for all games, which won’t work for PS4 and PS5 games in the db. To get communicationId
needed to retrieve trophies, you first need to retrieve it by translating titleId
into communicationId
by calling PsnAPI.GetTrohpiesWithIdsMobile
, example use here:
https://github.com/XenorPLxx/playnite-library-psn/blob/f430cb288444e36d3da8ff48d5564efbd9eda257/source/Libraries/PSNLibrary/PSNLibrary.cs#L267
Also, as the API takes 5 titleIds
at a time, I’d suggest dumping it into a file instead of resolving it each time. PSN plugin does this only once to import 1.0 plugin games, so I didn’t need to save it. There’ll be some custom metadata fields in P10 that could be used to store communicationId
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Thanks for your help.
This version must be good: playnite-successstory-plugin_2_2_1.zip
Yes, it seems to be working fine now 😃. I’m seeing trophies for PS4 and PS5 games. Thanks for fixing this 😃.