diff --git a/service/fit.py b/service/fit.py index 8cdf15a02..4e3a1aa7b 100644 --- a/service/fit.py +++ b/service/fit.py @@ -88,7 +88,7 @@ class Fit: "enableGaugeAnimation": True, "openFitInNew": False, "priceSystem": "Jita", - "priceSource": "evemarketer", + "priceSource": "fuzzwork market", "showShipBrowserTooltip": True, "marketSearchDelay": 250, "ammoChangeAll": False, diff --git a/service/marketSources/__init__.py b/service/marketSources/__init__.py index 311b3b284..a70452a1f 100644 --- a/service/marketSources/__init__.py +++ b/service/marketSources/__init__.py @@ -1 +1 @@ -__all__ = ['evemarketer', 'evemarketdata', 'fuzzwork', 'cevemarket'] +__all__ = ['evetycoon', 'evemarketdata', 'fuzzwork', 'cevemarket'] diff --git a/service/marketSources/evemarketer.py b/service/marketSources/evemarketer.py deleted file mode 100644 index 0af18bb4e..000000000 --- a/service/marketSources/evemarketer.py +++ /dev/null @@ -1,75 +0,0 @@ -# ============================================================================= -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -# ============================================================================= - - -from xml.dom import minidom - -from logbook import Logger - -from eos.saveddata.price import PriceStatus -from service.network import Network -from service.price import Price - -pyfalog = Logger(__name__) - - -class EveMarketer: - - name = 'evemarketer' - group = 'tranquility' - - def __init__(self, priceMap, system, fetchTimeout): - # Try selected system first - self.fetchPrices(priceMap, max(2 * fetchTimeout / 3, 2), system) - # If price was not available - try globally - if priceMap: - self.fetchPrices(priceMap, max(fetchTimeout / 3, 2)) - - @staticmethod - def fetchPrices(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' - network = Network.getInstance() - data = network.get(url=baseurl, type=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 - for type_ in types: - # Get data out of each typeID details tree - typeID = int(type_.getAttribute('id')) - sell = type_.getElementsByTagName('sell').item(0) - # If price data wasn't there, skip the item - try: - percprice = float(sell.getElementsByTagName('percentile').item(0).firstChild.data) - except (TypeError, ValueError): - pyfalog.warning('Failed to get price for: {0}', type_) - continue - - # 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] - - -Price.register(EveMarketer) diff --git a/service/marketSources/evetycoon.py b/service/marketSources/evetycoon.py new file mode 100644 index 000000000..ec7da5d0b --- /dev/null +++ b/service/marketSources/evetycoon.py @@ -0,0 +1,68 @@ +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + + +from xml.dom import minidom + +from logbook import Logger + +from eos.saveddata.price import PriceStatus +from service.network import Network +from service.price import Price + +pyfalog = Logger(__name__) + +locations = { + 30000142: (10000002, 60003760), # Jita 4-4 CNAP + 30002187: (10000043, 60008494), # Amarr VIII + 30002659: (10000032, 60011866), # Dodixie + 30002510: (10000030, 60004588), # Rens + 30002053: (10000042, 60005686)} # Hek + + +class EveTycoon: + + name = 'evetycoon' + group = 'tranquility' + + def __init__(self, priceMap, system, fetchTimeout): + # Try selected system first + self.fetchPrices(priceMap, max(2 * fetchTimeout / 3, 2), system) + + @staticmethod + def fetchPrices(priceMap, fetchTimeout, system=None): + # Default to jita when system is not found + regionID, stationID = locations.get(system, locations[30000142]) + baseurl = 'https://evetycoon.com/api/v1/market/stats' + network = Network.getInstance() + # Cycle through all types we've got from request + for typeID in tuple(priceMap): + url = f'{baseurl}/{regionID}/{typeID}' + resp = network.get(url=url, params={'locationId': stationID}, type=network.PRICES, timeout=fetchTimeout) + if resp.status_code != 200: + continue + price = resp.json()['sellAvgFivePercent'] + # Price is 0 - no data + if price == 0: + continue + priceMap[typeID].update(PriceStatus.fetchSuccess, price) + del priceMap[typeID] + + +Price.register(EveTycoon) diff --git a/service/price.py b/service/price.py index 8b82c6225..5a4fe0a1a 100644 --- a/service/price.py +++ b/service/price.py @@ -276,4 +276,4 @@ class PriceWorkerThread(threading.Thread): # Import market sources only to initialize price source modules, they register on their own -from service.marketSources import evemarketer, evemarketdata, fuzzwork, cevemarket # noqa: E402 +from service.marketSources import evemarketdata, fuzzwork, cevemarket, evetycoon # noqa: E402