69 lines
1.8 KiB
Python
69 lines
1.8 KiB
Python
import psycopg2, json
|
|
|
|
"""
|
|
CREATE TABLE IF NOT EXISTS skins (
|
|
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
weapon uuid REFERENCES weapons(id) NOT NULL,
|
|
rarity uuid REFERENCES rarity(id) NOT NULL,
|
|
paint_index integer NOT NULL,
|
|
display varchar NOT NULL,
|
|
min_float float NOT NULL,
|
|
max_float float NOT NULL,
|
|
legacy boolean NOT NULL
|
|
);
|
|
"""
|
|
|
|
conn = psycopg2.connect("dbname=porning user=aindustries")
|
|
cur = conn.cursor()
|
|
|
|
cur.execute("SELECT * FROM weapons")
|
|
raw_weapons = cur.fetchall()
|
|
weapons = {weapon[1]: weapon for weapon in raw_weapons}
|
|
|
|
cur.execute("SELECT * FROM rarity")
|
|
raw_rarity = cur.fetchall()
|
|
rarity = {rarity[1]: rarity[0] for rarity in raw_rarity}
|
|
|
|
with open("skins.json", "r") as f:
|
|
content = json.load(f)
|
|
|
|
skins = []
|
|
|
|
for raw in content:
|
|
if "sfui_wpnhud" in raw["weapon"]["id"]:
|
|
continue
|
|
|
|
skin = {
|
|
"weapon": weapons[raw["weapon"]["id"]][0],
|
|
"rarity": rarity[raw["rarity"]["name"]],
|
|
"paint_index": raw["paint_index"],
|
|
"display": raw["pattern"]["name"],
|
|
"min_float": raw["min_float"],
|
|
"max_float": raw["max_float"],
|
|
"legacy": raw["legacy_model"]
|
|
}
|
|
skins.append(skin)
|
|
|
|
for weapon in weapons.values():
|
|
if weapon[4] == "Gloves" and not "Default" in weapon[2]:
|
|
print("skip")
|
|
continue
|
|
|
|
skin = {
|
|
"weapon": weapon[0],
|
|
"rarity": rarity["Stock"],
|
|
"paint_index": 0,
|
|
"display": "",
|
|
"min_float": 0,
|
|
"max_float": 0,
|
|
"legacy": True
|
|
}
|
|
skins.append(skin)
|
|
|
|
#for skin in skins:
|
|
# cur.execute("INSERT INTO skins (weapon, rarity, paint_index, display, min_float, max_float, legacy) VALUES (%s, %s, %s, %s, %s, %s, %s)", (skin["weapon"], skin["rarity"], skin["paint_index"], skin["display"], skin["min_float"], skin["max_float"], skin["legacy"]))
|
|
|
|
conn.commit()
|
|
|
|
cur.close()
|
|
conn.close() |