From b62ef6a9a04d6a0ff049cf013133989896d5f893 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Thu, 22 Jan 2026 19:27:36 +0000 Subject: [PATCH] WWTOTA cluster support #97 --- core/constants.py | 2 +- core/lookup_helper.py | 4 +++- core/sig_utils.py | 4 ++++ spotproviders/wwtota.py | 36 +++++++++++++++++++----------------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/core/constants.py b/core/constants.py index c6b6a3a..c2c5fa8 100644 --- a/core/constants.py +++ b/core/constants.py @@ -4,7 +4,7 @@ from data.sig import SIG # General software SOFTWARE_NAME = "Spothole by M0TRT" -SOFTWARE_VERSION = "1.2" +SOFTWARE_VERSION = "1.3-pre" # HTTP headers used for spot providers that use HTTP HTTP_HEADERS = {"User-Agent": SOFTWARE_NAME + ", v" + SOFTWARE_VERSION + " (operated by " + SERVER_OWNER_CALLSIGN + ")"} diff --git a/core/lookup_helper.py b/core/lookup_helper.py index 1ecb8f6..246390d 100644 --- a/core/lookup_helper.py +++ b/core/lookup_helper.py @@ -140,12 +140,14 @@ class LookupHelper: # database live if possible. def download_clublog_ctyxml(self): try: - logging.info("Downloading Clublog cty.xml...") + logging.info("Downloading Clublog cty.xml.gz...") response = self.CLUBLOG_CTY_XML_CACHE.get("https://cdn.clublog.org/cty.php?api=" + self.CLUBLOG_API_KEY, headers=HTTP_HEADERS) + logging.info("Caching Clublog cty.xml.gz...") open(self.CLUBLOG_XML_DOWNLOAD_LOCATION + ".gz", 'wb').write(response.content) with gzip.open(self.CLUBLOG_XML_DOWNLOAD_LOCATION + ".gz", "rb") as uncompressed: file_content = uncompressed.read() + logging.info("Caching Clublog cty.xml...") with open(self.CLUBLOG_XML_DOWNLOAD_LOCATION, "wb") as f: f.write(file_content) f.flush() diff --git a/core/sig_utils.py b/core/sig_utils.py index f3f1260..e62433c 100644 --- a/core/sig_utils.py +++ b/core/sig_utils.py @@ -135,6 +135,10 @@ def populate_sig_ref_info(sig_ref): sig_ref.latitude = ll[0] sig_ref.longitude = ll[1] break + elif sig.upper() == "WWTOTA": + if not sig_ref.name: + sig_ref.name = sig_ref.id + sig_ref.url = "https://wwtota.com/seznam/karta_rozhledny.php?ref=" + sig_ref.name elif sig.upper() == "WAB" or sig.upper() == "WAI": ll = wab_wai_square_to_lat_lon(ref_id) if ll: diff --git a/spotproviders/wwtota.py b/spotproviders/wwtota.py index 177f4ef..e4486e9 100644 --- a/spotproviders/wwtota.py +++ b/spotproviders/wwtota.py @@ -1,5 +1,6 @@ from datetime import datetime +import json import pytz from data.sig_ref import SIGRef @@ -17,23 +18,24 @@ class WWTOTA(HTTPSpotProvider): def http_response_to_spots(self, http_response): new_spots = [] + response_fixed = http_response.text.replace("\\/", "/") + response_json = json.loads(response_fixed) + # Iterate through source data - for source_spot in http_response.json()["spots"]: - print(source_spot) # todo + for source_spot in response_json["spots"]: # Convert to our spot format - # spot = Spot(source=self.name, - # source_id=source_spot["spotId"], - # dx_call=source_spot["activator"].upper(), - # de_call=source_spot["spotter"].upper(), - # freq=float(source_spot["frequency"]) * 1000, - # mode=source_spot["mode"].upper(), - # comment=source_spot["comments"], - # sig="WWTOTA", - # sig_refs=[SIGRef(id=source_spot["reference"], sig="POTA", name=source_spot["name"])], - # time=datetime.strptime(source_spot["spotTime"], "%Y-%m-%dT%H:%M:%S").replace( - # tzinfo=pytz.UTC).timestamp()) - # - # # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do - # # that for us. - # new_spots.append(spot) + likely_freq = float(source_spot["freq"]) * 1000 + if likely_freq < 1000000: + likely_freq = likely_freq * 1000 + spot = Spot(source=self.name, + dx_call=source_spot["call"].upper(), + freq=likely_freq, + comment=source_spot["comment"], + sig="WWTOTA", + sig_refs=[SIGRef(id=source_spot["ref"], sig="WWTOTA")], + time=datetime.strptime(response_json["updated"][:10] + source_spot["time"], "%Y-%m-%d%H:%M").timestamp()) + + # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do + # that for us. + new_spots.append(spot) return new_spots \ No newline at end of file