-
Notifications
You must be signed in to change notification settings - Fork 0
/
igdb_databases.py
83 lines (46 loc) · 1.96 KB
/
igdb_databases.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
import json
from anonymize_data import get_data_folder
def get_igdb_file_name_suffix(release_year=None):
suffix = '' if release_year is None else '_' + str(release_year)
return suffix
def get_igdb_match_database_file_name(release_year=None):
# Dict: query string ---> igdb ID
suffix = get_igdb_file_name_suffix(release_year)
file_name = get_data_folder() + 'igdb_match_database' + suffix + '.json'
return file_name
def get_igdb_local_database_file_name(release_year=None):
# Dict: igdb ID ---> igdb data
suffix = get_igdb_file_name_suffix(release_year)
file_name = get_data_folder() + 'igdb_local_database' + suffix + '.json'
return file_name
def load_igdb_match_database(release_year=None, file_name=None):
if file_name is None:
file_name = get_igdb_match_database_file_name(release_year=release_year)
with open(file_name, encoding='utf-8') as f:
data = json.load(f)
return data
def save_igdb_match_database(data, release_year=None, file_name=None):
if file_name is None:
file_name = get_igdb_match_database_file_name(release_year=release_year)
with open(file_name, 'w', encoding='utf-8') as f:
json.dump(data, f)
return
def load_igdb_local_database(release_year=None, file_name=None):
if file_name is None:
file_name = get_igdb_local_database_file_name(release_year=release_year)
with open(file_name, encoding='utf-8') as f:
data = json.load(f)
return data
def save_igdb_local_database(data, release_year=None, file_name=None):
if file_name is None:
file_name = get_igdb_local_database_file_name(release_year=release_year)
with open(file_name, 'w', encoding='utf-8') as f:
json.dump(data, f)
return
def main():
release_year = '2018'
igdb_match_database = load_igdb_match_database(release_year)
igdb_local_database = load_igdb_local_database(release_year)
return True
if __name__ == '__main__':
main()