Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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))
@recklessop

This comment has been minimized.

Copy link

recklessop commented Nov 12, 2019

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

@rjesh-git

This comment has been minimized.

Copy link
Owner Author

rjesh-git commented Nov 12, 2019

Thanks Justin! I have incorporated the changes with some refactoring.

@nbarkhina

This comment has been minimized.

Copy link

nbarkhina commented Nov 12, 2019

I don't understand this, did they even upload the videos yet to the web?

@michelderooij

This comment has been minimized.

Copy link

michelderooij commented Nov 13, 2019

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

@awilmer

This comment has been minimized.

Copy link

awilmer commented Nov 19, 2019

Thanks, good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.