Import of skins
This commit is contained in:
65
skins.py
65
skins.py
@@ -0,0 +1,65 @@
|
||||
import psycopg2, json
|
||||
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS skins (
|
||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
||||
weapon uuid REFERENCES weapons(id),
|
||||
rarity uuid REFERENCES rarity(id),
|
||||
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[0] 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"]],
|
||||
"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.keys():
|
||||
skin = {
|
||||
"weapon": weapons[weapon],
|
||||
"rarity": rarity["Covert"],
|
||||
"paint_index": 0,
|
||||
"display": "Default",
|
||||
"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()
|
||||
Reference in New Issue
Block a user