diff --git a/alertproviders/ng3k.py b/alertproviders/ng3k.py index 5d8c830..f684b1a 100644 --- a/alertproviders/ng3k.py +++ b/alertproviders/ng3k.py @@ -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] diff --git a/core/utils.py b/core/utils.py index 175ac73..482ff38 100644 --- a/core/utils.py +++ b/core/utils.py @@ -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) diff --git a/webassets/js/alerts.js b/webassets/js/alerts.js index b438ef1..4e001c2 100644 --- a/webassets/js/alerts.js +++ b/webassets/js/alerts.js @@ -133,7 +133,7 @@ function addAlertRowsToTable(tbody, alerts) { } // Format DX flag - var dx_flag = ""; + var dx_flag = ""; 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 => `${call}`).join(", "); } + // Format DXpedition country + var dx_country_html = ""; + if (a["is_dxpedition"] == true && a["dx_country"] != null && a["dx_country"] != "") { + dx_country_html = `
${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(`${start_time_formatted}`); $tr.append(`${end_time_formatted}`); - $tr.append(`${dx_flag}${dx_calls_html}`); + $tr.append(`${dx_flag}${dx_calls_html}${dx_country_html}`); $tr.append(`${freqsModesText}`); $tr.append(`${commentText}`); $tr.append(` ${sigSourceText}`); diff --git a/webassets/js/spots.js b/webassets/js/spots.js index 068b463..7793263 100644 --- a/webassets/js/spots.js +++ b/webassets/js/spots.js @@ -66,7 +66,7 @@ function updateTable() { var time_formatted = time.format("HH:mm"); // Format DX flag - var dx_flag = ""; + var dx_flag = ""; if (s["dx_flag"] && s["dx_flag"] != null && s["dx_flag"] != "") { dx_flag = s["dx_flag"]; }