Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check the last 24hours for recently played games as Sony doesnt update it often #28

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/trophies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import discord
from datetime import datetime, timedelta, timezone
from psnawp_api import PSNAWP
import pytz

from utils.image_utils import get_discord_color
from utils.date_utils import format_date
Expand All @@ -21,11 +22,11 @@ def get_client():
def get_current_time():
return datetime.now(timezone.utc)

def get_recent_titles(client, minutes=TROPHIES_INTERVAL):
def get_recent_titles(client, hours=24): # Use 24 hours because Sony's API is not updating the last_played_date_time very often
logger.info("Calling Sony API to get recently played games")
now = get_current_time()
titles = list(client.title_stats())
title_ids = [(title.title_id, 'PS5' if 'ps5' in title.category.value else 'PS4') for title in titles if title.last_played_date_time > now - timedelta(minutes=minutes)]
title_ids = [(title.title_id, 'PS5' if 'ps5' in title.category.value else 'PS4') for title in titles if title.last_played_date_time > now - timedelta(hours=hours)]
logger.debug(f"API response: {titles}")
for title in titles:
if title.title_id in [id_ for id_, platform in title_ids]:
Expand Down
Loading