Skip to content

Instantly share code, notes, and snippets.

@amit-g
Last active November 12, 2019 07:50
Show Gist options
  • Save amit-g/a020cf91bbab4dc2656aac97f3e6a61a to your computer and use it in GitHub Desktop.
Save amit-g/a020cf91bbab4dc2656aac97f3e6a61a to your computer and use it in GitHub Desktop.
Reads the Podcast Feed and Downloads the Podcasts
$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