psnawp_api.models.title_stats module#
Provides TitleStats class for retrieving a user’s statistics on played titles and games.
- class PlatformCategory(*values)[source]#
Bases:
EnumRepresents the PlayStation platform associated with title.
- PS4 = 'ps4_game'#
- PS5 = 'ps5_native_game'#
- UNKNOWN = 'unknown'#
- class TitleStats(title_id: str | None, name: str | None, image_url: str | None, category: PlatformCategory | None, play_count: int | None, first_played_date_time: datetime | None, last_played_date_time: datetime | None, play_duration: timedelta | None)[source]#
Bases:
objectA class that represents a PlayStation Video Game Play Time Stats.
Note
This class is intended to be used via PSNAWP.
- __init__(title_id: str | None, name: str | None, image_url: str | None, category: PlatformCategory | None, play_count: int | None, first_played_date_time: datetime | None, last_played_date_time: datetime | None, play_duration: timedelta | None) None#
- category: PlatformCategory | None#
Category/Platform Type
- classmethod from_dict(game_stats_dict: dict[str, Any]) TitleStats[source]#
Creates an instance of
TitleStatsfrom a dictionary.
- class TitleStatsIterator(authenticator: Authenticator, url: str, pagination_args: PaginationArguments)[source]#
Bases:
PaginationIterator[TitleStats]An iterator for fetching and paginating through TitleStats objects from the PlayStation Network API.
Note
This class is intended to be used via Client or User class. See
psnawp_api.models.client.Client.title_stats()orpsnawp_api.models.user.User.title_stats().Init for TitleStatsIterator.
- __init__(authenticator: Authenticator, url: str, pagination_args: PaginationArguments) None[source]#
Init for TitleStatsIterator.
- fetch_next_page() Generator[TitleStats, None, None][source]#
Fetches the next page of TitleStats objects from the API.
- Yield:
A generator yielding TitleStats objects.
- classmethod from_endpoint(authenticator: Authenticator, account_id: str, pagination_args: PaginationArguments) Self[source]#
Creates an instance of TitleStatsIterator from the given endpoint.
- Parameters:
authenticator – The Authenticator instance used for making authenticated requests to the API.
account_id – The account ID for which to fetch title stats.
pagination_args – Arguments for handling pagination, including limit, offset, and page size.
- Returns:
An instance of TitleStatsIterator.
- play_duration_to_timedelta(play_duration: str | None) timedelta[source]#
Provides a timedelta object for the play duration PSN sends. If for some reason the string is malformed or None, timedelta will return 0.
Valid patters: PT243H18M48S, PT21M18S, PT18H, PT18H20S, PT4H21M
- Parameters:
play_duration – String from API
- Returns:
String parsed into a timedelta object
Note
PSN API returns the duration in this format: PT243H18M48S. The maximum time Unit is Hours, it does not extend to Days or Months.