Skip to content

Instantly share code, notes, and snippets.

@Omochin
Last active February 6, 2018 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Omochin/ecd018a74e927e6a25de2fa42fb63d74 to your computer and use it in GitHub Desktop.
Save Omochin/ecd018a74e927e6a25de2fa42fb63d74 to your computer and use it in GitHub Desktop.
import sys
import json
from collections import OrderedDict
from preston.xmlapi import Preston
APIS = {
3333333: "codecodecodecodecodecodecodecodecodecodecodecodecodecodecodecode"
}
def main():
if len(sys.argv) < 2:
print('Please input id or name')
return
else:
search_word = sys.argv[1]
with open('types.json', 'r') as file:
types_dict = json.load(file)
for key, code in APIS.items():
preston = Preston(
key=key,
code=code,
)
try:
rowset = preston.account.Characters()['rowset']
if 'row' not in rowset:
continue
except KeyError:
print('This key({}) is invalid'.format(key))
continue
row = rowset['row']
for character in row if isinstance(row, list) else [row]:
asset_list = preston.char.AssetList(characterID=character['@characterID'], flat=1)
for asset in asset_list['rowset']['row']:
if not isinstance(asset, OrderedDict):
continue
type_id = asset['@typeID']
if type_id not in types_dict:
continue
type_name = types_dict[type_id]
def output():
print('{} - LocationID {} - {}'.format(character['@name'], asset['@locationID'], type_name))
if search_word.isdigit():
if type_id == search_word:
output()
else:
if search_word in type_name:
output()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment