Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afb91b65ee | ||
|
|
86c245f85b | ||
|
|
9032415d78 | ||
|
|
25a179f5a0 |
@@ -14,14 +14,16 @@ MY_ID = 76561198826355942
|
|||||||
recent = {}
|
recent = {}
|
||||||
owned = {}
|
owned = {}
|
||||||
|
|
||||||
def get_cover_url(appid: int) -> str:
|
def modify_game_list(json: dict) -> dict:
|
||||||
return f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{appid}/header.jpg"
|
|
||||||
|
|
||||||
def inject_cover_url(json: dict) -> dict:
|
|
||||||
if 'games' in json.keys():
|
if 'games' in json.keys():
|
||||||
|
apps = (3301060, 404790, 1281930, 1920960, 1325960, 431960)
|
||||||
|
new_games = []
|
||||||
for i, g in enumerate(json['games']):
|
for i, g in enumerate(json['games']):
|
||||||
|
if g['appid'] not in apps:
|
||||||
json['games'][i]['h_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/header.jpg"
|
json['games'][i]['h_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/header.jpg"
|
||||||
json['games'][i]['v_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/library_600x900.jpg"
|
json['games'][i]['v_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/library_600x900.jpg"
|
||||||
|
new_games.append(json['games'][i])
|
||||||
|
json['games'] = new_games
|
||||||
return json
|
return json
|
||||||
|
|
||||||
def steam_request(interface: str, method: str, v: int = 1, **kwargs) -> requests.Response:
|
def steam_request(interface: str, method: str, v: int = 1, **kwargs) -> requests.Response:
|
||||||
@@ -36,7 +38,7 @@ def api_request(cache, *args, **kwargs):
|
|||||||
response = steam_request(*args, **kwargs)
|
response = steam_request(*args, **kwargs)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
cache.update({
|
cache.update({
|
||||||
'data': inject_cover_url(response.json().get("response")),
|
'data': modify_game_list(response.json().get("response")),
|
||||||
'last_updated': datetime.now().isoformat(),
|
'last_updated': datetime.now().isoformat(),
|
||||||
'status': 'success'
|
'status': 'success'
|
||||||
})
|
})
|
||||||
@@ -45,19 +47,25 @@ def api_request(cache, *args, **kwargs):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
cache['status'] = f'error: {str(e)}'
|
cache['status'] = f'error: {str(e)}'
|
||||||
|
|
||||||
scheduler = BackgroundScheduler()
|
if TOKEN:
|
||||||
scheduler.add_job(
|
scheduler = BackgroundScheduler()
|
||||||
|
scheduler.add_job(
|
||||||
func=lambda: api_request(recent, "IPlayerService", "GetRecentlyPlayedGames", steamid=76561198826355942),
|
func=lambda: api_request(recent, "IPlayerService", "GetRecentlyPlayedGames", steamid=76561198826355942),
|
||||||
trigger=IntervalTrigger(minutes=15),
|
trigger=IntervalTrigger(minutes=15),
|
||||||
id='risdeveau.steam.recent',
|
id='risdeveau.steam.recent',
|
||||||
replace_existing=True
|
replace_existing=True
|
||||||
)
|
)
|
||||||
scheduler.add_job(
|
scheduler.add_job(
|
||||||
func=lambda: api_request(owned, "IPlayerService", "GetOwnedGames", steamid=76561198826355942, include_appinfo=1, include_played_free_games=1),
|
func=lambda: api_request(owned, "IPlayerService", "GetOwnedGames", steamid=76561198826355942, include_appinfo=1, include_played_free_games=1),
|
||||||
trigger=IntervalTrigger(minutes=15),
|
trigger=IntervalTrigger(minutes=15),
|
||||||
id='risdeveau.steam.owned',
|
id='risdeveau.steam.owned',
|
||||||
replace_existing=True
|
replace_existing=True
|
||||||
)
|
)
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
|
|
||||||
atexit.register(lambda: scheduler.shutdown())
|
api_request(recent, "IPlayerService", "GetRecentlyPlayedGames", steamid=76561198826355942)
|
||||||
|
api_request(owned, "IPlayerService", "GetOwnedGames", steamid=76561198826355942, include_appinfo=1, include_played_free_games=1)
|
||||||
|
|
||||||
|
atexit.register(lambda: scheduler.shutdown())
|
||||||
|
else:
|
||||||
|
print("STEAM_TOKEN is not defined")
|
||||||
Reference in new issue
Block a user