mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Compare commits
18 Commits
bdd31f6993
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ea782579b | ||
|
|
8b036ddb46 | ||
|
|
3f827c597b | ||
|
|
587d3b4cf1 | ||
|
|
6eb1bd5ef1 | ||
|
|
0ead59a985 | ||
|
|
82b3c262b6 | ||
|
|
80b5077496 | ||
|
|
3625998f46 | ||
|
|
e31c750b41 | ||
|
|
ab05824c5d | ||
|
|
bb7b6d6f3c | ||
|
|
2c8d18685c | ||
|
|
090310240f | ||
|
|
f2f03b135f | ||
|
|
5d4b3d500d | ||
|
|
65d83d2339 | ||
|
|
5093a8d3d1 |
@@ -49,7 +49,8 @@ class ParksNPeaks(HTTPAlertProvider):
|
||||
logging.warn("PNP alert found with sig " + alert.sig + ", developer needs to add support for this!")
|
||||
|
||||
# If this is POTA, SOTA or WWFF data we already have it through other means, so ignore. Otherwise, add to
|
||||
# the alert list.
|
||||
# the alert list. Note that while ZLOTA has its own spots API, it doesn't have its own alerts API. So that
|
||||
# means the PnP *spot* provider rejects ZLOTA spots here, but the PnP *alerts* provider here allows ZLOTA.
|
||||
if alert.sig not in ["POTA", "SOTA", "WWFF"]:
|
||||
new_alerts.append(alert)
|
||||
return new_alerts
|
||||
|
||||
64
alertproviders/wota.py
Normal file
64
alertproviders/wota.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from datetime import datetime
|
||||
|
||||
import pytz
|
||||
from rss_parser import RSSParser
|
||||
|
||||
from alertproviders.http_alert_provider import HTTPAlertProvider
|
||||
from core.sig_utils import get_icon_for_sig
|
||||
from data.alert import Alert
|
||||
|
||||
|
||||
# Alert provider for Wainwrights on the Air
|
||||
class WOTA(HTTPAlertProvider):
|
||||
POLL_INTERVAL_SEC = 3600
|
||||
ALERTS_URL = "https://www.wota.org.uk/alerts_rss.php"
|
||||
RSS_DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S %z"
|
||||
|
||||
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 = []
|
||||
rss = RSSParser.parse(http_response.content.decode())
|
||||
# Iterate through source data
|
||||
for source_alert in rss.channel.items:
|
||||
|
||||
# Reject GUID missing or zero
|
||||
if not source_alert.guid or not source_alert.guid.content or source_alert.guid.content == "http://www.wota.org.uk/alerts/0":
|
||||
continue
|
||||
|
||||
# Pick apart the title
|
||||
title_split = source_alert.title.split(" on ")
|
||||
dx_call = title_split[0]
|
||||
ref = None
|
||||
ref_name = None
|
||||
if len(title_split) > 1:
|
||||
ref_split = title_split[1].split(" - ")
|
||||
ref = ref_split[0]
|
||||
if len(ref_split) > 1:
|
||||
ref_name = ref_split[1]
|
||||
|
||||
# Pick apart the description
|
||||
desc_split = source_alert.description.split(". ")
|
||||
freqs_modes = desc_split[0].replace("Frequencies/modes:", "").strip()
|
||||
comment = None
|
||||
if len(desc_split) > 1:
|
||||
comment = desc_split[1].strip()
|
||||
|
||||
time = datetime.strptime(source_alert.pub_date.content, self.RSS_DATE_TIME_FORMAT).astimezone(pytz.UTC)
|
||||
|
||||
# Convert to our alert format
|
||||
alert = Alert(source=self.name,
|
||||
source_id=source_alert.guid.content,
|
||||
dx_calls=[dx_call],
|
||||
freqs_modes=freqs_modes,
|
||||
comment=comment,
|
||||
sig="WOTA",
|
||||
sig_refs=[ref] if ref else [],
|
||||
sig_refs_names=[ref_name] if ref_name else [],
|
||||
icon=get_icon_for_sig("WOTA"),
|
||||
start_time=time.timestamp())
|
||||
|
||||
# Add to our list.
|
||||
new_alerts.append(alert)
|
||||
return new_alerts
|
||||
@@ -41,6 +41,14 @@ spot-providers:
|
||||
class: "ParksNPeaks"
|
||||
name: "ParksNPeaks"
|
||||
enabled: true
|
||||
-
|
||||
class: "ZLOTA"
|
||||
name: "ZLOTA"
|
||||
enabled: true
|
||||
-
|
||||
class: "WOTA"
|
||||
name: "WOTA"
|
||||
enabled: true
|
||||
-
|
||||
class: "APRSIS"
|
||||
name: "APRS-IS"
|
||||
@@ -88,6 +96,10 @@ alert-providers:
|
||||
class: "ParksNPeaks"
|
||||
name: "ParksNPeaks"
|
||||
enabled: true
|
||||
-
|
||||
class: "WOTA"
|
||||
name: "WOTA"
|
||||
enabled: true
|
||||
-
|
||||
class: "NG3K"
|
||||
name: "NG3K"
|
||||
|
||||
@@ -26,13 +26,14 @@ SIGS = [
|
||||
SIG(name="ZLOTA", description="New Zealand on the Air", icon="kiwi-bird", ref_regex=r"ZL[A-Z]/[A-Z]{2}\-\d+"),
|
||||
SIG(name="KRMNPA", description="Keith Roget Memorial National Parks Award", icon="earth-oceania", ref_regex=r""),
|
||||
SIG(name="WAB", description="Worked All Britain", icon="table-cells-large", ref_regex=r"[A-Z]{1,2}[0-9]{2}"),
|
||||
SIG(name="WAI", description="Worked All Ireland", icon="table-cells-large", ref_regex=r"[A-Z][0-9]{2}")
|
||||
SIG(name="WAI", description="Worked All Ireland", icon="table-cells-large", ref_regex=r"[A-Z][0-9]{2}"),
|
||||
SIG(name="WOTA", description="Wainwrights on the Air", icon="w", ref_regex=r"[A-Z]{3}-[0-9]{2}")
|
||||
]
|
||||
|
||||
# Modes. Note "DIGI" and "DIGITAL" are also supported but are normalised into "DATA".
|
||||
CW_MODES = ["CW"]
|
||||
PHONE_MODES = ["PHONE", "SSB", "USB", "LSB", "AM", "FM", "DV", "DMR", "DSTAR", "C4FM", "M17"]
|
||||
DATA_MODES = ["DATA", "FT8", "FT4", "RTTY", "SSTV", "JS8", "HELL", "BPSK", "PSK", "PSK31", "BPSK31", "OLIVIA", "MFSK", "MFSK32"]
|
||||
DATA_MODES = ["DATA", "FT8", "FT4", "RTTY", "SSTV", "JS8", "HELL", "BPSK", "PSK", "PSK31", "BPSK31", "OLIVIA", "MFSK", "MFSK32", "PKT"]
|
||||
ALL_MODES = CW_MODES + PHONE_MODES + DATA_MODES
|
||||
MODE_TYPES = ["CW", "PHONE", "DATA"]
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import logging
|
||||
from datetime import timedelta
|
||||
|
||||
from diskcache import Cache
|
||||
from pyhamtools import LookupLib, Callinfo
|
||||
from pyhamtools import LookupLib, Callinfo, callinfo
|
||||
from pyhamtools.exceptions import APIKeyMissingError
|
||||
from pyhamtools.frequency import freq_to_band
|
||||
from pyhamtools.locator import latlong_to_locator
|
||||
@@ -266,14 +266,19 @@ class LookupHelper:
|
||||
# Utility method to get QRZ.com data from cache if possible, if not get it from the API and cache it
|
||||
def get_qrz_data_for_callsign(self, call):
|
||||
# Fetch from cache if we can, otherwise fetch from the API and cache it
|
||||
qrz_data = self.QRZ_CALLSIGN_DATA_CACHE.get(call)
|
||||
if qrz_data:
|
||||
return qrz_data
|
||||
if call in self.QRZ_CALLSIGN_DATA_CACHE:
|
||||
return self.QRZ_CALLSIGN_DATA_CACHE.get(call)
|
||||
elif self.QRZ_AVAILABLE:
|
||||
try:
|
||||
data = self.LOOKUP_LIB_QRZ.lookup_callsign(callsign=call)
|
||||
self.QRZ_CALLSIGN_DATA_CACHE.add(call, data, expire=604800) # 1 week in seconds
|
||||
return data
|
||||
except KeyError:
|
||||
# QRZ had no info for the call, but maybe it had prefixes or suffixes. Try again with the base call.
|
||||
try:
|
||||
data = self.LOOKUP_LIB_QRZ.lookup_callsign(callsign=callinfo.Callinfo.get_homecall(call))
|
||||
self.QRZ_CALLSIGN_DATA_CACHE.add(call, data, expire=604800) # 1 week in seconds
|
||||
return data
|
||||
except KeyError:
|
||||
# QRZ had no info for the call, that's OK. Cache a None so we don't try to look this up again
|
||||
self.QRZ_CALLSIGN_DATA_CACHE.add(call, None, expire=604800) # 1 week in seconds
|
||||
@@ -284,14 +289,19 @@ class LookupHelper:
|
||||
# Utility method to get Clublog API data from cache if possible, if not get it from the API and cache it
|
||||
def get_clublog_api_data_for_callsign(self, call):
|
||||
# Fetch from cache if we can, otherwise fetch from the API and cache it
|
||||
clublog_data = self.CLUBLOG_CALLSIGN_DATA_CACHE.get(call)
|
||||
if clublog_data:
|
||||
return clublog_data
|
||||
if call in self.CLUBLOG_CALLSIGN_DATA_CACHE:
|
||||
return self.CLUBLOG_CALLSIGN_DATA_CACHE.get(call)
|
||||
elif self.CLUBLOG_API_AVAILABLE:
|
||||
try:
|
||||
data = self.LOOKUP_LIB_CLUBLOG_API.lookup_callsign(callsign=call)
|
||||
self.CLUBLOG_CALLSIGN_DATA_CACHE.add(call, data, expire=604800) # 1 week in seconds
|
||||
return data
|
||||
except KeyError:
|
||||
# Clublog had no info for the call, but maybe it had prefixes or suffixes. Try again with the base call.
|
||||
try:
|
||||
data = self.LOOKUP_LIB_CLUBLOG_API.lookup_callsign(callsign=callinfo.Callinfo.get_homecall(call))
|
||||
self.CLUBLOG_CALLSIGN_DATA_CACHE.add(call, data, expire=604800) # 1 week in seconds
|
||||
return data
|
||||
except KeyError:
|
||||
# Clublog had no info for the call, that's OK. Cache a None so we don't try to look this up again
|
||||
self.CLUBLOG_CALLSIGN_DATA_CACHE.add(call, None, expire=604800) # 1 week in seconds
|
||||
|
||||
@@ -111,11 +111,6 @@ class Alert:
|
||||
if self.dx_calls and not self.dx_names:
|
||||
self.dx_names = list(map(lambda c: lookup_helper.infer_name_from_callsign(c), self.dx_calls))
|
||||
|
||||
# Clean up comments
|
||||
if self.comment:
|
||||
comment = re.sub(r"\(de [A-Za-z0-9]*\)", "", self.comment)
|
||||
self.comment = comment.strip()
|
||||
|
||||
# Always create an ID based on a hash of every parameter *except* received_time. This is used as the index
|
||||
# to a map, which as a byproduct avoids us having multiple duplicate copies of the object that are identical
|
||||
# apart from that they were retrieved from the API at different times. Note that the simple Python hash()
|
||||
|
||||
26
data/spot.py
26
data/spot.py
@@ -177,6 +177,20 @@ class Spot:
|
||||
if self.de_call and "-" in self.de_call:
|
||||
self.de_call = self.de_call.split("-")[0]
|
||||
|
||||
# If we have a spotter of "RBNHOLE", we should have the actual spotter callsign in the comment, so extract it.
|
||||
# RBNHole posts come from a number of providers, so it's dealt with here in the generic spot handling code.
|
||||
if self.de_call == "RBNHOLE" and self.comment:
|
||||
rbnhole_call_match = re.search(r"\Wat ([a-z0-9/]+)\W", self.comment, re.IGNORECASE)
|
||||
if rbnhole_call_match:
|
||||
self.de_call = rbnhole_call_match.group(1).upper()
|
||||
|
||||
# If we have a spotter of "SOTAMAT", we might have the actual spotter callsign in the comment, if so extract it.
|
||||
# SOTAMAT can do POTA as well as SOTA, so it's dealt with here in the generic spot handling code.
|
||||
if self.de_call == "SOTAMAT" and self.comment:
|
||||
sotamat_call_match = re.search(r"\Wfrom ([a-z0-9/]+)]", self.comment, re.IGNORECASE)
|
||||
if sotamat_call_match:
|
||||
self.de_call = sotamat_call_match.group(1).upper()
|
||||
|
||||
# Spotter country, continent, zones etc. from callsign.
|
||||
# DE of "RBNHOLE" and "SOTAMAT" are not things we can look up location for
|
||||
if self.de_call != "RBNHOLE" and self.de_call != "SOTAMAT":
|
||||
@@ -249,14 +263,6 @@ class Spot:
|
||||
if self.comment and not self.qrt:
|
||||
self.qrt = "QRT" in self.comment.upper()
|
||||
|
||||
# Clean up comments
|
||||
if self.comment:
|
||||
comment = re.sub(r"\(de [A-Za-z0-9]*\)", "", self.comment)
|
||||
comment = re.sub(r"\[.*]:", "", comment)
|
||||
comment = re.sub(r"\[.*]", "", comment)
|
||||
comment = re.sub(r"\"\"", "", comment)
|
||||
self.comment = comment.strip()
|
||||
|
||||
# DX operator details lookup, using QRZ.com. This should be the last resort compared to taking the data from
|
||||
# the actual spotting service, e.g. we don't want to accidentally use a user's QRZ.com home lat/lon instead of
|
||||
# the one from the park reference they're at.
|
||||
@@ -284,8 +290,8 @@ class Spot:
|
||||
self.dx_location_good = self.dx_location_source == "SPOT" or self.dx_location_source == "WAB/WAI GRID" or (
|
||||
self.dx_location_source == "QRZ" and not "/" in self.dx_call)
|
||||
|
||||
# DE of "RBNHOLE", "SOTAMAT" and "ZLOTA" are not things we can look up location for
|
||||
if self.de_call != "RBNHOLE" and self.de_call != "SOTAMAT" and self.de_call != "ZLOTA":
|
||||
# DE of "RBNHOLE" and "SOTAMAT" are not things we can look up location for
|
||||
if self.de_call != "RBNHOLE" and self.de_call != "SOTAMAT":
|
||||
# DE operator position lookup, using QRZ.com.
|
||||
if self.de_call and not self.de_latitude:
|
||||
latlon = lookup_helper.infer_latlon_from_callsign_qrz(self.de_call)
|
||||
|
||||
@@ -19,9 +19,9 @@ class DXCluster(SpotProvider):
|
||||
# Note the callsign pattern deliberately excludes calls ending in "-#", which are from RBN and can be enabled by
|
||||
# default on some clusters. If you want RBN spots, there is a separate provider for that.
|
||||
CALLSIGN_PATTERN = "([a-z|0-9|/]+)"
|
||||
FREQUENCY_PATTERM = "([0-9|.]+)"
|
||||
FREQUENCY_PATTERN = "([0-9|.]+)"
|
||||
LINE_PATTERN = re.compile(
|
||||
"^DX de " + CALLSIGN_PATTERN + ":\\s+" + FREQUENCY_PATTERM + "\\s+" + CALLSIGN_PATTERN + "\\s+(.*)\\s+(\\d{4}Z)",
|
||||
"^DX de " + CALLSIGN_PATTERN + ":\\s+" + FREQUENCY_PATTERN + "\\s+" + CALLSIGN_PATTERN + "\\s+(.*)\\s+(\\d{4}Z)",
|
||||
re.IGNORECASE)
|
||||
|
||||
# Constructor requires hostname and port
|
||||
|
||||
@@ -19,9 +19,6 @@ class ParksNPeaks(HTTPSpotProvider):
|
||||
SIOTA_LIST_URL = "https://www.silosontheair.com/data/silos.csv"
|
||||
SIOTA_LIST_CACHE_TIME_DAYS = 30
|
||||
SIOTA_LIST_CACHE = CachedSession("cache/siota_data_cache", expire_after=timedelta(days=SIOTA_LIST_CACHE_TIME_DAYS))
|
||||
ZLOTA_LIST_URL = "https://ontheair.nz/assets/assets.json"
|
||||
ZLOTA_LIST_CACHE_TIME_DAYS = 30
|
||||
ZLOTA_LIST_CACHE = CachedSession("cache/zlota_data_cache", expire_after=timedelta(days=ZLOTA_LIST_CACHE_TIME_DAYS))
|
||||
|
||||
def __init__(self, provider_config):
|
||||
super().__init__(provider_config, self.SPOTS_URL, self.POLL_INTERVAL_SEC)
|
||||
@@ -52,7 +49,7 @@ class ParksNPeaks(HTTPSpotProvider):
|
||||
|
||||
# Extract a de_call if it's in the comment but not in the "actSpoter" field
|
||||
m = re.search(r"\(de ([A-Za-z0-9]*)\)", spot.comment)
|
||||
if (not spot.de_call or spot.de_call == "ZLOTA") and m:
|
||||
if not spot.de_call and m:
|
||||
spot.de_call = m.group(1)
|
||||
|
||||
# Log a warning for the developer if PnP gives us an unknown programme we've never seen before
|
||||
@@ -70,20 +67,10 @@ class ParksNPeaks(HTTPSpotProvider):
|
||||
spot.dx_grid = row["LOCATOR"]
|
||||
break
|
||||
|
||||
# ZLOTA name/lat/lon lookup
|
||||
if spot.sig == "ZLOTA":
|
||||
zlota_data = self.ZLOTA_LIST_CACHE.get(self.ZLOTA_LIST_URL, headers=HTTP_HEADERS).json()
|
||||
for asset in zlota_data:
|
||||
if asset["code"] == spot.sig_refs[0]:
|
||||
spot.sig_refs_names = [asset["name"]]
|
||||
spot.dx_latitude = asset["y"]
|
||||
spot.dx_longitude = asset["x"]
|
||||
break
|
||||
|
||||
# Note there is currently no support for KRMNPA location lookup, see issue #61.
|
||||
|
||||
# If this is POTA, SOTA or WWFF data we already have it through other means, so ignore. Otherwise, add to
|
||||
# the spot list.
|
||||
if spot.sig not in ["POTA", "SOTA", "WWFF"]:
|
||||
# If this is POTA, SOTA, WWFF or ZLOTA data we already have it through other means, so ignore. Otherwise,
|
||||
# add to the spot list.
|
||||
if spot.sig not in ["POTA", "SOTA", "WWFF", "ZLOTA"]:
|
||||
new_spots.append(spot)
|
||||
return new_spots
|
||||
|
||||
88
spotproviders/wota.py
Normal file
88
spotproviders/wota.py
Normal file
@@ -0,0 +1,88 @@
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
import pytz
|
||||
from requests_cache import CachedSession
|
||||
from rss_parser import RSSParser
|
||||
|
||||
from core.constants import HTTP_HEADERS
|
||||
from core.sig_utils import get_icon_for_sig
|
||||
from data.spot import Spot
|
||||
from spotproviders.http_spot_provider import HTTPSpotProvider
|
||||
|
||||
|
||||
# Spot provider for Wainwrights on the Air
|
||||
class WOTA(HTTPSpotProvider):
|
||||
POLL_INTERVAL_SEC = 120
|
||||
SPOTS_URL = "https://www.wota.org.uk/spots_rss.php"
|
||||
LIST_URL = "https://www.wota.org.uk/mapping/data/summits.json"
|
||||
LIST_CACHE_TIME_DAYS = 30
|
||||
LIST_CACHE = CachedSession("cache/wota_data_cache", expire_after=timedelta(days=LIST_CACHE_TIME_DAYS))
|
||||
RSS_DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S %z"
|
||||
|
||||
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 = []
|
||||
rss = RSSParser.parse(http_response.content.decode())
|
||||
# Iterate through source data
|
||||
for source_spot in rss.channel.items:
|
||||
|
||||
# Reject GUID missing or zero
|
||||
if not source_spot.guid or not source_spot.guid.content or source_spot.guid.content == "http://www.wota.org.uk/spots/0":
|
||||
continue
|
||||
|
||||
# Pick apart the title
|
||||
title_split = source_spot.title.split(" on ")
|
||||
dx_call = title_split[0]
|
||||
ref = None
|
||||
ref_name = None
|
||||
if len(title_split) > 1:
|
||||
ref_split = title_split[1].split(" - ")
|
||||
ref = ref_split[0]
|
||||
if len(ref_split) > 1:
|
||||
ref_name = ref_split[1]
|
||||
|
||||
# Pick apart the description
|
||||
desc_split = source_spot.description.split(". ")
|
||||
freq_mode = desc_split[0].replace("Frequencies/modes:", "").strip()
|
||||
freq_mode_split = freq_mode.split("-")
|
||||
freq_hz = float(freq_mode_split[0]) * 1000000
|
||||
mode = freq_mode_split[1]
|
||||
|
||||
comment = None
|
||||
if len(desc_split) > 1:
|
||||
comment = desc_split[1].strip()
|
||||
spotter = None
|
||||
if len(desc_split) > 2:
|
||||
spotter = desc_split[2].replace("Spotted by ", "").replace(".", "").strip()
|
||||
|
||||
time = datetime.strptime(source_spot.pub_date.content, self.RSS_DATE_TIME_FORMAT).astimezone(pytz.UTC)
|
||||
|
||||
# Convert to our spot format
|
||||
spot = Spot(source=self.name,
|
||||
source_id=source_spot.guid.content,
|
||||
dx_call=dx_call,
|
||||
de_call=spotter,
|
||||
freq=freq_hz,
|
||||
mode=mode,
|
||||
comment=comment,
|
||||
sig="WOTA",
|
||||
sig_refs=[ref] if ref else [],
|
||||
sig_refs_names=[ref_name] if ref_name else [],
|
||||
sig_refs_urls="https://www.wota.org.uk/MM_" + ref if ref else [],
|
||||
icon=get_icon_for_sig("WOTA"),
|
||||
time=time.timestamp())
|
||||
|
||||
# WOTA name/lat/lon lookup
|
||||
wota_data = self.LIST_CACHE.get(self.LIST_URL, headers=HTTP_HEADERS).json()
|
||||
for feature in wota_data["features"]:
|
||||
if feature["properties"]["wotaId"] == spot.sig_refs[0]:
|
||||
spot.sig_refs_names = [feature["properties"]["title"]]
|
||||
spot.dx_latitude = feature["geometry"]["coordinates"][1]
|
||||
spot.dx_longitude = feature["geometry"]["coordinates"][0]
|
||||
spot.dx_grid = feature["properties"]["qthLocator"]
|
||||
break
|
||||
|
||||
new_spots.append(spot)
|
||||
return new_spots
|
||||
59
spotproviders/zlota.py
Normal file
59
spotproviders/zlota.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import csv
|
||||
import logging
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytz
|
||||
from requests_cache import CachedSession
|
||||
|
||||
from core.constants import HTTP_HEADERS
|
||||
from core.sig_utils import get_icon_for_sig
|
||||
from data.spot import Spot
|
||||
from spotproviders.http_spot_provider import HTTPSpotProvider
|
||||
|
||||
|
||||
# Spot provider for ZLOTA
|
||||
class ZLOTA(HTTPSpotProvider):
|
||||
POLL_INTERVAL_SEC = 120
|
||||
SPOTS_URL = "https://ontheair.nz/api/spots?zlota_only=true"
|
||||
LIST_URL = "https://ontheair.nz/assets/assets.json"
|
||||
LIST_CACHE_TIME_DAYS = 30
|
||||
LIST_CACHE = CachedSession("cache/zlota_data_cache", expire_after=timedelta(days=LIST_CACHE_TIME_DAYS))
|
||||
|
||||
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():
|
||||
# Frequency is often inconsistent as to whether it's in Hz or kHz. Make a guess.
|
||||
freq_hz = float(source_spot["frequency"])
|
||||
if freq_hz < 1000000:
|
||||
freq_hz = freq_hz * 1000
|
||||
|
||||
# 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=freq_hz,
|
||||
mode=source_spot["mode"].upper().strip(),
|
||||
comment=source_spot["comments"],
|
||||
sig="ZLOTA",
|
||||
sig_refs=[source_spot["reference"]],
|
||||
sig_refs_names=[source_spot["name"]],
|
||||
icon=get_icon_for_sig("ZLOTA"),
|
||||
time=datetime.fromisoformat(source_spot["referenced_time"]).astimezone(pytz.UTC).timestamp())
|
||||
|
||||
# ZLOTA name/lat/lon lookup
|
||||
zlota_data = self.LIST_CACHE.get(self.LIST_URL, headers=HTTP_HEADERS).json()
|
||||
for asset in zlota_data:
|
||||
if asset["code"] == spot.sig_refs[0]:
|
||||
spot.sig_refs_names = [asset["name"]]
|
||||
spot.dx_latitude = asset["y"]
|
||||
spot.dx_longitude = asset["x"]
|
||||
break
|
||||
|
||||
new_spots.append(spot)
|
||||
return new_spots
|
||||
@@ -31,6 +31,7 @@
|
||||
<link href="/fa/css/solid.min.css" rel="stylesheet" />
|
||||
|
||||
<link rel="icon" type="image/png" href="/img/icon-512.png">
|
||||
<link rel="apple-touch-icon" href="img/icon-512-pwa.png">
|
||||
<link rel="alternate icon" type="image/png" href="/img/icon-192.png">
|
||||
<link rel="alternate icon" type="image/png" href="/img/icon-32.png">
|
||||
<link rel="alternate icon" type="image/png" href="/img/icon-16.png">
|
||||
|
||||
@@ -1016,4 +1016,4 @@ components:
|
||||
ref_regex:
|
||||
type: string
|
||||
description: Regex that matches this SIG's reference IDs. Generally for Spothole's own internal use, clients probably won't need this.
|
||||
example: "[A-Z]{2}\-\d+"
|
||||
example: "[A-Z]{2}\\-\\d+"
|
||||
@@ -124,16 +124,12 @@ function addAlertRowsToTable(tbody, alerts) {
|
||||
var showRef = $("#tableShowRef")[0].checked;
|
||||
|
||||
// Get times for the alert, and convert to local time if necessary.
|
||||
var start_time_unix = moment.unix(a["start_time"]);
|
||||
var start_time = start_time_unix.utc();
|
||||
if (useLocalTime) {
|
||||
start_time = start_time.local();
|
||||
}
|
||||
var end_time_unix = moment.unix(a["end_time"]);
|
||||
var end_time = end_time_unix.utc();
|
||||
if (useLocalTime) {
|
||||
end_time = end_time.local();
|
||||
}
|
||||
var start_time_utc = moment.unix(a["start_time"]).utc();
|
||||
var start_time_local = start_time_utc.clone().local();
|
||||
start_time = useLocalTime ? start_time_local : start_time_utc;
|
||||
var end_time_utc = moment.unix(a["end_time"]).utc();
|
||||
var end_time_local = end_time_utc.clone().local();
|
||||
end_time = useLocalTime ? end_time_local : end_time_utc;
|
||||
|
||||
// Format the times for display. Start time is displayed as e.g. 7 Oct 12:34 unless the time is in a
|
||||
// different year to the current year, in which case the year is inserted between month and hour.
|
||||
@@ -143,8 +139,8 @@ function addAlertRowsToTable(tbody, alerts) {
|
||||
// Overriding all of that, if the start time is 00:00 and the end time is 23:59 when considered in UTC, the
|
||||
// hours and minutes are stripped out from the display, as we assume the server is just giving us full days.
|
||||
// Finally, if there is no end date set, "---" is displayed.
|
||||
var whole_days = start_time_unix.utc().format("HH:mm") == "00:00" &&
|
||||
(end_time_unix != null || end_time_unix > 0 || end_time_unix.utc().format("HH:mm") == "23:59");
|
||||
var whole_days = start_time_utc.format("HH:mm") == "00:00" &&
|
||||
(end_time_utc != null || end_time_utc > 0 || end_time_utc.format("HH:mm") == "23:59");
|
||||
var hours_minutes_format = whole_days ? "" : " HH:mm";
|
||||
var start_time_formatted = start_time.format("D MMM" + hours_minutes_format);
|
||||
if (start_time.format("YYYY") != moment().format("YYYY")) {
|
||||
@@ -153,11 +149,13 @@ function addAlertRowsToTable(tbody, alerts) {
|
||||
start_time_formatted = start_time.format("[Today]" + hours_minutes_format);
|
||||
}
|
||||
var end_time_formatted = "---";
|
||||
if (end_time_unix != null && end_time_unix > 0 && end_time != null) {
|
||||
if (end_time_utc != null && end_time_utc > 0 && end_time != null) {
|
||||
var end_time_formatted = whole_days ? start_time_formatted : end_time.format("HH:mm");
|
||||
if (end_time.format("D MMM") != start_time.format("D MMM")) {
|
||||
if (end_time.format("YYYY") != moment().format("YYYY")) {
|
||||
end_time_formatted = end_time.format("D MMM YYYY" + hours_minutes_format);
|
||||
} else if (useLocalTime && end_time.format("D MMM YYYY") == moment().format("D MMM YYYY")) {
|
||||
end_time_formatted = end_time.format("[Today]" + hours_minutes_format);
|
||||
} else {
|
||||
end_time_formatted = end_time.format("D MMM" + hours_minutes_format);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ function updateTable() {
|
||||
// Format a UTC or local time for display
|
||||
var time = moment.unix(s["time"]).utc();
|
||||
if (useLocalTime) {
|
||||
time = time.local();
|
||||
time.local();
|
||||
}
|
||||
var time_formatted = time.format("HH:mm");
|
||||
|
||||
@@ -185,7 +185,7 @@ function updateTable() {
|
||||
$tr.append(`<td class='nowrap'>${time_formatted}</td>`);
|
||||
}
|
||||
if (showDX) {
|
||||
$tr.append(`<td class='nowrap'><span class='flag-wrapper hideonmobile' title='${dx_country}'>${dx_flag}</span><a class='dx-link' href='https://qrz.com/db/${s["dx_call"]}' target='_new'>${s["dx_call"]}</a></td>`);
|
||||
$tr.append(`<td class='nowrap'><span class='flag-wrapper hideonmobile' title='${dx_country}'>${dx_flag}</span><a class='dx-link' href='https://qrz.com/db/${s["dx_call"]}' target='_new' title='${s["dx_name"] != null ? s["dx_name"] : ""}'>${s["dx_call"]}</a></td>`);
|
||||
}
|
||||
if (showFreq) {
|
||||
$tr.append(`<td class='nowrap'><span class='band-bullet' title='${bandFullName}' style='color: ${s["band_color"]}'>■</span>${freq_string}</td>`);
|
||||
|
||||
Reference in New Issue
Block a user