Skip to content
Permalink
Browse files

Update update_tf2_items to support new pagination of GetSchemaItems

  • Loading branch information...
Smashman committed Jun 26, 2019
1 parent 4d0f98f commit efca9e6a7a4f63015e3669bdee5b79e4b5dd9843
Showing with 20 additions and 4 deletions.
  1. +19 −3 app/scripts/scripts.py
  2. +1 −1 manage.py
@@ -20,9 +20,24 @@ def insert_classes():
db.session.commit()


def get_items(start=0):
items = []
try:
schema = steam.api.interface("IEconItems_440").GetSchemaItems(language="english", start=start).get("result")
if schema.get('items'):
items += schema.get('items')
if schema.get('next'):
items += get_items(schema.get('next'))
except HTTPError:
raise
return items


def update_tf2_items():
update_completed = False

defindex_start = 47 # Start at Demoman's Fro as everything before is a weapon

insert_classes()

bad_item_types = ["CheatDetector", "Tournament Medal", "Cursed Soul", "Badge"]
@@ -49,15 +64,16 @@ def update_tf2_items():

for i in range(10):
if not update_completed:
print "Not completed. Trying again."
if i > 0:
print "Not completed. Trying again."
try:
schema = steam.api.interface("IEconItems_440").GetSchema(language="english").get("result")
items = get_items(defindex_start)
schema = steam.api.interface("IEconItems_440").GetSchemaOverview(language="english").get("result")
items_game_url = schema.get('items_game_url')
items_game = steam.vdf.load(urllib2.urlopen(items_game_url)).get('items_game')
except HTTPError:
db.session.rollback()
continue
items = schema.get('items')
print "{} items in schema. Starting loop".format(len(items))
for item in items:
defindex = item.get('defindex')
@@ -4,7 +4,7 @@
Takes the following commands:
- runserver
- shell
- update_tf2_items (Updates information about TF2 Items stored in the DB - Runs every 24h via cron)
- update_tf2_items (Updates information about TF2 Items stored in the DB - Runs every 14d via cron)
- delete_expired_packages (Deletes packages that have expired - Runs every 24h via cron)
"""

0 comments on commit efca9e6

Please sign in to comment.
You can’t perform that action at this time.