diff --git a/.github/workflows/quality-check.yml b/.github/workflows/quality-check.yml index 0f2b7b4..87903d8 100644 --- a/.github/workflows/quality-check.yml +++ b/.github/workflows/quality-check.yml @@ -1,9 +1,10 @@ name: Quality Check on: - push: - branches: - - master + schedule: + # Runs every Monday at 12AM IST (UTC+5:30) + - cron: "30 18 * * 0" + workflow_dispatch: pull_request: branches: - master diff --git a/.github/workflows/steam-stats.yml b/.github/workflows/steam-stats.yml index 41bbae8..da01405 100644 --- a/.github/workflows/steam-stats.yml +++ b/.github/workflows/steam-stats.yml @@ -5,6 +5,9 @@ on: # Runs every Monday at 12AM IST (UTC+5:30) - cron: "30 18 * * 0" workflow_dispatch: + pull_request: + branches: + - master jobs: update-readme: diff --git a/README.md b/README.md index ba97249..37f0cd2 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,7 @@ [![Visitor Badge](https://badges.pufler.dev/visits/nicconike/steam-stats)](https://badges.pufler.dev) -![Steam Games Stats](https://github.com/Nicconike/Steam-Stats/blob/master/assets/recently_played_games.svg?sanitize=true) -![Steam Workshop Stats](https://github.com/Nicconike/Steam-Stats/blob/master/assets/steam_workshop_stats.svg?sanitize=true) diff --git a/api/card.py b/api/card.py index 10215de..ceb4d25 100644 --- a/api/card.py +++ b/api/card.py @@ -1,8 +1,8 @@ -"""Generate Card for Steam Stats""" -import json +"""Generate Cards for Steam Stats""" +import datetime import os from dotenv import load_dotenv -from steam_stats import get_player_summaries +from steam_stats import get_player_summaries, get_recently_played_games load_dotenv() @@ -11,25 +11,38 @@ STEAM_ID = os.getenv("STEAM_ID") +def format_unix_time(unix_time): + """Convert Unix time to human-readable format""" + return datetime.datetime.fromtimestamp(unix_time).strftime("%d/%m/%Y") + + def generate_card_for_player_summary(player_data): """Generate HTML content based on Steam Player Summary Data""" + if not player_data: + return None summary_data = player_data["response"]["players"][0] personaname = summary_data["personaname"] personastate = summary_data["personastate"] avatarfull = summary_data["avatarfull"] loccountrycode = summary_data["loccountrycode"] + lastlogoff = summary_data["lastlogoff"] + timecreated = summary_data["timecreated"] gameextrainfo = summary_data.get("gameextrainfo", None) + # Convert lastlogoff & timecreated from Unix time to human-readable format + lastlogoff_str = format_unix_time(lastlogoff) + timecreated_str = format_unix_time(timecreated) + personastate_map = { - 0: 'Offline', - 1: 'Online', - 2: 'Busy', - 3: 'Away', - 4: 'Snooze', - 5: 'Looking to trade', - 6: 'Looking to play' + 0: "Offline", + 1: "Online", + 2: "Busy", + 3: "Away", + 4: "Snooze", + 5: "Looking to trade", + 6: "Looking to play" } - personastate_value = personastate_map.get(personastate, 'Unknown') + personastate_value = personastate_map.get(personastate, "Unknown") html_content = f""" @@ -41,7 +54,7 @@ def generate_card_for_player_summary(player_data): +
+