-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
28 lines (23 loc) · 888 Bytes
/
Copy pathindex.py
File metadata and controls
28 lines (23 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from src.main import fetch_weekly_free_games, fetch_pinned_games
from src.utils import notify_user, parse_game_list, delete_files, is_notify_time, logger
import json
def run():
free_games, to_be_free = fetch_weekly_free_games()
pined_games = fetch_pinned_games()
game_data = {
"free_games": free_games,
"to_be_free": to_be_free,
"pinned": pined_games
}
with open("./page/json/game_info.json", "w", encoding='utf-8') as f:
json.dump(game_data, f)
image_folder = "./page/images"
delete_files(image_folder)
message = '\n'.join(parse_game_list(free_games + to_be_free))
print(message)
if is_notify_time(free_games[0]['start_date']):
notify_user(title="Epic Weekly Free Games", content=message)
else:
logger.info("Push notification is cancelled ...")
if __name__ == "__main__":
run()