mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-12 13:08:17 +02:00
Updated list-nina-warnings.ps1
This commit is contained in:
parent
31a95d7074
commit
1c92a03ad5
@ -1,42 +1,46 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists the current weather warnings by NINA
|
Lists the current NINA warnings
|
||||||
.DESCRIPTION
|
.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
|
.EXAMPLE
|
||||||
PS> ./list-nina-warnings.ps1
|
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
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function ListWarningsOf([string]$category, [string]$source)
|
function ListWarningsOf([string]$source, [string]$URL)
|
||||||
{
|
{
|
||||||
Write-Progress "Loading NINA warnings..."
|
Write-Progress "Loading NINA - $source warnings..."
|
||||||
$warnings = (Invoke-WebRequest -URI https://warnung.bund.de/api31/$category/mapData.json -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
$warnings = (Invoke-WebRequest -URI $URL -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
||||||
Write-Progress -completed "Done."
|
Write-Progress -completed "Done."
|
||||||
|
|
||||||
foreach($warning in $warnings) {
|
foreach($warning in $warnings) {
|
||||||
$message = $warning.i18nTitle.en
|
$title = $warning.i18nTitle.en
|
||||||
|
if ("$title" -eq "") { $title = $warning.i18nTitle.de }
|
||||||
$startDate = $warning.startDate
|
$startDate = $warning.startDate
|
||||||
$expiresDate = $warning.expiresDate
|
$expiresDate = $warning.expiresDate
|
||||||
$severity = $warning.severity
|
$severity = $warning.severity
|
||||||
$urgency = $warning.urgency
|
$urgency = $warning.urgency
|
||||||
$type = $warning.type
|
$type = $warning.type
|
||||||
Write-Output "* $message"
|
Write-Output "⚠️ $title"
|
||||||
Write-Output " from $startDate to $expiresDate ($source $type, $severity, $urgency)"
|
Write-Output " 🕘 $($startDate)...$expiresDate (by $source, $type, $severity, $urgency)"
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
ListWarningsOf "katwarn" "Katwarn"
|
ListWarningsOf "Katwarn" "https://warnung.bund.de/api31/katwarn/mapData.json"
|
||||||
ListWarningsOf "dwd" "DWD"
|
ListWarningsOf "DWD" "https://warnung.bund.de/api31/dwd/mapData.json"
|
||||||
ListWarningsOf "police" "Police"
|
ListWarningsOf "Police" "https://warnung.bund.de/api31/police/mapData.json"
|
||||||
ListWarningsOf "lhp" "LHP"
|
ListWarningsOf "LHP" "https://warnung.bund.de/api31/lhp/mapData.json"
|
||||||
ListWarningsOf "biwapp" "Biwapp"
|
ListWarningsOf "Biwapp" "https://warnung.bund.de/api31/biwapp/mapData.json"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user