Last active
November 12, 2019 07:50
-
-
Save amit-g/a020cf91bbab4dc2656aac97f3e6a61a to your computer and use it in GitHub Desktop.
Reads the Podcast Feed and Downloads the Podcasts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$FeedUrl="ValidFeedRssUrl" | |
$FeedResponse=Invoke-WebRequest $FeedUrl | |
$FeedXml=[xml]$FeedResponse.Content | |
$FeedXml.rss.channel.item | | |
Select-Object @{ L="PubDate"; E={ [DateTime]::ParseExact($_.pubDate.Substring(0, $_.pubDate.Length - 3) + "GMT", "R", $null) } }, @{ L="Uri"; E={ [Uri]$_.guid } } | | |
Select-Object @{ L="LocalName"; E={ $_.PubDate.ToString("yyyy-MM-dd-") + [Uri]::UnescapeDataString($_.Uri.Segments[$_.Uri.Segments.Length - 1]).Replace(" ", "_") } }, PubDate, Uri | | |
Select-Object -First 2 | | |
% { if (! (Test-Path $_.LocalName)) { echo "Downloading $($_.LocalName)"; "Start-BitsTransfer -Source $_.Uri -Destination $_.LocalName; Sleep 10;" } else { echo "$($_.LocalName) already downloaded" } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment