mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-08-07 09:22:44 +02:00
repeaterlist
This commit is contained in:
+53
-2
@@ -9,9 +9,9 @@ import bs4 as bs # pip install beautifulsoup4
|
||||
import xml.dom.minidom
|
||||
from modules.log import *
|
||||
|
||||
trap_list_location = ("whereami", "tide", "moon", "wx", "wxc", "wxa", "wxalert")
|
||||
trap_list_location = ("whereami", "tide", "moon", "wx", "wxc", "wxa", "wxalert", "repeaterlist")
|
||||
|
||||
def where_am_i(lat=0, lon=0, short=False):
|
||||
def where_am_i(lat=0, lon=0, short=False, zip=False):
|
||||
whereIam = ""
|
||||
grid = mh.to_maiden(float(lat), float(lon))
|
||||
|
||||
@@ -31,6 +31,12 @@ def where_am_i(lat=0, lon=0, short=False):
|
||||
whereIam = f"City: {address.get('city', '')}. State: {address.get('state', '')}. County: {address.get('county', '')}. Country: {address.get('country', '')}."
|
||||
return whereIam
|
||||
|
||||
if zip:
|
||||
# return a string with zip code only
|
||||
location = geolocator.reverse(str(lat) + ", " + str(lon))
|
||||
whereIam = location.raw['address'].get('postcode', '')
|
||||
return whereIam
|
||||
|
||||
if float(lat) == latitudeValue and float(lon) == longitudeValue:
|
||||
# redacted address when no GPS and using default location
|
||||
location = geolocator.reverse(str(lat) + ", " + str(lon))
|
||||
@@ -62,6 +68,51 @@ def where_am_i(lat=0, lon=0, short=False):
|
||||
logger.debug("Location:Error fetching location data with whereami, likely network error")
|
||||
return ERROR_FETCHING_DATA
|
||||
|
||||
def getArtSciRepeaters(lat=0, lon=0):
|
||||
# UK api_url = "https://api-beta.rsgb.online/all/systems"
|
||||
#grid = mh.to_maiden(float(lat), float(lon))
|
||||
repeaters = []
|
||||
zipCode = where_am_i(lat, lon, zip=True)
|
||||
if zipCode == NO_DATA_NOGPS or zipCode == ERROR_FETCHING_DATA:
|
||||
return zipCode
|
||||
|
||||
if zipCode.isnumeric():
|
||||
try:
|
||||
artsci_url = f"http://www.artscipub.com/mobile/showstate.asp?zip={zipCode}"
|
||||
response = requests.get(artsci_url)
|
||||
soup = bs.BeautifulSoup(response.text, 'html.parser')
|
||||
# results needed xpath is /html/body/table[2]/tbody/tr/td/table/tbody/tr[2]/td/table
|
||||
table = soup.find_all('table')[1]
|
||||
rows = table.find_all('tr')
|
||||
for row in rows:
|
||||
cols = row.find_all('td')
|
||||
cols = [ele.text.strip() for ele in cols]
|
||||
# if no elements have the word 'located' then append
|
||||
if not any('located' in ele for ele in cols):
|
||||
if not any('Location' in ele for ele in cols):
|
||||
repeaters.append([ele for ele in cols if ele])
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching data from {artsci_url}: {e}")
|
||||
|
||||
if repeaters != []:
|
||||
msg = f"Found:{len(repeaters)} in {zipCode}\n"
|
||||
for repeater in repeaters:
|
||||
# format is ['City', 'Frequency', 'Offset', 'PL', 'Call', 'Notes']
|
||||
# there might be missing elements or only one element
|
||||
if len(repeater) == 2:
|
||||
msg += f"Freq:{repeater[1]}\n"
|
||||
elif len(repeater) == 3:
|
||||
msg += f"Freq:{repeater[1]}, PL:{repeater[2]}\n"
|
||||
elif len(repeater) == 4:
|
||||
msg += f"Freq:{repeater[1]}, PL:{repeater[2]}, ID: {repeater[3]}\n"
|
||||
elif len(repeater) == 5:
|
||||
msg += f"Freq:{repeater[1]}, PL:{repeater[2]}, ID:{repeater[3]}, Dist:{repeater[4]}\n"
|
||||
elif len(repeater) == 6:
|
||||
msg += f"Freq:{repeater[1]}, PL:{repeater[2]}, ID:{repeater[3]}, Dist:{repeater[4]}. {repeater[5]}\n"
|
||||
else:
|
||||
msg = f"no results.. sorry"
|
||||
return msg
|
||||
|
||||
|
||||
def get_tide(lat=0, lon=0):
|
||||
station_id = ""
|
||||
|
||||
Reference in New Issue
Block a user