Skip to content

Instantly share code, notes, and snippets.

@ciphertxt
Created March 16, 2014 23:04
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 ciphertxt/9591139 to your computer and use it in GitHub Desktop.
Save ciphertxt/9591139 to your computer and use it in GitHub Desktop.
Downloads the SPC14 files with BITS instead of WebClient
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$rss = (new-object net.webclient)
$a = [xml]($rss.downloadstring("http://channel9.msdn.com/Events/SharePoint-Conference/2014/RSS/mp4high"))
$a.rss.channel.item | foreach {
$code = $_.comments.split("/") | select -last 1
$url = New-Object System.Uri($_.enclosure.url)
$file = $code + "-" + $_.creator + "-" + $_.title.Replace("'","").Replace("*","").Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "")
$file = $file + ".mp4"
Write-Host "Generated file name $($file)" -ForegroundColor DarkCyan
if (!(test-path $file)) {
Write-Host -ForegroundColor Cyan "Dowloading $($file)"
Start-BitsTransfer -Source $url -Destination $file -Asynchronous
}
}
$jobs = Get-BitsTransfer | ? { $_.JobState -eq "Transferring" };
while ($jobs.Count -gt 0) {
$totalbytes=0;
$bytestransferred=0;
foreach ($job in $jobs) {
$totalbytes += $job.BytesTotal;
$bytestransferred += $job.bytestransferred
}
[int]$pctComplete = $(($bytestransferred*100)/$totalbytes);
Write-Progress -Status "Transferring $bytestransferred of $totalbytes ($pctComplete%)" -Activity "Dowloading SPC files" -PercentComplete $pctComplete
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment