-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimplementAPI.py
More file actions
59 lines (47 loc) · 1.78 KB
/
implementAPI.py
File metadata and controls
59 lines (47 loc) · 1.78 KB
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
import requests
import os, sys
script_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(script_dir)
import json
gameFile = os.path.join(script_dir, "gameID.txt")
gameInfoFile = os.path.join(script_dir, "gameInfo.json")
coverFile = os.path.join(script_dir, "coverID.txt")
coverURL = os.path.join(script_dir, "coverURLFile.txt")
studioFile = os.path.join(script_dir, "studioID.txt")
studioNames = os.path.join(script_dir, "studioNamesFile.txt")
url = "https://api.igdb.com/v4/games/"
headers={"Client-ID":"4wosykh1ay6nekw5wm7snyvfujab25", "Authorization":"Bearer 67ynk7wndnr0fdw2owihpucvglids0"}
coversURL = "https://api.igdb.com/v4/covers/"
studioURL = "https://api.igdb.com/v4/companies/"
gameIdFile = open(gameFile, "r")
gameInformation = open(gameInfoFile, "a+")
coverIdFile = open(coverFile, "r")
coverURLFile = open(coverURL, "w")
studioIdFile = open(studioFile, "r")
studioNamesFile = open(studioNames, "w")
#lines = gameIdFile.readlines()
#for line in lines:
# x = requests.post(url, data=line, headers=headers)
# gameInformation.writelines(x.text)
#gameInformation = open(gameInfoFile)
#data = json.load(gameInformation)
#all_games = []
#for game in data:
# cover = game.get('cover', 0)
## coverIdFile.write(str(cover) + "\n")
#urlLines = coverIdFile.readlines()
#print(urlLines)
#for line in urlLines:
# print(line)
# x = requests.post(coversURL, data=line, headers=headers)
# coverURLFile.writelines(x.text)
#gameInformation = open(gameInfoFile)
#data = json.load(gameInformation)
#for game in data:
# studio = game.get('created_at', "No Studio")
# studioIdFile.write(str(studio) + "\n")
studioLines = studioIdFile.readlines()
for line in studioLines:
x = requests.post(studioURL, data=line, headers=headers)
print(x.text)
studioNamesFile.writelines(x.text)