Last active
December 17, 2020 20:07
-
-
Save rjesh-git/ee3e21cd966e8c7186bea6d9fd766b5c to your computer and use it in GitHub Desktop.
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
# Author Rajesh Sitaraman | |
# @rjesh | rjesh.com | |
<# | |
.SYNOPSIS | |
Download Ignite 2019 session presentation slides and videos. | |
.EXAMPLE | |
PS C:\> .\Get-IgniteContent.ps1 -DownloadPath /Users/rajeshsitaraman/src/public/share/IG-2019 -Keyword "AI" | |
.EXAMPLE | |
PS C:\> .\Get-IgniteContent.ps1 -DownloadPath /Users/rajeshsitaraman/src/public/share/IG-2019 -Keyword "Teams" -IncludeVideos | |
.EXAMPLE | |
Downloads all sessions -- Might take very long time | |
PS C:\> .\Get-IgniteContent.ps1 -DownloadPath /Users/rajeshsitaraman/src/public/share/IG-2019 | |
#> | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory = $true, Position = 1)] | |
[String]$DownloadPath, | |
[Parameter(Mandatory = $false, Position = 2)] | |
[String]$Keyword, | |
[Parameter(Mandatory = $false, Position = 3)] | |
[Switch]$IncludeVideos | |
) | |
$itemsPerPage = 100 | |
$page = 1 | |
$response = $null | |
If (-Not (Test-Path -Path $DownloadPath -PathType Container)) { | |
New-Item -Path $DownloadPath -ItemType directory | Out-Null | |
} | |
function Get-File { | |
param([Parameter(Mandatory=$true)][string] $FilePath, [Parameter(Mandatory=$true)][string] $URI) | |
if (Test-Path $FilePath -PathType Leaf) { | |
Write-Host "Skipping $FilePath already exists." -ForegroundColor Red | |
}else { | |
If ($PSVersionTable.PSEdition -eq "Core") { | |
Invoke-WebRequest -Uri $URI -OutFile $FilePath | |
} | |
Else { | |
Start-BitsTransfer -Source $URI -Destination $FilePath | |
} | |
} | |
} | |
if (!$Keyword) { $searchText = "" } else { $searchText = $Keyword} | |
do { | |
$body = @{ | |
"itemsPerPage" = $itemsPerPage | |
"searchText" = $searchText | |
"searchPage" = $page | |
"sortOption" = "None" | |
"mustHaveOnDemandVideo" = $true | |
} | |
$params = @{ | |
Headers = @{"Content-type"="application/json"} | |
Body = $body | convertto-json | |
Method = "Post" | |
URI = "https://api-myignite.techcommunity.microsoft.com/api/session/search" | |
} | |
$response = Invoke-RestMethod @params | |
foreach ($item in $response.data) { | |
$name = $item.Title -replace '[\W]', ' ' | |
$name = $name.Substring(0,[System.Math]::Min(50, $name.Length)) | |
Write-Host "Downloading -- $($item.sessionCodeNormalized)" -ForegroundColor Green | |
if ($item.slideDeck) {Get-File -URI $item.slideDeck -FilePath "$DownloadPath/$($item.sessionCodeNormalized)-$name.pptx"} | |
if ($item.downloadVideoLink -and $IncludeVideos) {Get-File -URI $item.downloadVideoLink-FilePath "$DownloadPath/$($item.sessionCodeNormalized)-$name.mp4"} | |
} | |
$page +=1 | |
} until ($page -gt ($($response.total)/$itemsPerPage)) |
I don't understand this, did they even upload the videos yet to the web?
Nice, but limited. Maintaining a session download script for years now, can get direct links as well as other quality streams (significant less space), filtering options, resuming, captions, etc. See https://github.com/michelderooij/Get-EventSession
Thanks, good job!
Great script! I added a couple of if statements to check if the file already exists so that I could "resume" downloading stuff if my terminal session was closed. Lines 68-85 are what I changed: https://gist.github.com/recklessop/6e26d53ee8ea9717d2fdaede3b709e62
How can I do to download the PPT for Ignite 2020?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Justin! I have incorporated the changes with some refactoring.