mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-27 20:28:44 +02:00
Update list-nina-warnings.ps1
This commit is contained in:
parent
3721feeaa9
commit
d6071ca2b0
@ -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])"
|
||||
|
Loading…
Reference in New Issue
Block a user