Last active
February 6, 2018 21:06
-
-
Save Omochin/ecd018a74e927e6a25de2fa42fb63d74 to your computer and use it in GitHub Desktop.
use full xml api. get types.json -> https://github.com/Omochin/eveolnine-notice2discrod/blob/master/types.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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