Improved lookup for callsigns and display of DXpedition DXCC name on alerts page #38

This commit is contained in:
Ian Renton
2025-10-11 21:34:44 +01:00
parent 7cf6d05c4b
commit ba84b90315
4 changed files with 51 additions and 4 deletions

View File

@@ -61,6 +61,9 @@ class NG3K(HTTPAlertProvider):
if not dx_calls:
dx_calls = [parts[2].upper()]
# "Calls" of TBA, TBC or TBD are not real attempts at Turkish callsigns
dx_calls = list(filter(lambda a: a != "TBA" and a != "TBC" and a != "TBD" , dx_calls))
dx_country = parts[1]
qsl_info = parts[3]
bands = extra_parts[1]

View File

@@ -6,7 +6,7 @@ from pyhamtools.frequency import freq_to_band
from pyhamtools.locator import latlong_to_locator
from core.config import config
from core.constants import BANDS, UNKNOWN_BAND, CW_MODES, PHONE_MODES, DATA_MODES, ALL_MODES
from core.constants import BANDS, UNKNOWN_BAND, CW_MODES, PHONE_MODES, DATA_MODES, ALL_MODES, QRZCQ_CALLSIGN_LOOKUP_DATA
# Lookup helpers from pyhamtools
LOOKUP_LIB_BASIC = LookupLib(lookuptype="countryfile")
@@ -55,10 +55,16 @@ def infer_country_from_callsign(call):
country = CALL_INFO_BASIC.get_country_name(base_call)
except KeyError as e:
country = None
# Couldn't get anything from basic call info database, try QRZ.com
if not country:
qrz_data = get_qrz_data_for_callsign(call)
if qrz_data and "country" in qrz_data:
country = qrz_data["country"]
# Couldn't get anything from QRZ.com database, try QRZCQ data
if not country:
qrzcq_data = get_qrzcq_data_for_callsign(call)
if qrzcq_data and qrzcq_data["country"]:
country = qrzcq_data["country"]
return country
# Infer a DXCC ID from a callsign
@@ -73,10 +79,16 @@ def infer_dxcc_id_from_callsign(call):
dxcc = CALL_INFO_BASIC.get_adif_id(base_call)
except KeyError as e:
dxcc = None
# Couldn't get anything from basic call info database, try QRZ.com
if not dxcc:
qrz_data = get_qrz_data_for_callsign(call)
if qrz_data and "adif" in qrz_data:
dxcc = qrz_data["adif"]
# Couldn't get anything from QRZ.com database, try QRZCQ data
if not dxcc:
qrzcq_data = get_qrzcq_data_for_callsign(call)
if qrzcq_data and qrzcq_data["dxcc"]:
dxcc = qrzcq_data["dxcc"]
return dxcc
# Infer a continent shortcode from a callsign
@@ -90,6 +102,11 @@ def infer_continent_from_callsign(call):
continent = CALL_INFO_BASIC.get_continent(base_call)
except KeyError as e:
continent = None
# Couldn't get anything from basic call info database, try QRZCQ data
if not continent:
qrzcq_data = get_qrzcq_data_for_callsign(call)
if qrzcq_data and qrzcq_data["continent"]:
continent = qrzcq_data["continent"]
return continent
# Infer a CQ zone from a callsign
@@ -104,10 +121,16 @@ def infer_cq_zone_from_callsign(call):
cqz = CALL_INFO_BASIC.get_cqz(base_call)
except KeyError as e:
cqz = None
# Couldn't get anything from basic call info database, try QRZ.com
if not cqz:
qrz_data = get_qrz_data_for_callsign(call)
if qrz_data and "cqz" in qrz_data:
cqz = qrz_data["cqz"]
# Couldn't get anything from QRZ.com database, try QRZCQ data
if not cqz:
qrzcq_data = get_qrzcq_data_for_callsign(call)
if qrzcq_data and qrzcq_data["cqz"]:
cqz = qrzcq_data["cqz"]
return cqz
# Infer a ITU zone from a callsign
@@ -122,10 +145,16 @@ def infer_itu_zone_from_callsign(call):
ituz = CALL_INFO_BASIC.get_ituz(base_call)
except KeyError as e:
ituz = None
# Couldn't get anything from basic call info database, try QRZ.com
if not ituz:
qrz_data = get_qrz_data_for_callsign(call)
if qrz_data and "ituz" in qrz_data:
ituz = qrz_data["ituz"]
# Couldn't get anything from QRZ.com database, try QRZCQ data
if not ituz:
qrzcq_data = get_qrzcq_data_for_callsign(call)
if qrzcq_data and qrzcq_data["ituz"]:
ituz = qrzcq_data["ituz"]
return ituz
# Utility method to get QRZ.com data from cache if possible, if not get it from the API and cache it
@@ -145,6 +174,15 @@ def get_qrz_data_for_callsign(call):
else:
return None
# Utility method to get QRZCQ data from our constants table, if we can find it
def get_qrzcq_data_for_callsign(call):
# Iterate in reverse order - see comments on the data structure itself
for entry in reversed(QRZCQ_CALLSIGN_LOOKUP_DATA):
if call.startswith(entry["prefix"]):
print(call + " " + str(entry))
return entry
return None
# Infer an operator name from a callsign (requires QRZ.com)
def infer_name_from_callsign(call):
data = get_qrz_data_for_callsign(call)

