56 lines
1.1 KiB
Python
56 lines
1.1 KiB
Python
import psycopg2, json
|
|
|
|
"""
|
|
CREATE TABLE IF NOT EXISTS rarity (
|
|
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
display varchar NOT NULL,
|
|
color varchar NOT NULL
|
|
);
|
|
"""
|
|
|
|
conn = psycopg2.connect("dbname=porning user=aindustries")
|
|
cur = conn.cursor()
|
|
|
|
with open("skins.json", "r") as f:
|
|
content = json.load(f)
|
|
|
|
rarities = {}
|
|
|
|
for raw in content:
|
|
if raw["rarity"]["name"] in rarities:
|
|
continue
|
|
|
|
rarity = {
|
|
"display": raw["rarity"]["name"],
|
|
"color": raw["rarity"]["color"]
|
|
}
|
|
|
|
rarities[rarity["display"]] = rarity
|
|
|
|
with open("agents.json", "r") as f:
|
|
content = json.load(f)
|
|
|
|
for raw in content:
|
|
if raw["rarity"]["name"] in rarities:
|
|
continue
|
|
|
|
rarity = {
|
|
"display": raw["rarity"]["name"],
|
|
"color": raw["rarity"]["color"]
|
|
}
|
|
|
|
rarities[rarity["display"]] = rarity
|
|
|
|
# Missing rarity for default skins
|
|
rarities["Stock"] = {
|
|
"display": "Stock",
|
|
"color": "#ded6cc"
|
|
}
|
|
|
|
for rarity in rarities.values():
|
|
cur.execute("INSERT INTO rarity (display, color) VALUES (%s, %s)", (rarity["display"], rarity["color"]))
|
|
|
|
conn.commit()
|
|
|
|
cur.close()
|
|
conn.close() |