Fetch item price globally if failed to get sensible data for specified system
This commit is contained in:
@@ -34,13 +34,18 @@ class EveMarketData:
|
||||
name = "eve-marketdata.com"
|
||||
|
||||
def __init__(self, priceMap, system, fetchTimeout):
|
||||
data = {}
|
||||
baseurl = "https://eve-marketdata.com/api/item_prices.xml"
|
||||
data["system_id"] = system
|
||||
data["type_ids"] = ','.join(str(typeID) for typeID in priceMap)
|
||||
# Try selected system first
|
||||
self.fetchPrices(priceMap, fetchTimeout, system)
|
||||
# If price was not available - try globally
|
||||
self.fetchPrices(priceMap, fetchTimeout)
|
||||
|
||||
def fetchPrices(self, priceMap, fetchTimeout, system=None):
|
||||
params = {"type_ids": ','.join(str(typeID) for typeID in priceMap)}
|
||||
if system is not None:
|
||||
params["system_id"] = system
|
||||
baseurl = "https://eve-marketdata.com/api/item_prices.xml"
|
||||
network = Network.getInstance()
|
||||
data = network.request(baseurl, network.PRICES, params=data, timeout=fetchTimeout)
|
||||
data = network.request(baseurl, network.PRICES, params=params, timeout=fetchTimeout)
|
||||
xml = minidom.parseString(data.text)
|
||||
types = xml.getElementsByTagName("eve").item(0).getElementsByTagName("price")
|
||||
|
||||
|
||||
@@ -34,14 +34,18 @@ class EveMarketer:
|
||||
name = "evemarketer"
|
||||
|
||||
def __init__(self, priceMap, system, fetchTimeout):
|
||||
data = {}
|
||||
# Try selected system first
|
||||
self.fetchPrices(priceMap, fetchTimeout, system)
|
||||
# If price was not available - try globally
|
||||
self.fetchPrices(priceMap, fetchTimeout)
|
||||
|
||||
def fetchPrices(self, priceMap, fetchTimeout, system=None):
|
||||
params = {"typeid": {typeID for typeID in priceMap}}
|
||||
if system is not None:
|
||||
params["usesystem"] = system
|
||||
baseurl = "https://api.evemarketer.com/ec/marketstat"
|
||||
|
||||
data["usesystem"] = system
|
||||
data["typeid"] = {typeID for typeID in priceMap}
|
||||
|
||||
network = Network.getInstance()
|
||||
data = network.request(baseurl, network.PRICES, params=data, timeout=fetchTimeout)
|
||||
data = network.request(baseurl, network.PRICES, params=params, timeout=fetchTimeout)
|
||||
xml = minidom.parseString(data.text)
|
||||
types = xml.getElementsByTagName("marketstat").item(0).getElementsByTagName("type")
|
||||
# Cycle through all types we've got from request
|
||||
@@ -56,7 +60,12 @@ class EveMarketer:
|
||||
pyfalog.warning("Failed to get price for: {0}", type_)
|
||||
continue
|
||||
|
||||
# Fill price data
|
||||
# Price is 0 if evemarketer has info on this item, but it is not available
|
||||
# for current scope limit. If we provided scope limit - make sure to skip
|
||||
# such items to check globally, and do not skip if requested globally
|
||||
if percprice == 0 and system is not None:
|
||||
continue
|
||||
|
||||
priceMap[typeID].update(PriceStatus.fetchSuccess, percprice)
|
||||
del priceMap[typeID]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user