Merge branch 'main' of github.com:fleschutz/PowerShell

This commit is contained in:
Markus Fleschutz 2024-05-17 08:05:14 +02:00
commit 00d11f8866
2 changed files with 20 additions and 21 deletions

View File

@ -12,20 +12,17 @@
#> #>
try { try {
clear-host Clear-Host
""
" ______ ______ ______ _____ __ ______ ______ " " ______ ______ ______ _____ __ ______ ______ "
" /\ ___\ /\ == \ /\ ___\ /\ __-. /\ \ /\__ _\ /\ ___\ " " /\ ___\ /\ == \ /\ ___\ /\ __-. /\ \ /\__ _\ /\ ___\ "
" \ \ \____ \ \ __< \ \ __\ \ \ \/\ \ \ \ \ \/_/\ \/ \ \___ \ " " \ \ \____ \ \ __< \ \ __\ \ \ \/\ \ \ \ \ \/_/\ \/ \ \___ \ "
" \ \_____\ \ \_\ \_\ \ \_____\ \ \____- \ \_\ \ \_\ \/\_____\ " " \ \_____\ \ \_\ \_\ \ \_____\ \ \____- \ \_\ \ \_\ \/\_____\ "
" \/_____/ \/_/ /_/ \/_____/ \/____/ \/_/ \/_/ \/_____/ " " \/_____/ \/_/ /_/ \/_____/ \/____/ \/_/ \/_/ \/_____/ "
"" ""
& "$PSScriptRoot/write-animated.ps1" "Typos: Markus Fleschutz" & "$PSScriptRoot/write-animated.ps1" "Typos: Markus Fleschutz"
& "$PSScriptRoot/write-animated.ps1" "Keyboard: Rapoo 12335 E9270P WL Ultra-Slim Touch" & "$PSScriptRoot/write-animated.ps1" "Keyboard: Rapoo 12335 E9270P WL Ultra-Slim Touch"
& "$PSScriptRoot/write-animated.ps1" "Operating Systems: Windows 11 23H3 & Ubuntu Server 24.04 LTS" & "$PSScriptRoot/write-animated.ps1" "Operating Systems: Windows 11 23H3 & Ubuntu Server 24.04 LTS"
& "$PSScriptRoot/write-animated.ps1" "Console: Windows Terminal 1.20.11271.0" & "$PSScriptRoot/write-animated.ps1" "Console: Windows Terminal 1.20.11271.0"
& "$PSScriptRoot/write-animated.ps1" "Background Image: Asteroid Field by starwars.com"
& "$PSScriptRoot/write-animated.ps1" "Shell: PowerShell 5.1.22621.2506 & PowerShell 7.4.2" & "$PSScriptRoot/write-animated.ps1" "Shell: PowerShell 5.1.22621.2506 & PowerShell 7.4.2"
& "$PSScriptRoot/write-animated.ps1" "Scripts: PowerShell Scripts 1.1" & "$PSScriptRoot/write-animated.ps1" "Scripts: PowerShell Scripts 1.1"
& "$PSScriptRoot/write-animated.ps1" "GitHub: github.com/fleschutz/PowerShell" & "$PSScriptRoot/write-animated.ps1" "GitHub: github.com/fleschutz/PowerShell"
@ -38,7 +35,6 @@ try {
& "$PSScriptRoot/write-animated.ps1" "Special Thanks: Andrea Fleschutz" & "$PSScriptRoot/write-animated.ps1" "Special Thanks: Andrea Fleschutz"
& "$PSScriptRoot/write-animated.ps1" "Copyright: (c) 2024. All Rights Reserved" & "$PSScriptRoot/write-animated.ps1" "Copyright: (c) 2024. All Rights Reserved"
& "$PSScriptRoot/write-animated.ps1" "No Animals Were Harmed in the Making of This Film" & "$PSScriptRoot/write-animated.ps1" "No Animals Were Harmed in the Making of This Film"
& "$PSScriptRoot/write-big.ps1" " Thanx 4 watching" & "$PSScriptRoot/write-big.ps1" " Thanx 4 watching"
exit 0 # success exit 0 # success
} catch { } catch {

View File

@ -1,34 +1,37 @@
<# <#
.SYNOPSIS .SYNOPSIS
Lists the latest headlines Watch the latest headlines
.DESCRIPTION .DESCRIPTION
This PowerShell script lists the latest headlines by using a RSS (Really Simple Syndication) feed. This PowerShell script lists the latest headlines by using a RSS (Really Simple Syndication) feed.
.PARAMETER RSS_URL .PARAMETER RSS_URL
Specifies the URL to the RSS feed (Yahoo World News by default) Specifies the URL to the RSS feed (Yahoo World News by default)
.PARAMETER maxLines
Specifies the maximum number of lines to list (24 by default)
.EXAMPLE .EXAMPLE
PS> ./list-headlines.ps1 PS> ./watch-headlines.ps1
Niger coup: Ecowas deadline sparks anxiety in northern Nigeria Niger coup: Ecowas deadline sparks anxiety in northern Nigeria
...
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$RSS_URL = "https://news.yahoo.com/rss/world", [int]$maxLines = 24) param([string]$RSS_URL = "https://news.yahoo.com/rss/world", [int]$timeInterval = 30000) # in ms
function GetLatestHeadline {
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
foreach ($item in $content.rss.channel.item) { return "$($item.title)" }
return ""
}
try { try {
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content $previous = ""
[int]$count = 1 while ($true) {
foreach ($item in $content.rss.channel.item) { $latest = GetLatestHeadline
& "$PSScriptRoot/write-animated.ps1" "* $($item.title) *" if ($latest -ne $previous) {
if ($count++ -eq $maxLines) { break } & "$PSScriptRoot/write-animated.ps1" "❇️ $latest ❇️"
$previous = $latest
}
Start-Sleep -milliseconds $timeInterval
} }
$source = $content.rss.channel.title
$date = $content.rss.channel.pubDate
" (by $source as of $date)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"