Skip to content

Instantly share code, notes, and snippets.

@mcollier
Last active December 8, 2021 10:12
Show Gist options
  • Save mcollier/10097074 to your computer and use it in GitHub Desktop.
Save mcollier/10097074 to your computer and use it in GitHub Desktop.
Download videos and slides from Microsoft conferences
Param
(
[Parameter(Mandatory=$false)]
[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)
try
{
if ((Test-Path -Path $destination -PathType Leaf))
{
Write-Host 'Skipping file, already downloaded' -ForegroundColor Yellow}
else
{
Write-Output "Downloading '$source' to '$destination'"
$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"
#TechEd NA 2014
#$dataFeed = "http://s.ch9.ms/Events/TechEd/NorthAmerica/2014/RSS/mp4?sort=sequential&direction=desc&term=microsoft%20azure"
#BUILD 2016 - Azure
$dataFeed = "http://s.ch9.ms/Events/Build/2016/RSS/mp4med?sort=sequential&direction=desc&term=&tag=azure"
$a = ([xml]$rss.downloadstring($dataFeed))
$a.rss.channel.item | foreach{
if ($_.category -eq "microsoft-azure" -or $_.category -eq "azure")
{
$sessionNumber = $_.link.Substring($_.link.LastIndexOf("/") + 1)
$mediaUrl = New-Object System.Uri($_.enclosure.url)
$pptxUrl = New-Object System.Uri($_.enclosure.url.Replace(".mp4", ".pptx"))
$file = $_.creator + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "-") + " ($sessionNumber)" + ".mp4"
$pptx = $_.creator + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "-") + " ($sessionNumber)" + ".pptx"
$downloadFile = $DownloadLocation + "\" + $file
DownloadFile -source $mediaUrl -destination $downloadFile
$downloadFile = $DownloadLocation + "\" + $pptx
DownloadFile -source $pptxUrl -destination $downloadFile
# TODO: try alternate location for PPTX - only tested with BUILD 2014, 2016 and TechEd NA 2014. Need to make dynamic.
#$pptxUrlAlt = "http://video.ch9.ms/sessions/build/2014/" + $sessionNumber + ".pptx"
#$pptxUrlAlt = "http://video.ch9.ms/sessions/teched/na/2014/" + $sessionNumber + ".pptx"
$pptxUrlAlt = "https://sec.ch9.ms/sessions/build/2016/" + $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