Skip Ribbon Commands
Skip to main content

Anders Rask on SharePoint

:

Anders Rask on SharePoint > Posts > PowerShell script to download session videos from SharePoint Conference '11
October 12
PowerShell script to download session videos from SharePoint Conference '11
As promised on Twitter, here is my short PowerShell script to download the videos from #SPC11
 
UPDATE:
The script wont work after the hosting company added check for referrer headers in the request instead of doing propert authentication check. At the same time the hosting company have asked me not to change my script to bypass this "security" setting, so the script will not be updated to work with headers. I have asked the hosting company to add proper security so that I can modify my script to use users MySPC login without being in any grey area with regards to making downloads available.
 
The first function Get-WebFile is taken from Poshcode.org and slightly modified to stop overwriting existing files (you will have to delete partially downloaded files manually) and ignore if files did not exist.
 
I have just added all sessions from the session browser, so if some of them dont have a video, you will receive a warning but processing should continue.
 
I have only very briefly tested this script, so please let me know if it breaks and I will fix it.
 
Either check out the code below or download zip SPC-sessions.zipSPC-sessions.zip or from my Dropbox folder here.
 
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
## Get-WebFile (aka wget for PowerShell)
 ###############################################################################
 ## Downloads a file or page from the web
 ## History:
 ## v3.6  Add -Passthru switch to output TEXT files
 ## v3.5  Add -Quiet switch to turn off the progress reports 
 ## v3.4  Add progress report for files which dont report size
 ## v3.3  Add progress report for files which report their size
 ## v3.2  Use the pure Stream object because StreamWriter is based on TextWriter:
 ## it was messing up binary files, and making mistakes with extended characters in text
 ## v3.1  Unwrap the filename when it has quotes around it
 ## v3  rewritten completely using HttpWebRequest + HttpWebResponse to figure out the file name, if possible
 ## v2  adds a ton of parsing to make the output pretty
 ## added measuring the scripts involved in the command, (uses Tokenizer)
 ###############################################################################
 function Get-WebFile {
 param(
 $url = (Read-Host "The URL to download"),
 $fileName = $null,
 [switch]$Passthru,
 [switch]$quiet
 )
 
$req = [System.Net.HttpWebRequest]::Create($url);
 #http://stackoverflow.com/questions/518181/too-many-automatic-redirections-were-attempted-error-message-when-using-a-httpw
 $req.CookieContainer = New-Object System.Net.CookieContainer
 try
 {
 $res = $req.GetResponse();
 }
 catch [Management.Automation.MethodInvocationException]
 {
 Write-Warning "The file $url was not found on server! SKIPPING…"
return
 }
 
if($fileName -and !(Split-Path $fileName)) {
 $fileName = Join-Path (Get-Location -PSProvider "FileSystem") $fileName
 }
 elseif((!$Passthru -and ($fileName -eq $null)) -or (($fileName -ne $null) -and (Test-Path -PathType "Container" $fileName)))
 {
 [string]$fileName = ([regex](?i)filename=(.*)$).Match( $res.Headers["Content-Disposition"] ).Groups[1].Value
 $fileName = $fileName.trim("\/""’")
if(!$fileName) {
 $fileName = $res.ResponseUri.Segments[-1]
 $fileName = $fileName.trim("\/")
 if(!$fileName) {
 Write-Warning "The file $url was not found on server! SKIPPING…"
return
 }
 $fileName = $fileName.trim("\/")
 if(!([IO.FileInfo]$fileName).Extension) {
 $fileName = $fileName + "." + $res.ContentType.Split(";")[0].Split("/")[1]
 }
 }
 $fileName = Join-Path (Get-Location -PSProvider "FileSystem") $fileName
 }
 if($Passthru) {
 $encoding = [System.Text.Encoding]::GetEncoding( $res.CharacterSet )
 [string]$output = ""
 }
 
if($res.StatusCode -eq 200) {
 [int]$goal = $res.ContentLength
 $reader = $res.GetResponseStream()
 if($fileName)
 {
 try
 {
 $writer = new-object System.IO.FileStream $fileName, "CreateNew"
 }
 catch [Management.Automation.MethodInvocationException]
 {
 write-warning "The file $fileName already exists! Skipping…"
return
 }
 }
 [byte[]]$buffer = new-object byte[] 4096
 [int]$total = [int]$count = 0
 do
 {
 $count = $reader.Read($buffer, 0, $buffer.Length);
 if($fileName) {
 $writer.Write($buffer, 0, $count);
 }
 if($Passthru){
 $output += $encoding.GetString($buffer,0,$count)
 } elseif(!$quiet) {
 $total += $count
 if($goal -gt 0) {
 Write-Progress "Downloading $url" "Saving $total of $goal" -id 0 -percentComplete (($total/$goal)*100)
 } else {
 Write-Progress "Downloading $url" "Saving $total bytes…" -id 0
 }
 }
 } while ($count -gt 0)
 
$reader.Close()
 if($fileName) {
 $writer.Flush()
 $writer.Close()
 }
 if($Passthru){
 $output
 }
 }
 $res.Close();
 if($fileName) {
 ls $fileName
 }
 }
 
