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 {
clear-host
""
Clear-Host
" ______ ______ ______ _____ __ ______ ______ "
" /\ ___\ /\ == \ /\ ___\ /\ __-. /\ \ /\__ _\ /\ ___\ "
" \ \ \____ \ \ __< \ \ __\ \ \ \/\ \ \ \ \ \/_/\ \/ \ \___ \ "
" \ \_____\ \ \_\ \_\ \ \_____\ \ \____- \ \_\ \ \_\ \/\_____\ "
" \/_____/ \/_/ /_/ \/_____/ \/____/ \/_/ \/_/ \/_____/ "
""
""
& "$PSScriptRoot/write-animated.ps1" "Typos: Markus Fleschutz"
& "$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" "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" "Scripts: PowerShell Scripts 1.1"
& "$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" "Copyright: (c) 2024. All Rights Reserved"
& "$PSScriptRoot/write-animated.ps1" "No Animals Were Harmed in the Making of This Film"
& "$PSScriptRoot/write-big.ps1" " Thanx 4 watching"
exit 0 # success
} catch {

View File

@ -1,34 +1,37 @@
<#
.SYNOPSIS
Lists the latest headlines
Watch the latest headlines
.DESCRIPTION
This PowerShell script lists the latest headlines by using a RSS (Really Simple Syndication) feed.
.PARAMETER RSS_URL
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
PS> ./list-headlines.ps1
Niger coup: Ecowas deadline sparks anxiety in northern Nigeria
...
PS> ./watch-headlines.ps1
Niger coup: Ecowas deadline sparks anxiety in northern Nigeria
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
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 {
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
[int]$count = 1
foreach ($item in $content.rss.channel.item) {
& "$PSScriptRoot/write-animated.ps1" "* $($item.title) *"
if ($count++ -eq $maxLines) { break }
$previous = ""
while ($true) {
$latest = GetLatestHeadline
if ($latest -ne $previous) {
& "$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
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"