mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Allow alerts to have more than one DX callsign, and parse the "as CALL" fields from NG3K. Not yet working #38
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
import pytz
|
||||
@@ -11,6 +12,7 @@ from data.alert import Alert
|
||||
class NG3K(HTTPAlertProvider):
|
||||
POLL_INTERVAL_SEC = 3600
|
||||
ALERTS_URL = "https://www.ng3k.com/adxo.xml"
|
||||
AS_CALL_PATTERN = re.compile("as ([a-z0-9/]+)", re.IGNORECASE)
|
||||
|
||||
def __init__(self, provider_config):
|
||||
super().__init__(provider_config, self.ALERTS_URL, self.POLL_INTERVAL_SEC)
|
||||
@@ -49,18 +51,26 @@ class NG3K(HTTPAlertProvider):
|
||||
end_timestamp = datetime.strptime(end_year + " " + end_mon + " " + end_day + " 23:59", "%Y %b %d %H:%M").replace(
|
||||
tzinfo=pytz.UTC).timestamp()
|
||||
|
||||
dx_country = parts[1]
|
||||
dx_call = parts[2]
|
||||
qsl_info = parts[3]
|
||||
# Sometimes the DX callsign is "real", sometimes you just get a prefix with the real working callsigns being
|
||||
# provided in the "by" field. e.g. call="JW", by="By LA7XK as JW7XK, LA6VM as JW6VM, LA9DL as JW9DL". So
|
||||
# if there are "as" callsigns in the "by" field, we extract them and replace the main call with them.
|
||||
# TODO this doesn't work yet, debug
|
||||
extra_parts = parts[5].split("; ")
|
||||
by = extra_parts[0]
|
||||
dx_calls = [parts[2].upper()]
|
||||
match = self.AS_CALL_PATTERN.match(by)
|
||||
if match:
|
||||
dx_calls = [x.group(1) for x in re.finditer(self.AS_CALL_PATTERN, by)]
|
||||
|
||||
dx_country = parts[1]
|
||||
qsl_info = parts[3]
|
||||
bands = extra_parts[1]
|
||||
modes = extra_parts[2] if len(extra_parts) > 3 else ""
|
||||
comment = extra_parts[-1]
|
||||
|
||||
# Convert to our alert format
|
||||
alert = Alert(source=self.name,
|
||||
dx_call=dx_call.upper(),
|
||||
dx_calls=dx_calls,
|
||||
dx_country=dx_country,
|
||||
freqs_modes=bands + (("; " + modes) if modes != "" else ""),
|
||||
comment=by + "; " + comment + "; " + qsl_info,
|
||||
|
||||
@@ -21,7 +21,7 @@ class POTA(HTTPAlertProvider):
|
||||
# Convert to our alert format
|
||||
alert = Alert(source=self.name,
|
||||
source_id=source_alert["scheduledActivitiesId"],
|
||||
dx_call=source_alert["activator"].upper(),
|
||||
dx_calls=[source_alert["activator"].upper()],
|
||||
freqs_modes=source_alert["frequencies"],
|
||||
comment=source_alert["comments"],
|
||||
sig="POTA",
|
||||
|
||||
@@ -21,7 +21,7 @@ class SOTA(HTTPAlertProvider):
|
||||
# Convert to our alert format
|
||||
alert = Alert(source=self.name,
|
||||
source_id=source_alert["id"],
|
||||
dx_call=source_alert["activatingCallsign"].upper(),
|
||||
dx_calls=[source_alert["activatingCallsign"].upper()],
|
||||
dx_name=source_alert["activatorName"].upper(),
|
||||
freqs_modes=source_alert["frequency"],
|
||||
comment=source_alert["comments"],
|
||||
|
||||
@@ -21,7 +21,7 @@ class WWFF(HTTPAlertProvider):
|
||||
# Convert to our alert format
|
||||
alert = Alert(source=self.name,
|
||||
source_id=source_alert["id"],
|
||||
dx_call=source_alert["activator_call"].upper(),
|
||||
dx_calls=[source_alert["activator_call"].upper()],
|
||||
freqs_modes=source_alert["band"] + " " + source_alert["mode"],
|
||||
comment=source_alert["remarks"],
|
||||
sig="WWFF",
|
||||
|
||||
Reference in New Issue
Block a user