|
|
|
@ -278,22 +278,30 @@ class LBTC(util.Base):
|
|
|
|
|
|
|
|
|
|
# with open("pub.json", "a") as f:
|
|
|
|
|
# import json
|
|
|
|
|
#
|
|
|
|
|
# f.write(json.dumps([page, currency, asset, ads]) + "\n")
|
|
|
|
|
# f.close()
|
|
|
|
|
if ads is None:
|
|
|
|
|
print("ASDS IS NONE")
|
|
|
|
|
return False
|
|
|
|
|
if ads is False:
|
|
|
|
|
print("ADS IS FALSE")
|
|
|
|
|
return False
|
|
|
|
|
if ads["response"] is None:
|
|
|
|
|
print("NO RESPONSE")
|
|
|
|
|
return False
|
|
|
|
|
if "data" not in ads["response"]:
|
|
|
|
|
print("NO DATAS")
|
|
|
|
|
return False
|
|
|
|
|
for ad in ads["response"]["data"]["ad_list"]:
|
|
|
|
|
if self.map_provider(ad["data"]["online_provider"]) not in providers:
|
|
|
|
|
print(ad["data"]["online_provider"], "is not in", providers)
|
|
|
|
|
print(ad["data"]["online_provider"] in providers)
|
|
|
|
|
continue
|
|
|
|
|
date_last_seen = ad["data"]["profile"]["last_online"]
|
|
|
|
|
# Check if this person was seen recently
|
|
|
|
|
if not util.last_online_recent(date_last_seen):
|
|
|
|
|
print("NOT SEEN RECENTLTY")
|
|
|
|
|
continue
|
|
|
|
|
ad_id = str(ad["data"]["ad_id"])
|
|
|
|
|
username = ad["data"]["profile"]["username"]
|
|
|
|
@ -340,13 +348,16 @@ class LBTC(util.Base):
|
|
|
|
|
|
|
|
|
|
@util.handle_exceptions
|
|
|
|
|
def update_prices(self, assets=None):
|
|
|
|
|
print("UPDATE_PRICES", assets)
|
|
|
|
|
# Get all public ads for the given assets
|
|
|
|
|
public_ads = self.get_all_public_ads(assets)
|
|
|
|
|
if not public_ads:
|
|
|
|
|
print("NOT PUBLIC ADS")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Get the ads to update
|
|
|
|
|
to_update = self.markets.get_new_ad_equations(self.platform, public_ads, assets)
|
|
|
|
|
print("TO UPdATE", to_update)
|
|
|
|
|
self.slow_ad_update(to_update)
|
|
|
|
|
|
|
|
|
|
# TODO: make generic and move to markets
|
|
|
|
@ -357,6 +368,7 @@ class LBTC(util.Base):
|
|
|
|
|
:return: dict of public ads keyed by currency
|
|
|
|
|
:rtype: dict
|
|
|
|
|
"""
|
|
|
|
|
print("GET ALL PUBLIC ADS")
|
|
|
|
|
public_ads = {}
|
|
|
|
|
crypto_map = {
|
|
|
|
|
"BTC": "bitcoin",
|
|
|
|
@ -382,11 +394,14 @@ class LBTC(util.Base):
|
|
|
|
|
except KeyError:
|
|
|
|
|
# self.log.error("Error getting public ads for currency {currency}", currency=currency)
|
|
|
|
|
continue
|
|
|
|
|
print("ABOUT TO RUN ENUM PUBLIC ADS WITH ", asset, currency, providers)
|
|
|
|
|
ads_list = self.enum_public_ads(asset, currency, providers)
|
|
|
|
|
print("ADS LIST", ads_list)
|
|
|
|
|
if not ads_list:
|
|
|
|
|
continue
|
|
|
|
|
ads = self.money.lookup_rates(self.platform, ads_list, rates=rates)
|
|
|
|
|
if not ads:
|
|
|
|
|
print("NOT ADS CONTINUE")
|
|
|
|
|
continue
|
|
|
|
|
self.write_to_es_ads("ads", ads)
|
|
|
|
|
if currency in public_ads:
|
|
|
|
@ -395,6 +410,7 @@ class LBTC(util.Base):
|
|
|
|
|
public_ads[currency].append(ad)
|
|
|
|
|
else:
|
|
|
|
|
public_ads[currency] = ads
|
|
|
|
|
print("RETURNING PUBLIC ADS", public_ads)
|
|
|
|
|
return public_ads
|
|
|
|
|
|
|
|
|
|
def write_to_es_ads(self, msgtype, ads):
|
|
|
|
|