-
-
Save ivlists/10650359 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Param | |
( | |
[Parameter(Mandatory=$true)] | |
[String] | |
$DownloadLocation | |
) | |
cls | |
# The script has been tested on Powershell 3.0 | |
Set-StrictMode -Version 3 | |
# Following modifies the Write-Verbose behavior to turn the messages on globally for this session | |
$VerbosePreference = "Continue" | |
#$ErrorActionPreference = 'Stop' | |
if ($DownloadLocation -eq $null -or $DownloadLocation.Length -eq 0) | |
{ | |
$DownloadLocation = (Get-Location -PSProvider FileSystem).ProviderPath | |
} | |
$rss = (new-object net.webclient) | |
function DownloadFile | |
{ | |
param ([string] $source, [string] $destination) | |
Write-Output "Downloading '$source' to '$destination'" | |
try | |
{ | |
if (!(Test-Path -Path $destination -PathType Leaf)) | |
{ | |
$wc = (New-Object System.Net.WebClient) | |
$wc.DownloadFile($source, $destination) | |
} | |
} | |
catch | |
{ | |
$ex = $_.Exception.InnerException | |
Write-Error "Failed to download file '$source'. $ex.Message" | |
} | |
} | |
#Set the username for windows auth proxy | |
#$rss.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials | |
# Set the RSS feed path | |
# TechEd NA 2013 | |
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/rss/mp4high/?sort=sequential&direction=desc&term=&r=Developer+Tools+%26+Application+Lifecycle+Management&r=Windows+Azure+Application+Development&y=Breakout&Media=true#fbid=FDnmapgI5Hf" | |
# | |
# TechEd NA 2013 - All | |
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/RSS/mp4high" | |
# | |
#TechEd NA 2013 - Windows Azure | |
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/rss/mp4high/?sort=sequential&direction=desc&term=&r=Windows+Azure+Application+Development&y=Breakout&Media=true#fbid=FDnmapgI5Hf" | |
# | |
# TechEd Europe 2013 - All | |
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/Europe/2013/RSS/mp4high" | |
# | |
# TechEd Europe 2013 - Windows Azure | |
#$dataFeed = "http://channel9.msdn.com/Events/TechEd/europe/2013/RSS/mp4high/?sort=sequential&direction=desc&term=&r=Windows+Azure+Application+Development&y=Breakout&Media" | |
# | |
#BUILD 2013 - All | |
#$dataFeed = "http://channel9.msdn.com/Events/Build/2013/RSS/mp4high#theSessions" | |
# | |
#BUILD 2014 - Azure | |
$dataFeed = "http://s.ch9.ms/Events/Build/2014/rss/mp4med?sort=sequential&direction=desc&term=&tag=azure" | |
$a = ([xml]$rss.downloadstring($dataFeed)) | |
$a.rss.channel.item | foreach{ | |
$mediaUrl = New-Object System.Uri($_.enclosure.url) | |
$pptxUrl = New-Object System.Uri($_.enclosure.url.Replace(".mp4", ".pptx")) | |
$file = $_.creator + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "-") + ".mp4" | |
$pptx = $_.creator + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "-") + ".pptx" | |
if ($_.category -eq "azure") | |
{ | |
$downloadFile = $DownloadLocation + "\" + $file | |
DownloadFile -source $mediaUrl -destination $downloadFile | |
$downloadFile = $DownloadLocation + "\" + $pptx | |
DownloadFile -source $pptxUrl -destination $downloadFile | |
# try alternate location for PPTX - only tested with BUILD 2014 | |
$sessionNumber = $_.link.Substring($_.link.LastIndexOf("/") + 1) | |
$pptxUrlAlt = "http://video.ch9.ms/sessions/build/2014/" + $sessionNumber + ".pptx" | |
$downloadFile = $DownloadLocation + "\" + $pptx | |
DownloadFile -source $pptxUrlAlt -destination $downloadFile | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment