-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem_city_data.py
More file actions
43 lines (35 loc) · 1.74 KB
/
Copy pathitem_city_data.py
File metadata and controls
43 lines (35 loc) · 1.74 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
from db import DataBase
import requests
import time
def item_names_data():
response = requests.get('https://raw.githubusercontent.com/ao-data/ao-bin-dumps/master/formatted/items.json').json()
db = DataBase()
for item in response:
db.add_item(table='item_names', column='unique_name', value=item['UniqueName'])
def market_places_data():
response = requests.get('https://raw.githubusercontent.com/ao-data/ao-bin-dumps/master/formatted/world.json').json()
db = DataBase()
for location in response:
if (('Market' in location['UniqueName'] or 'Rest' in location['UniqueName']) and
'Auction' not in location['Index']):
db.add_items(table='markets', columns=('index', 'unique_name'),
values=(location['Index'], location['UniqueName']))
elif location['UniqueName'] == 'Caerleon':
db.add_items(table='markets', columns=('index', 'unique_name'),
values=(location['Index'], location['UniqueName']))
def market_categories_and_subcategories_data():
response = requests.get('https://raw.githubusercontent.com/ao-data/ao-bin-dumps/master/items.json').json()
db = DataBase()
n = 1
for category in response['items']['shopcategories']['shopcategory']:
db.add_item(table='categories', column='category', value=category['@id'])
for subcategory in category['shopsubcategory']:
db.add_items(table='subcategories', columns=('subcategory', 'category'), values=(subcategory['@id'], n))
n += 1
if __name__ == '__main__':
start_time = time.time()
item_names_data()
market_places_data()
market_categories_and_subcategories_data()
end_time = time.time()
print('Time:', end_time - start_time)