Skip to content

Commit

Permalink
add support for additional languages
Browse files Browse the repository at this point in the history
  • Loading branch information
JackJPowell committed Nov 9, 2024
1 parent b493df9 commit 89e2ee1
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions custom_components/playstation_network/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ async def _async_update_data(self) -> dict[str, Any]:
== "availableToPlay"
)
self.data["platform"] = (
self.data["presence"]
.get("basicPresence")
.get("primaryPlatformInfo")
self.data["presence"].get("basicPresence").get("primaryPlatformInfo")
)
try:
self.data["title_metadata"] = (
Expand All @@ -76,9 +74,7 @@ async def _async_update_data(self) -> dict[str, Any]:
self.data["title_metadata"] = {}

# self.data["friends"] = await self.client.available_to_play()
self.data[
"trophy_summary"
] = await self.hass.async_add_executor_job(
self.data["trophy_summary"] = await self.hass.async_add_executor_job(
lambda: self.client.trophy_summary()
)

Expand All @@ -90,11 +86,17 @@ async def _async_update_data(self) -> dict[str, Any]:
title = await self.hass.async_add_executor_job(
lambda: self.api.game_title(title_id, "me")
)
self.data[
"title_details"
] = await self.hass.async_add_executor_job(
lambda: title.get_details()
## Attempt to pull details with user's country and language code
self.data["title_details"] = await self.hass.async_add_executor_job(
lambda: title.get_details(
self.hass.config.country, self.hass.config.language
)
)
## If we receive an error, fall back to english
if self.data["title_details"][0].get("errorCode") is not None:
self.data["title_details"] = await self.hass.async_add_executor_job(
lambda: title.get_details()
)

trophy_titles = await self.hass.async_add_executor_job(
lambda: self.client.trophy_titles_for_title(
Expand Down

0 comments on commit 89e2ee1

Please sign in to comment.