mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-12-13 07:33:39 +00:00
44 lines
2.1 KiB
Python
44 lines
2.1 KiB
Python
from datetime import datetime
|
|
|
|
from data.sig_ref import SIGRef
|
|
from data.spot import Spot
|
|
from spotproviders.http_spot_provider import HTTPSpotProvider
|
|
|
|
|
|
# Spot provider for servers based on the "xOTA" software at https://github.com/nischu/xOTA/
|
|
# The provider typically doesn't give us a lat/lon or SIG explicitly, so our own config provides this information. This
|
|
# functionality is implemented for TOTA events.
|
|
class XOTA(HTTPSpotProvider):
|
|
POLL_INTERVAL_SEC = 300
|
|
FIXED_LATITUDE = None
|
|
FIXED_LONGITUDE = None
|
|
SIG = None
|
|
|
|
def __init__(self, provider_config):
|
|
super().__init__(provider_config, provider_config["url"] + "/api/spot/all", self.POLL_INTERVAL_SEC)
|
|
self.FIXED_LATITUDE = provider_config["latitude"] if "latitude" in provider_config else None
|
|
self.FIXED_LONGITUDE = provider_config["longitude"] if "longitude" in provider_config else None
|
|
self.SIG = provider_config["sig"] if "sig" in provider_config else None
|
|
|
|
def http_response_to_spots(self, http_response):
|
|
new_spots = []
|
|
# Iterate through source data
|
|
for source_spot in http_response.json():
|
|
# Convert to our spot format
|
|
spot = Spot(source=self.name,
|
|
source_id=source_spot["id"],
|
|
dx_call=source_spot["stationCallSign"].upper(),
|
|
freq=float(source_spot["freq"]) * 1000,
|
|
mode=source_spot["mode"].upper(),
|
|
sig=self.SIG,
|
|
sig_refs=[SIGRef(id=source_spot["reference"]["title"], sig=self.SIG, url=source_spot["reference"]["website"])],
|
|
time=datetime.fromisoformat(source_spot["modificationDate"]).timestamp(),
|
|
dx_latitude=self.FIXED_LATITUDE,
|
|
dx_longitude=self.FIXED_LONGITUDE,
|
|
qrt=source_spot["state"] != "active")
|
|
|
|
# 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
|