function Get-Sessions
 {
 [CmdletBinding()]
 param
 (
 [Parameter(Mandatory=$true, ValueFromPipeline = $true)]
 $Session,
 [Parameter(Mandatory=$true)]
 $VideoDownloadUrl
 )
 process
 {
 Write-Output "`tDownloading file $($_.Length) of $($_.ReadCount) from session $($_)"
 Get-WebFile -Url "$VideoDownloadUrl$($_).wmv.zip"
 }
 }
 
$sessions = Get-Content .\SPC sessions.csv
 $sessions | Get-Sessions -VideoDownloadUrl "http://cdn.tri-digital.com/spc/videos/"
 
 
The script was put together real fast, so no support for multi-threading. If anyone care to implement that, let me know and I will incorporate it in the script...

Comments

good

 I am sure that the information for understanding the depression that you shared through your post is useful for people. I am impressed with the way of writing. It kept connected me all the time. Keep up the good work.  https://www.uhjackets.com/blade-runner-2-ryan-gosling-leather-fur-coat
 on 7/4/2018 8:02 AM

sunny day quotes

The first function Get-WebFile is taken from Poshcode.org and slightly modified to stop overwriting existing files (you will have to delete partially downloaded files manually) and ignore if files did not exist.
 I like this post that amazing and interesting. Thanks for share!
 on 9/19/2018 10:38 PM

sunny day quotes

The first function Get-WebFile is taken from Poshcode.org and slightly modified to stop overwriting existing files (you will have to delete partially downloaded files manually) and ignore if files did not exist.
 I like this post that amazing and interesting. Thanks for share!
http://2quotes.net/life-quotes/sunny-day-quotes-happiness-is-a-sunny-day.html
 on 9/19/2018 10:39 PM

Re: PowerShell script to download session videos from SharePoint Conference '11

Hopefully this script will also help me in downloading https://www.essayuniverse.net/essayvikings-review/. Those assignments are post online on powerpoint. And I don’t know how to access them easily.
 on 10/14/2018 9:44 AM

whatsapp

If you want to get them excited about you, WhatsApp status is one of the best possible ways to make them see green where you're concerned: Check Out the best whatsapp status lines
https://www.digitalocean.com/community/users/davinben
 on 2/4/2019 11:44 AM

Great

 on 2/7/2019 8:04 AM

Thanks

 on 2/7/2019 8:04 AM

cheap mink eyelashes

That is one of the perfect types good fake eyelashes https://www.topeyelashserums.com/ of eyes. Like two huge woolly teddy bears out of some children's book they cheap mink lashes https://www.howtogroweyelashes.org/ looked. Once you attach false eyelashes, you will need to take proper care of cheap fake eyelashes https://lifethroughmylashes.com/ your eye and lashes. Step one 1: Aerosol the eyelashes on the eyelashes and squirt the eyelashes to dry
Different from the usual motion of eyelash, prior to the eyelash in the pillow of the 3d mink eyelash vendors https://cheapminklashes.com/ cushion aerosol on the eyelash fixed spray, be sure you spray spray in every place of the cushion, then put one side a d put it off it to be dry.
 on 5/12/2019 10:34 PM

Fortnite Juul

Fortnite Phone Case - Juul Case will be the newbies to the lash market, and are also not often discussed in the man made vs. If you have pet animal allergies, these https://fortnitephonecase.com/ might not exactly be for you. They'll also cost you a lot more than a artificial lash set, and be warned!
 on 5/12/2019 10:35 PM

Sofia Neo

The principal capacity Get-WebFile is taken from Poshcode.org and marginally altered to quit overwriting existing records (you should erase halfway downloaded documents physically) and disregard if records did not exist.
https://www.samishleather.com/
I like this post astonishing and intriguing. A debt of gratitude is in order for offer!
 on 5/28/2019 1:01 AM
1 - 10Next

Add Comment

Title


Body *


Migrated Source URL


Commentator Name


Commentator Email


BotCheck *


Are you human? What is the sum of fifty-two minus ten?

Attachments