diff --git a/scripts/list-nina-warnings.ps1 b/scripts/list-nina-warnings.ps1 index 0dd6aba1..f2f1b426 100755 --- a/scripts/list-nina-warnings.ps1 +++ b/scripts/list-nina-warnings.ps1 @@ -1,8 +1,8 @@ <# .SYNOPSIS - Lists the current NINA warnings + Lists the current weather warnings by NINA .DESCRIPTION - This PowerShell script queries the current NINA warnings and prints it. + This PowerShell script queries the current NINA weather warnings and lists it. .EXAMPLE PS> ./list-nina-warnings.ps1 .LINK @@ -11,21 +11,32 @@ Author: Markus Fleschutz | License: CC0 #> -try { +function ListWarningsOf([string]$category, [string]$source) +{ Write-Progress "Loading NINA warnings..." - $warnings = (Invoke-WebRequest -URI https://warnung.bund.de/api31/dwd/mapData.json -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + $warnings = (Invoke-WebRequest -URI https://warnung.bund.de/api31/$category/mapData.json -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json Write-Progress -completed "Done." - Write-Output "Weather Warnings by DWD" - Write-Output "-----------------------" + foreach($warning in $warnings) { + $message = $warning.i18nTitle.en $startDate = $warning.startDate $expiresDate = $warning.expiresDate $severity = $warning.severity $urgency = $warning.urgency $type = $warning.type - $message = $warning.i18nTitle.en - Write-Output "* $type from $startDate to $($expiresDate): $message ($severity, $urgency)" + Write-Output "* $message" + Write-Output " from $startDate to $expiresDate ($source $type, $severity, $urgency)" + Write-Output "" } +} + +try { + Write-Output "" + ListWarningsOf "katwarn" "Katwarn" + ListWarningsOf "dwd" "DWD" + ListWarningsOf "police" "Police" + ListWarningsOf "lhp" "LHP" + ListWarningsOf "biwapp" "Biwapp" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"