Downloading Videos From German Media Databases

by May 5, 2017

In Germany, there are publicly available media databases with most of the TV content broadcasted by public stations. It just takes very little PowerShell code to extract the JSON data, display the TV shows in a list, and let you select some for download.

Note however that the JSON file with the download URLs is quite large, so it may take a moment for the video list to appear.

#requires -Version 3.0

# here is the list of download URLs - get it and 
# convert the JSON format
$url = ''
$web = Invoke-WebRequest -Uri $url -UseBasicParsing 
$videos = $web.Content | ConvertFrom-Json 

# get all videos, create a nice title to display,
# and attach the original data to each entry
$videos |
ForEach-Object {
  $title = '{0} - {1}' -f $_[2], $_[5]
  $title | Add-Member -MemberType NoteProperty -Name Data -Value $_ -PassThru
} |
Sort-Object |
Out-GridView -Title 'Video' -OutputMode Multiple |
ForEach-Object {
  # get the actual download info from the selected videos
  # and do the download
  $url = $_.Data[6]
  $filename = Split-Path -Path $url -Leaf
  # videos are saved into your TEMP folder unless you
  # specify a different folder below
  $filepath = Join-Path -Path $env:temp -ChildPath $filename
  Invoke-WebRequest -Uri $url -OutFile $filepath -UseBasicParsing
  Invoke-Item -Path $filepath

Twitter This Tip! ReTweet this Tip!