Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, json, urllib2, sys
- reload(sys)
- sys.setdefaultencoding("utf-8")
- from pprint import pprint
- def load_list():
- if not os.path.isfile('DLC_LIST.txt'):
- return {}
- ret = {}
- with open('DLC_LIST.txt') as f:
- for line in f.readlines():
- if not line[0] == '#':
- pts = line.split(' ', 1)
- ret[pts[0]] = pts[1].rstrip('\n')
- return ret
- def getData(id):
- try:
- response = urllib2.urlopen('http://store.steampowered.com/api/appdetails/?appids=%s' % id)
- ret = json.loads(response.read())
- if ret == None:
- print('Temporarly blocked from steam API, try again later')
- return None
- return ret['%s' % id]['data']
- except:
- print('Temporarly blocked from steam API, try again later')
- return None
- list = load_list()
- print('# Known DLC: %s' % len(list))
- parent = getData('252690')
- if not parent == None:
- count = 0
- for num in parent['dlc']:
- id = '%s' % num
- if not id in list:
- dlc = None #getData(num)
- if dlc is None:
- print('')
- print('API Ban while iterating new DLC, updating list.')
- print('Run this script again in a few mins to get the rest')
- print('')
- break
- if (dlc['type'] == 'dlc'):
- print('New DLC: %s %s' % (dlc['steam_appid'], dlc['name']))
- count += 1
- list[id] = dlc['name']
- print ('# New DLC %s' % count)
- print ('# Total DLC %s' % len(list))
- with open('DLC_LIST.txt', 'w') as f:
- f.write('# Add DLC here, Format is "APPID App Name" APPID MUST be a valid APPID\n')
- f.write('# See the following website for a complete list:\n')
- f.write('# https://steamdb.info/app/252690/dlc/\n')
- f.write('# Total DLC: %s\n' % len(list))
- f.write('#\n')
- f.write('\n'.join(['%s %s' % (id, list[id]) for id in sorted(list.keys())]))
- f.write('\n')
Advertisement
Add Comment
Please, Sign In to add comment