-
Notifications
You must be signed in to change notification settings - Fork 0
/
getgames.py
65 lines (48 loc) · 1.31 KB
/
getgames.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from gogapi import GogApi, Token
import json
token = Token.from_file("token.json")
if token.expired():
token.refresh()
token.save("token.json")
api = GogApi(token)
# api.web_games_gogdata()
# prod = api.product(2134842136)
# prod.update_galaxy(expand=True)
game_ids = api.web_user_games()['owned']
print("Games:", game_ids)
myfile = open("owned.json", 'w')
myfile.write(json.dumps(game_ids))
myfile.close()
def get_gameinfo(id):
raw_game = api.web_account_gamedetails(id)
if type(raw_game) is not dict:
return {
"id": id,
"error": "no data"
}
languages = []
downloads = raw_game['downloads']
for i in range(0, len(downloads)):
print(i)
download = downloads[i]
languages.append(download[0])
return {
"id": id,
"title": raw_game['title'],
"releaseTimestamp": raw_game['releaseTimestamp'],
"backgroundImage": raw_game['backgroundImage'],
"languages": languages
}
games_with_info = []
for i in range(0, len(game_ids)):
game_id = game_ids[i]
print("fetching for id", game_id)
games_with_info.append(
get_gameinfo(game_id)
)
myfile = open("owned.json", 'w')
myfile.write(json.dumps({
"ids": game_ids,
"data": games_with_info
}))
myfile.close()