Last active
December 10, 2020 00:53
-
-
Save marckean/cda912af6e972f2afc861eb12a1f3343 to your computer and use it in GitHub Desktop.
Download all Ben & Liam podcasts to your local computer
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
$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