From 1c92a03ad5fb34e208df286a149b4e9bc70e7619 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 26 Jun 2024 08:39:06 +0200 Subject: [PATCH] Updated list-nina-warnings.ps1 --- scripts/list-nina-warnings.ps1 | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/scripts/list-nina-warnings.ps1 b/scripts/list-nina-warnings.ps1 index f2f1b426..f3666871 100755 --- a/scripts/list-nina-warnings.ps1 +++ b/scripts/list-nina-warnings.ps1 @@ -1,42 +1,46 @@ <# .SYNOPSIS - Lists the current weather warnings by NINA + Lists the current NINA warnings .DESCRIPTION - This PowerShell script queries the current NINA weather warnings and lists it. + This PowerShell script queries the current NINA warnings and lists it. .EXAMPLE PS> ./list-nina-warnings.ps1 + + ⚠️ Official SEVERE WEATHER WARNING of SEVERE THUNDERSTORMS with VERY HEAVY RAIN and HAIL + 🕘 2024-06-26T07:53:00+02:00 ... 2024-06-26T08:45:00+02:00 (by DWD, Update, Severe, Immediate) .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> -function ListWarningsOf([string]$category, [string]$source) +function ListWarningsOf([string]$source, [string]$URL) { - Write-Progress "Loading NINA warnings..." - $warnings = (Invoke-WebRequest -URI https://warnung.bund.de/api31/$category/mapData.json -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + Write-Progress "Loading NINA - $source warnings..." + $warnings = (Invoke-WebRequest -URI $URL -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json Write-Progress -completed "Done." foreach($warning in $warnings) { - $message = $warning.i18nTitle.en + $title = $warning.i18nTitle.en + if ("$title" -eq "") { $title = $warning.i18nTitle.de } $startDate = $warning.startDate $expiresDate = $warning.expiresDate $severity = $warning.severity $urgency = $warning.urgency $type = $warning.type - Write-Output "* $message" - Write-Output " from $startDate to $expiresDate ($source $type, $severity, $urgency)" + Write-Output "⚠️ $title" + Write-Output " 🕘 $($startDate)...$expiresDate (by $source, $type, $severity, $urgency)" Write-Output "" } } try { Write-Output "" - ListWarningsOf "katwarn" "Katwarn" - ListWarningsOf "dwd" "DWD" - ListWarningsOf "police" "Police" - ListWarningsOf "lhp" "LHP" - ListWarningsOf "biwapp" "Biwapp" + ListWarningsOf "Katwarn" "https://warnung.bund.de/api31/katwarn/mapData.json" + ListWarningsOf "DWD" "https://warnung.bund.de/api31/dwd/mapData.json" + ListWarningsOf "Police" "https://warnung.bund.de/api31/police/mapData.json" + ListWarningsOf "LHP" "https://warnung.bund.de/api31/lhp/mapData.json" + ListWarningsOf "Biwapp" "https://warnung.bund.de/api31/biwapp/mapData.json" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"