Created
March 16, 2014 23:04
-
-
Save ciphertxt/9591139 to your computer and use it in GitHub Desktop.
Downloads the SPC14 files with BITS instead of WebClient
This file contains 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
[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