mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-02-04 09:14:30 +00:00
39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
from datetime import datetime
|
|
|
|
import pytz
|
|
|
|
from data.sig_ref import SIGRef
|
|
from data.spot import Spot
|
|
from spotproviders.http_spot_provider import HTTPSpotProvider
|
|
|
|
|
|
# Spot provider for Towers on the Air
|
|
class WWTOTA(HTTPSpotProvider):
|
|
POLL_INTERVAL_SEC = 120
|
|
SPOTS_URL = "https://wwtota.com/api/cluster_live.php"
|
|
|
|
def __init__(self, provider_config):
|
|
super().__init__(provider_config, self.SPOTS_URL, self.POLL_INTERVAL_SEC)
|
|
|
|
def http_response_to_spots(self, http_response):
|
|
new_spots = []
|
|
# Iterate through source data
|
|
for source_spot in http_response.json()["spots"]:
|
|
print(source_spot) # todo
|
|
# 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)
|
|
return new_spots |