Created
May 15, 2017 18:50
-
-
Save jdhitsolutions/8fd6be458c2cbb7b8bbb8073c83fda89 to your computer and use it in GitHub Desktop.
A PowerShell script to download video podcasts from Todd Klindt
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
#Requires -version 4.0 | |
<# | |
This is a script but it supports -Whatif and accepts parameters. | |
#> | |
[cmdletbinding(SupportsShouldProcess)] | |
Param ( | |
[Parameter(Position = 0, HelpMessage = "Enter the path where you want to save the downloads")] | |
[ValidateNotNullorEmpty()] | |
[ValidateScript({Test-Path $_})] | |
[string]$Path = "D:\temp", | |
[ValidateScript({$_ -gt 0})] | |
[int]$Newest = 10 | |
) | |
$uri = "http://www.toddklindt.com/netcast/WMVSmall/feed-wmv.rss" | |
#modify security so that the download will be over https | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
$data = Invoke-RestMethod $uri | |
$data | Select Title,Summary, | |
@{Name="Length";Expression = {$_.duration -as [timespan]}}, | |
@{Name="Published";Expression = {$_.pubdate -as [datetime]}}, | |
@{Name="SizeMB";Expression = {[math]::round($_.enclosure.length/1MB,2)}},Link | | |
Sort Published -Descending | Select -First $Newest | | |
Out-GridView -title "Select one or more Todd Klindt video podcasts to download" -PassThru | | |
foreach { | |
$name = Split-Path $_.link -Leaf | |
$out = Join-path -Path $path -ChildPath $name | |
Write-host "Downloading $($_.link) to $out over HTTPS" -ForegroundColor Green | |
if ($pscmdlet.ShouldProcess($out)) { | |
Invoke-WebRequest -Uri $_.link -UseBasicParsing -OutFile $out | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment