Пример #1
0
def get_killmail(kill):
    url = None
    if type(kill) is str:
        url = kill
    elif type(kill) is KillMail:
        url = kill.crest_url
    elif type(kill) is int:
        kill = KillMail(kill)
        url = kill.crest_url
    if url is None:
        return None
    data = web.fetch_url(url)
    return json.loads(data)
Пример #2
0
def get_killmail(kill):
    url = None
    if type(kill) is str:
        url = kill
    elif type(kill) is KillMail:
        url = kill.crest_url
    elif type(kill) is int:
        kill = KillMail(kill)
        url = kill.crest_url
    if url is None:
        return None
    data = web.fetch_url(url)
    return json.loads(data)
Пример #3
0
def get_kills(start_time):
    _log.info('Getting all killmails from start time: %s.' % start_time)
    url_format = 'https://zkillboard.com/api/allianceID/%d/startTime/%s/orderDirection/asc/api-only/page/%d/'
    all_kills = []
    for page in range(10):
        url = url_format % (alliance_id, start_time, page+1)
        content = web.fetch_url(url)
        kills = json.loads(content)
        all_kills = itertools.chain(all_kills, [kill for kill in kills if kill is not None])
        if len(kills) < 200:
            break
    bad = [kill for kill in all_kills if 'killID' not in kill]
    _log.debug('Some kills did not have kill ids: %s' % bad)
    all_kills = [kill for kill in all_kills if 'killID' in kill]
    return list(all_kills)
Пример #4
0
def get_kills(start_time):
    _log.info('Getting all killmails from start time: %s.' % start_time)
    url_format = 'https://zkillboard.com/api/allianceID/%d/startTime/%s/orderDirection/asc/api-only/page/%d/'
    all_kills = []
    for page in range(10):
        url = url_format % (alliance_id, start_time, page + 1)
        content = web.fetch_url(url)
        kills = json.loads(content)
        all_kills = itertools.chain(
            all_kills, [kill for kill in kills if kill is not None])
        if len(kills) < 200:
            break
    all_kills = list(all_kills)
    bad = [kill for kill in all_kills if 'killID' not in kill]
    _log.debug('Some kills did not have kill ids: %s' % bad)
    all_kills = [kill for kill in all_kills if 'killID' in kill]
    return list(all_kills)
Пример #5
0
def get_crest_hash(kill_id):
    _log.info('Getting killmail by id: %d.' % kill_id)
    url = 'https://zkillboard.com/api/killID/%d/no-items/' % kill_id
    content = web.fetch_url(url)
    kills = json.loads(content)
    km = kills[0] if kills and len(kills) > 0 else None
    victimID = str(int(km['victim']['characterID']) or 'None')
    attackerID = 'None'
    for a in km['attackers']:
        if str(a['finalBlow']) == '1':
            attackerID = str(int(a['characterID']) or 'None')
            break
    shipID = str(km['victim']['shipTypeID'] or 'None')
    dttm = datetime.strptime(km['killTime'], '%Y-%m-%d %H:%M:%S')
    dttm = str(long((dttm - datetime.utcfromtimestamp(0)).total_seconds() * 10000000 + 116444736000000000L))
    _log.info('Generating crest hash for kill %d from %s-%s-%s-%s' % (kill_id, victimID, attackerID, shipID, dttm))
    return sha.new(victimID + attackerID + shipID + dttm).hexdigest()
Пример #6
0
def get_jita_price(type_id):
    _log.debug('Getting Jita sell price for type %d.' % type_id)
    url = 'http://api.eve-central.com/api/quicklook?typeid=%d&usesystem=%d' % (
        type_id, jita_id)
    response = web.fetch_url(url)
    root = ET.fromstring(response)
    sell_orders = root.find('quicklook').find('sell_orders')
    price = None
    for order in sell_orders.findall('order'):
        p = float(order.find('price').text)
        if price is None or p < price:
            price = p
    if price is None:
        _log.info('No Jita price found for type %d.' % type_id)
    else:
        _log.debug('Jita price found for type %d: %f.' % (type_id, price))
    return price
Пример #7
0
def get_forge_price(type_id):
    _log.debug('Getting The Forge sell price for type %d.' % type_id)
    url = 'http://api.eve-central.com/api/quicklook?typeid=%d&regionlimit=%d' % (
        type_id, forge_id)
    response = web.fetch_url(url)
    root = ET.fromstring(response)
    sell_orders = root.find('quicklook').find('sell_orders')
    price = None
    for order in sell_orders.findall('order'):
        p = float(order.find('price').text)
        if price is None or p < price:
            price = p
    if price is None:
        item = InvType.by_id(type_id)
        _log.warning('No Forge price found for %s (type %d).' %
                     (item.typeName, type_id))
    else:
        _log.debug('Forge price found for type %d: %f.' % (type_id, price))
    return price
Пример #8
0
def get_crest_hash(kill_id):
    _log.info('Getting killmail by id: %d.' % kill_id)
    url = 'https://zkillboard.com/api/killID/%d/no-items/' % kill_id
    content = web.fetch_url(url)
    kills = json.loads(content)
    km = kills[0] if kills and len(kills) > 0 else None
    victimID = str(int(km['victim']['characterID']) or 'None')
    attackerID = 'None'
    for a in km['attackers']:
        if str(a['finalBlow']) == '1':
            attackerID = str(int(a['characterID']) or 'None')
            break
    shipID = str(km['victim']['shipTypeID'] or 'None')
    dttm = datetime.strptime(km['killTime'], '%Y-%m-%d %H:%M:%S')
    dttm = str(
        long((dttm - datetime.utcfromtimestamp(0)).total_seconds() * 10000000 +
             116444736000000000L))
    _log.info('Generating crest hash for kill %d from %s-%s-%s-%s' %
              (kill_id, victimID, attackerID, shipID, dttm))
    return sha.new(victimID + attackerID + shipID + dttm).hexdigest()
Пример #9
0
def get_kill(kill_id):
    _log.info('Getting killmail by id: %d.' % kill_id)
    url = 'https://zkillboard.com/api/killID/%d/' % kill_id
    content = web.fetch_url(url)
    kills = json.loads(content)
    return kills[0] if kills and len(kills) > 0 else None
Пример #10
0
def get_kill(kill_id):
    _log.info('Getting killmail by id: %d.' % kill_id)
    url = 'https://zkillboard.com/api/killID/%d/' % kill_id
    content = web.fetch_url(url)
    kills = json.loads(content)
    return kills[0] if kills and len(kills) > 0 else None