Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Download all Ben & Liam podcasts to your local computer
$downloadlocation = "$env:USERPROFILE\downloads\BenLiam"
if(!(Test-Path $downloadlocation)) {New-Item -Path $downloadlocation -ItemType Directory}
# Get all the podcasts
$CompletePodcasts = @()
$page = 1
do {
$URL = "$page&"
$result1 = Invoke-WebRequest -Uri $URL | ConvertFrom-Json
$CompletePodcasts += $result1.items | Select-Object post_title, podcast_duration, post_posted_on, podcast_source_url
} until (!$result1.items)
# download all the podcasts
ForEach($CompletePodcast in $CompletePodcasts) {
$ContentType = ((Invoke-WebRequest -Uri $CompletePodcast.podcast_source_url).headers)['Content-Type']
$date = (get-date ($CompletePodcast.post_posted_on) -Format yyyyMMdd)
# Remove all special charactors from the title
$filename = $CompletePodcast.post_title -replace '[^0-9a-zA-Z\s,].?'
if(!(Test-Path ("$downloadlocation\$date $filename.mp3")) -and $ContentType -eq 'audio/mpeg'){
Invoke-WebRequest -Uri $CompletePodcast.podcast_source_url -OutFile "$downloadlocation\$date $filename.mp3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment