mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 16:59:25 +00:00
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
from datetime import datetime
|
|
|
|
import pytz
|
|
|
|
from data.spot import Spot
|
|
from providers.http_provider import HTTPProvider
|
|
|
|
|
|
# Provider for Worldwide Flora & Fauna
|
|
class WWFF(HTTPProvider):
|
|
POLL_INTERVAL_SEC = 120
|
|
SPOTS_URL = "https://spots.wwff.co/static/spots.json"
|
|
|
|
def __init__(self):
|
|
super().__init__(self.SPOTS_URL, self.POLL_INTERVAL_SEC)
|
|
|
|
def name(self):
|
|
return "WWFF"
|
|
|
|
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["activator"].upper(),
|
|
de_call=source_spot["spotter"].upper(),
|
|
freq=float(source_spot["frequency_khz"]),
|
|
mode=source_spot["mode"].upper(),
|
|
comment=source_spot["remarks"],
|
|
sig="WWFF",
|
|
sig_refs=[source_spot["reference"]],
|
|
sig_refs_names=[source_spot["reference_name"]],
|
|
time=datetime.fromtimestamp(source_spot["spot_time"]).replace(tzinfo=pytz.UTC),
|
|
latitude=source_spot["latitude"],
|
|
longitude=source_spot["longitude"])
|
|
# Fill in any missing data
|
|
spot.infer_missing()
|
|
# 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 |