View File

@@ -133,7 +133,7 @@ function addAlertRowsToTable(tbody, alerts) {
}
// Format DX flag
var dx_flag = "<i class='fa-solid fa-circle-question'></i>";
var dx_flag = "<i class='fa-solid fa-globe-africa'></i>";
if (a["dx_flag"] && a["dx_flag"] != null && a["dx_flag"] != "") {
dx_flag = a["dx_flag"];
}
@@ -150,6 +150,12 @@ function addAlertRowsToTable(tbody, alerts) {
dx_calls_html = a["dx_calls"].map(call => `<a class='dx-link' href='https://qrz.com/db/${call}' target='_new'>${call}</a>`).join(", ");
}
// Format DXpedition country
var dx_country_html = "";
if (a["is_dxpedition"] == true && a["dx_country"] != null && a["dx_country"] != "") {
dx_country_html = `<br/>${a["dx_country"]}`;
}
// Format freqs & modes
var freqsModesText = "";
if (a["freqs_modes"] != null) {
@@ -177,7 +183,7 @@ function addAlertRowsToTable(tbody, alerts) {
// Populate the row
$tr.append(`<td class='nowrap'>${start_time_formatted}</td>`);
$tr.append(`<td class='nowrap'>${end_time_formatted}</td>`);
$tr.append(`<td class='nowrap'><span class='flag-wrapper hideonmobile' title='${dx_country}'>${dx_flag}</span>${dx_calls_html}</td>`);
$tr.append(`<td class='nowrap'><span class='flag-wrapper hideonmobile' title='${dx_country}'>${dx_flag}</span>${dx_calls_html}${dx_country_html}</td>`);
$tr.append(`<td class='hideonmobile'>${freqsModesText}</td>`);
$tr.append(`<td class='hideonmobile'>${commentText}</td>`);
$tr.append(`<td class='nowrap hideonmobile'><span class='icon-wrapper'><i class='fa-solid fa-${a["icon"]}'></i></span> ${sigSourceText}</td>`);

View File

@@ -66,7 +66,7 @@ function updateTable() {
var time_formatted = time.format("HH:mm");
// Format DX flag
var dx_flag = "<i class='fa-solid fa-circle-question'></i>";
var dx_flag = "<i class='fa-solid fa-globe-africa'></i>";
if (s["dx_flag"] && s["dx_flag"] != null && s["dx_flag"] != "") {
dx_flag = s["dx_flag"];
}