SOTA & WWFF alert providers #17

This commit is contained in:
Ian Renton
2025-10-07 21:03:15 +01:00
parent 73ef0c7621
commit 3c70da4d33
6 changed files with 103 additions and 8 deletions

37
alertproviders/sota.py Normal file
View File

@@ -0,0 +1,37 @@
from datetime import datetime
import pytz
from alertproviders.http_alert_provider import HTTPAlertProvider
from data.alert import Alert
# Alert provider for Summits on the Air
class SOTA(HTTPAlertProvider):
POLL_INTERVAL_SEC = 3600
ALERTS_URL = "https://api-db2.sota.org.uk/api/alerts/365/all/all"
def __init__(self, provider_config):
super().__init__(provider_config, self.ALERTS_URL, self.POLL_INTERVAL_SEC)
def http_response_to_alerts(self, http_response):
new_alerts = []
# Iterate through source data
for source_alert in http_response.json():
# Convert to our alert format
alert = Alert(source=self.name,
source_id=source_alert["id"],
dx_call=source_alert["activatingCallsign"].upper(),
dx_name=source_alert["activatorName"].upper(),
freqs_modes=source_alert["frequency"],
comment=source_alert["comments"],
sig="SOTA",
sig_refs=[source_alert["associationCode"] + "/" + source_alert["summitCode"]],
sig_refs_names=[source_alert["summitDetails"]],
icon="mountain-sun",
start_time=datetime.strptime(source_alert["dateActivated"],
"%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=pytz.UTC).timestamp())
# Add to our list
new_alerts.append(alert)
return new_alerts

37
alertproviders/wwff.py Normal file
View File

@@ -0,0 +1,37 @@
from datetime import datetime
import pytz
from alertproviders.http_alert_provider import HTTPAlertProvider
from data.alert import Alert
# Alert provider for Worldwide Flora and Fauna
class WWFF(HTTPAlertProvider):
POLL_INTERVAL_SEC = 3600
ALERTS_URL = "https://spots.wwff.co/static/agendas.json"
def __init__(self, provider_config):
super().__init__(provider_config, self.ALERTS_URL, self.POLL_INTERVAL_SEC)
def http_response_to_alerts(self, http_response):
new_alerts = []
# Iterate through source data
for source_alert in http_response.json():
# Convert to our alert format
alert = Alert(source=self.name,
source_id=source_alert["id"],
dx_call=source_alert["activator_call"].upper(),
freqs_modes=source_alert["band"] + " " + source_alert["mode"],
comment=source_alert["remarks"],
sig="WWFF",
sig_refs=[source_alert["reference"]],
icon="seedling",
start_time=datetime.strptime(source_alert["utc_start"],
"%Y-%m-%d %H:%M:%S").replace(tzinfo=pytz.UTC).timestamp(),
end_time=datetime.strptime(source_alert["utc_end"],
"%Y-%m-%d %H:%M:%S").replace(tzinfo=pytz.UTC).timestamp())
# Add to our list
new_alerts.append(alert)
return new_alerts