-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.py
204 lines (178 loc) · 5.27 KB
/
convert.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env python3
# https://api.steampowered.com/ISteamApps/GetAppList/v2/
from markdown.extensions.tables import TableExtension
import markdown
import sys
from bs4 import BeautifulSoup
import subprocess
import json
import pandas as pd
f = open(sys.argv[1], "r")
text = f.read()
f.close()
html = markdown.markdown(text, extensions=[TableExtension(use_align_attribute=True)])
soup = BeautifulSoup(html, "html.parser")
h1 = ""
h2 = ""
h3 = ""
games = {}
h2Dict = {}
h3Dict = {}
listA = soup.contents
for x in listA:
if not x.name == None:
if x.name == "h1":
h2 = ""
h3 = ""
h1 = x.contents[0]
h2Dict = {}
if x.name == "h2":
h3 = ""
h2 = x.contents[0]
h3Dict = {}
if x.name == "h3":
h3 = x.contents[0]
if x.name == "ul":
content = []
for item in x:
if not item == "\n":
content.append(item.contents[0].strip())
if not h3 == "":
h3Dict[h3] = content
h2Dict[h2] = h3Dict
games[h1] = h2Dict
elif not h2 == "":
h2Dict[h2] = content
games[h1] = h2Dict
else:
games[h1] = content
fullGames = {"AAA": {}, "All VR": {}, "Base Building": {}, "Crafting": {}, "Creative Management": {}, "Platformer": {}, "Puzzle": {}, "Racing": {}, "RTS": {}, "Simulation": {}, "Small": {}, "Sports": {}, "Star Wars": {}, "Strategy": {}}
for platformA in games:
for storeA in games[platformA]:
for genreA, gamesListA in (games[platformA][storeA]).items():
dictA = fullGames[genreA]
for gameA in gamesListA:
if gameA in fullGames[genreA].keys():
fullGames[genreA][gameA]["platform"].append(platformA)
fullGames[genreA][gameA]["store"].append(storeA)
else:
entryA = {
"platform": [platformA],
"store": [storeA],
"hours": 0
}
dictA.update({gameA: entryA})
fullGames[genreA] = dictA
fileName = "games.json"
if len(sys.argv) > 2:
fileName = sys.argv[2]
with open(fileName, "w") as write_file:
newJson = json.dump(fullGames, write_file, indent=2)
'''
f = open("steam.json", "r")
steamAPIString = f.read()
steamAPI = json.loads(steamAPIString)
listOfSteamGames = []
for x in fullGames.keys():
for y in fullGames[x]:
if "Steam" in fullGames[x][y]["store"]:
listOfSteamGames.append(y)
ids = {}
for game in listOfSteamGames:
found = False
for x in steamAPI["applist"]["apps"]:
toTest = x["name"].replace(" ™", "")
toTest = toTest.replace("®", "")
if toTest.replace("™", "") == game:
ids.update({game: x["appid"]})
found = True
if not found:
if game == "Grand Theft Auto: San Andreas":
ids.update({game: "12120"})
if game == "HelixVision":
ids.update({game: "1137310"})
if game == "FrostPunk":
ids.update({game: "323190"})
if game == "Rimworld":
ids.update({game: "294100"})
if game == "Burnout Paradise: The Ultimate Box":
ids.update({game: "24740"})
if game == "DIRT 3 Complete Edition":
ids.update({game: "321040"})
if game == "DIRT 4":
ids.update({game: "421020"})
if game == "F1 2011":
ids.update({game: "44360"})
if game == "F1 2012":
ids.update({game: "208500"})
if game == "F1 2014":
ids.update({game: "226580"})
if game == "F1 2015":
ids.update({game: "286570"})
if game == "F1 2016":
ids.update({game: "391040"})
if game == "F1 2017":
ids.update({game: "515220"})
if game == "F1 2018":
ids.update({game: "737800"})
if game == "MotoGP 15":
ids.update({game: "355130"})
if game == "Project CARS":
ids.update({game: "234630"})
if game == "Project CARS 2":
ids.update({game: "378860"})
if game == "Age of Empires II HD Edition":
ids.update({game: "221380"})
if game == "Age of Empires II Definitive Edition":
ids.update({game: "813780"})
if game == "Age of Empires III Complete Collection":
ids.update({game: "105450"})
if game == "Star Wars Empire at War: Gold Pack":
ids.update({game: "32470"})
if game == "BEAR, VODKA, STALINGRAD":
ids.update({game: "1232130"})
if game == "Cook, Serve, Delicious":
ids.update({game: "247020"})
if game == "HELLION":
ids.update({game: "588210"})
if game == "PAC-MAN Museum":
ids.update({game: "1665130"})
if game == "LEGO Star Wars: The Force Awakens":
ids.update({game: "438640"})
if game == "Star Wars Battlefront (Classic, 2004)":
ids.update({game: "1058020"})
if game == "Star Wars Knights of the Old Republic":
ids.update({game: "32370"})
if game == "Star Wars Knights of the Old Republic II: The Sith Lords":
ids.update({game: "208580"})
if game == "Star Wars Republic Commando":
ids.update({game: "6000"})
if game == "Star Wars: Shadow of the Empire":
ids.update({game: "560170"})
if game == "Star Wars: The Old Republic":
ids.update({game: "1286830"})
if game == "Bloons TD6":
ids.update({game: "960090"})
if game == "Magic: The Gathering - Duels of the Planeswalkers 2013":
ids.update({game: "87330"})
if game == "DIRT Rally":
ids.update({game: "310560"})
notAllGames = False
for game in listOfSteamGames:
if not game in ids:
print(game)
notAllGames = True
if notAllGames:
print("Error")
exit()
for x in fullGames.keys():
for y in fullGames[x]:
if "Steam" in fullGames[x][y]["store"]:
game = y
fullGames[x][y]["steamID"] = ids[y]
fileName = "games.json"
if len(sys.argv) > 2:
fileName = sys.argv[2]
with open(fileName, "w") as write_file:
newJson = json.dump(fullGames, write_file, indent=2)
'''