Skip to content

Instantly share code, notes, and snippets.

@m-gagne
Last active August 29, 2015 14:09
Show Gist options
  • Save m-gagne/34dba24dfa34c2169a89 to your computer and use it in GitHub Desktop.
Save m-gagne/34dba24dfa34c2169a89 to your computer and use it in GitHub Desktop.
Powershell script to download all of Azure Friday videos from RSS feed
function GetFeedPageCount ($url) {
$feed=[xml](New-Object System.Net.WebClient).DownloadString($url)
$pageCount = $feed.rss.channel.pageCount
return $pageCount;
}
function DownloadFeed ($url) {
$feed=[xml](New-Object System.Net.WebClient).DownloadString($url)
foreach($i in $feed.rss.channel.item) {
$url = New-Object System.Uri($i.enclosure.url)
$url.ToString()
$url.Segments[-1]
$localFile = $url.Segments[-1]
if (Test-Path($localFile)) {
Write-Host "Skipping file, already downloaded"
}
else
{
Invoke-WebRequest $url -OutFile $url.Segments[-1]
}
}
}
# This sample code assumes the RSS feed returns a pageCount
# eg: rss/channel/pageCount
# as well as accepts ?page= as a parameter
#
# Based on code by Scott Hanselman
# Source: http://www.hanselman.com/blog/Mix11VideosDownloadThemAllWithRSS.aspx
#
# Related blog post here: http://blogs.msdn.com/b/cdndevs/archive/2014/11/18/azure-fridays-a-powershell-script-to-download-rss-videos.aspx
$feedUrl = "http://channel9.msdn.com/Shows/Azure-Friday/feed/mp4high"
$pageCount = GetFeedPageCount($feedUrl)
for ($i = 1; $i -le $pageCount; $i++) {
Write-Host "Downloading page $i of $pageCount"
DownloadFeed($feedUrl + "?page=" + $i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment