Skip to content

Instantly share code, notes, and snippets.

Embed
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 = "https://www.novafm.com.au/wp-json/nova/v1/infinite-scroll-posts?query_name=episodes&post_type=episode&meta_key=podcast_319425&paged=$page&__amp_source_origin=https%3A%2F%2Fwww.novafm.com.au"
$result1 = Invoke-WebRequest -Uri $URL | ConvertFrom-Json
if($result1){
$CompletePodcasts += $result1.items | Select-Object post_title, podcast_duration, post_posted_on, podcast_source_url
$page++
}
} 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