Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions apps/rawmetar/raw_metar.star
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main(config):
),
)

response = http.get("https://www.aviationweather.gov/cgi-bin/data/metar.php?ids={}".format(station_id))
response = http.get("https://aviationweather.gov/api/data/metar?ids={}".format(station_id))
content = response.body()

if not content:
Expand All @@ -37,7 +37,20 @@ def main(config):
max_line_width = 12
lines_per_page = 4

lines_to_display = [content[i:i + max_line_width] for i in range(0, len(content), max_line_width)]
words = content.split()
lines_to_display = []
current_line = ""

for word in words:
if len(current_line) + len(word) + 1 > max_line_width and current_line:
lines_to_display.append(current_line)
current_line = word
else:
current_line = current_line + (" " + word if current_line else word)

if current_line:
lines_to_display.append(current_line)

pages_to_display = [lines_to_display[i:i + lines_per_page] for i in range(0, len(lines_to_display), lines_per_page)]

frames = []
Expand Down