Skip to content

Instantly share code, notes, and snippets.

@stevebeauge
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevebeauge/0a40383b95cb130ae10d to your computer and use it in GitHub Desktop.
Save stevebeauge/0a40383b95cb130ae10d to your computer and use it in GitHub Desktop.
Improved "The Ultimate Script to download Microsoft Ignite Videos AND slides!" script
#Script written by Vlad Catrinescu
#Visit my site www.absolute-sharepoint.com
#Twitter: @vladcatrinescu
#Originally Posted here: http://absolute-sharepoint.com/2015/05/the-ultimate-script-to-download-microsoft-ignite-videos-and-slides.html
Param(
[string]$keyword
)
###### Variables #####
#Location - Preferably enter something not too long to not have filename problems! cut and paste them afterwards
$downloadlocation = "C:\Ignite"
#Ignite 2015 Videos RSS Feed
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$rss = (new-object net.webclient)
$video1 = ([xml]$rss.downloadstring("http://s.ch9.ms/events/ignite/2015/rss/mp4high"))
$video2 = ([xml]$rss.downloadstring("http://s.ch9.ms/events/ignite/2015/rss/mp4high?page=2"))
$slide1 = ([xml]$rss.downloadstring("http://s.ch9.ms/events/ignite/2015/rss/slides"))
$slide2 = ([xml]$rss.downloadstring("http://s.ch9.ms/events/ignite/2015/rss/slides?page=2"))
#other qualities for the videos only. Choose the one you want!
# $a = ([xml]$rss.downloadstring("http://channel9.msdn.com/events/ignite/2015/rss/mp4"))
#$a = ([xml]$rss.downloadstring("http://channel9.msdn.com/events/ignite/2015/rss/mp3"))
#SCRIPT/ Functions Do not touch below this line :)#
if (-not (Test-Path $downloadlocation)) {
Write-Host "Folder $fpath dosen't exist. Creating it..."
New-Item $downloadlocation -type directory
}
set-location $downloadlocation
function DownloadSlides($filter,$videourl)
{
try {
$videourl.rss.channel.item | Where{($_.title -like “*$filter*”)} | foreach{
$code = $_.comments.split("/") | select -last 1
# Grab the URL for the PPTX file
$urlpptx = New-Object System.Uri($_.enclosure.url)
$filepptx = $code + "-" + $_.creator + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "").Replace("|", "").Replace('"',"").Replace("*","")
$filepptx = $filepptx.substring(0, [System.Math]::Min(120, $filepptx.Length))
$filepptx = $filepptx.trim()
$filepptx = $filepptx + ".pptx"
if ($code -ne "")
{
$folder = $code + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "").Replace("|", "").Replace('"',"").Replace("*","")
$folder = $folder.substring(0, [System.Math]::Min(100, $folder.Length))
$folder = $folder.trim()
}
else
{
$folder = "NoCodeSessions"
}
if (-not (Test-Path $folder)) {
Write-Host "Folder $folder dosen't exist. Creating it..."
New-Item $folder -type directory
}
# Make sure the PowerPoint file doesn't already exist
if (!(test-path "$downloadlocation\$folder\$filepptx"))
{
# Echo out the file that's being downloaded
$filepptx
#$wc = (New-Object System.Net.WebClient)
# Download the MP4 file
#$wc.DownloadFile($urlpptx, "$downloadlocation\$filepptx")
Start-BitsTransfer $urlpptx "$downloadlocation\$filepptx" -DisplayName $filepptx
mv $filepptx $folder
}
}
}
catch{
$ErrorMessage = $_.Exception.Message
Write-host "$ErrorMessage"
}
}
function DownloadVideos($filter,$slideurl)
{
#download all the mp4
# Walk through each item in the feed
$slideurl.rss.channel.item | Where{($_.title -like “*$filter*”)} | foreach{
$code = $_.comments.split("/") | select -last 1
# Grab the URL for the MP4 file
$url = New-Object System.Uri($_.enclosure.url)
# Create the local file name for the MP4 download
$file = $code + "-" + $_.creator + "-" + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "").Replace("|", "").Replace('"',"").Replace("*","")
$file = $file.substring(0, [System.Math]::Min(120, $file.Length))
$file = $file.trim()
$file = $file + ".mp4"
if ($code -ne "")
{
$folder = $code + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "").Replace("|", "").Replace('"',"").Replace("*","")
$folder = $folder.substring(0, [System.Math]::Min(100, $folder.Length))
$folder = $folder.trim()
}
else
{
$folder = "NoCodeSessions"
}
if (-not (Test-Path $folder)) {
Write-Host "Folder $folder) dosen't exist. Creating it..."
New-Item $folder -type directory
}
# Make sure the MP4 file doesn't already exist
if (!(test-path "$folder\$file"))
{
# Echo out the file that's being downloaded
$file
#$wc = (New-Object System.Net.WebClient)
# Download the MP4 file
#$wc.DownloadFile($url, "$downloadlocation\$file")
Start-BitsTransfer $url "$downloadlocation\$file" -DisplayName $file
mv $file $folder
}
#text description from session
$OutFile = New-Item -type file "$($downloadlocation)\$($Folder)\$($Code.trim()).txt" -Force
$Category = "" ; $Content = ""
$_.category | foreach {$Category += $_ + ","}
$Content = $_.title.trim() + "`r`n" + $_.creator + "`r`n" + $_.summary.trim() + "`r`n" + "`r`n" + $Category.Substring(0,$Category.Length -1)
add-content $OutFile $Content
}
}
if ($keyword)
{
$keywords = $keyword.split(",")
foreach ($k in $keywords)
{
$k.trim()
Write-Host "You are now downloading the sessions with the keyword $k"
DownloadSlides $k $slide1
DownloadSlides $k $slide2
DownloadVideos $k $video1
DownloadVideos $k $video2
}
}
else
{
DownloadSlides " " $slide1
DownloadSlides " " $slide2
DownloadVideos " " $video1
DownloadVideos " " $video2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment