$data = Get-Content-Path$Path-Raw | ConvertFrom-Json | ForEach-Object { $_ } | ForEach-Object { # define a string describing the video. This string will be shown in a grid view window $title = '{0,5} [{2}] "{1}" ({3})'-f ([Object[]]$_) # add the original data to the string so when the user select a video, # the details i.e. download URL is still available $title | Add-Member-MemberType NoteProperty -NameData-Value$_-PassThru }
$data | Sort-Object | Out-GridView-Title'Select Video(s)'-OutputMode Multiple | ForEach-Object { # take the download URL from the attached original data $url = $_.Data[5] $filename = Split-Path-Path$url-Leaf $filepath = Join-Path-Path$env:temp-ChildPath$filename $title = 'Video download {0} ({1})'-f$_.Data[1], $_.Data[0] Start-BitsTransfer-Description$title-Source$url-Destination$filepath # you can use a simple web request as well in case BITS isn't available # Invoke-WebRequest -Uri $url -OutFile $filepath -UseBasicParsing
# open video in associated player Invoke-Item-Path$filepath }