diff --git a/core/sig_utils.py b/core/sig_utils.py index 0dd7501..96306c5 100644 --- a/core/sig_utils.py +++ b/core/sig_utils.py @@ -1,7 +1,7 @@ import csv import logging -from pyhamtools.locator import latlong_to_locator +from pyhamtools.locator import latlong_to_locator, locator_to_latlong from core.cache_utils import SEMI_STATIC_URL_DATA_CACHE from core.constants import SIGS, HTTP_HEADERS @@ -21,7 +21,7 @@ def get_ref_regex_for_sig(sig): # Note there is currently no support for KRMNPA location lookup, see issue #61. def populate_sig_ref_info(sig_ref): if sig_ref.sig is None or sig_ref.id is None: - logging.warn("Failed to look up sig_ref info, sig or id were not set.") + logging.warning("Failed to look up sig_ref info, sig or id were not set.") sig = sig_ref.sig ref_id = sig_ref.id @@ -121,7 +121,17 @@ def populate_sig_ref_info(sig_ref): sig_ref.name = sig_ref.id sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-") elif sig.upper() == "LLOTA": - sig_ref.url = "https://llota.app/list/ref/" + ref_id + data = SEMI_STATIC_URL_DATA_CACHE.get("https://llota.app/api/public/references", headers=HTTP_HEADERS).json() + if data: + for ref in data: + if ref["reference_code"] == ref_id: + sig_ref.name = ref["name"] + sig_ref.url = "https://llota.app/list/ref/" + ref_id + sig_ref.grid = ref["grid_locator"] + ll = locator_to_latlong(sig_ref.grid) + sig_ref.latitude = ll[0] + sig_ref.longitude = ll[1] + break elif sig.upper() == "WWTOTA": sig_ref.url = "https://wwtota.com/seznam/karta_rozhledny.php?ref=" + ref_id elif sig.upper() == "WAB" or sig.upper() == "WAI": @@ -132,7 +142,7 @@ def populate_sig_ref_info(sig_ref): sig_ref.latitude = ll[0] sig_ref.longitude = ll[1] except: - logging.warn("Failed to look up sig_ref info for " + sig + " ref " + ref_id + ".") + logging.warning("Failed to look up sig_ref info for " + sig + " ref " + ref_id + ".") return sig_ref diff --git a/spotproviders/llota.py b/spotproviders/llota.py index e2e97a6..2c362f9 100644 --- a/spotproviders/llota.py +++ b/spotproviders/llota.py @@ -21,8 +21,8 @@ class LLOTA(HTTPSpotProvider): comment = None spotter = None if "history" in source_spot and len(source_spot["history"]) > 0: - comment = source_spot["history"][0]["comment"] - spotter = source_spot["history"][0]["spotter_callsign"] + comment = source_spot["history"][-1]["comment"] + spotter = source_spot["history"][-1]["spotter_callsign"] # Convert to our spot format spot = Spot(source=self.name, source_id=source_spot["id"], diff --git a/spotproviders/pota.py b/spotproviders/pota.py index 13f75d5..08f8ab1 100644 --- a/spotproviders/pota.py +++ b/spotproviders/pota.py @@ -11,8 +11,6 @@ from spotproviders.http_spot_provider import HTTPSpotProvider class POTA(HTTPSpotProvider): POLL_INTERVAL_SEC = 120 SPOTS_URL = "https://api.pota.app/spot/activator" - # Might need to look up extra park data - PARK_URL_ROOT = "https://api.pota.app/park/" def __init__(self, provider_config): super().__init__(provider_config, self.SPOTS_URL, self.POLL_INTERVAL_SEC) diff --git a/spotproviders/sota.py b/spotproviders/sota.py index 56026d1..a01e583 100644 --- a/spotproviders/sota.py +++ b/spotproviders/sota.py @@ -16,8 +16,6 @@ class SOTA(HTTPSpotProvider): # The actual data lookup all happens after parsing and checking the epoch. EPOCH_URL = "https://api-db2.sota.org.uk/api/spots/epoch" SPOTS_URL = "https://api-db2.sota.org.uk/api/spots/60/all/all" - # SOTA spots don't contain lat/lon, we need a separate lookup for that - SUMMIT_URL_ROOT = "https://api-db2.sota.org.uk/api/summits/" def __init__(self, provider_config): super().__init__(provider_config, self.EPOCH_URL, self.POLL_INTERVAL_SEC)