Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save visualblind/20d621a84ab68e23c6d8426bb9428284 to your computer and use it in GitHub Desktop.

Select an option

Save visualblind/20d621a84ab68e23c6d8426bb9428284 to your computer and use it in GitHub Desktop.
Shell and PowerShell Scripts to Download Sam Harris Making Sense Full Subscriber Podcast Episodes for Free
#https://blog.travisflix.com/download-sam-harris-making-sense-full-subscriber-podcast-episodes-for-free/
# Tested with PowerShell 5.1 on Windows and PowerShell 7.5.4 on Linux
# Fetch RSS feed and extract MP3 URLs and output to file
(Invoke-WebRequest -Uri 'https://rss.samharris.org/feed/5b624f14-e923-4a75-aeb9-77d11773fb91').Content -split "`n" |
Where-Object { $_ -like '*mp3*' } |
ForEach-Object {
$_ -replace ' <enclosure length="0" type="audio/mpeg" url="' -replace '"/>'
} | Out-File -FilePath '.\feed5b624f14.txt' -Encoding utf8
# Download files (skip if already exist)
$urls = Get-Content -Path '.\feed5b624f14.txt'
foreach ($url in $urls) {
$filename = [System.IO.Path]::GetFileName($url.Split('?')[0])
$destinationPath = Join-Path -Path $pwd.Path -ChildPath $fileName
if (-not (Test-Path $destinationPath)) {
Invoke-WebRequest -Uri $url -OutFile $filename
}
}
#!/usr/bin/env bash
#https://blog.travisflix.com/download-sam-harris-making-sense-full-subscriber-podcast-episodes-for-free/
# This version downloads the latest episode and then prompts asking you whether you
# would like to continue downloading the rest or not.
SKIP=false;curl -s 'https://rss.samharris.org/feed/5b624f14-e923-4a75-aeb9-77d11773fb91'|grep '.mp3'| \
sed -E 's/\s+<enclosure length="0" type="audio\/mpeg" url="//;s/"\/>//' >./feed5b624f14.txt&& \
while read url;do filename=${url##*/};filename=${filename%%\?*}; echo "Processing record: $filename"
wget -c -nc $url -O $filename; [ "$SKIP" = false ] && \
read -p "Do you want to continue downloading the rest? (Yy/Nn):" Q </dev/tty
[[ $Q =~ [Yy] ]] && SKIP=true || break; done <feed5b624f14.txt
#!/usr/bin/env bash
#https://blog.travisflix.com/download-sam-harris-making-sense-full-subscriber-podcast-episodes-for-free/
# If you only want the latest podcast episode instead of downloading all of them, you can add
# a break; right after the wget command which would be the last command before the done command.
curl -s 'https://rss.samharris.org/feed/5b624f14-e923-4a75-aeb9-77d11773fb91' | grep '.mp3' | \
sed -E 's/\s+<enclosure length="0" type="audio\/mpeg" url="//;s/"\/>//' > ./feed5b624f14.txt && \
while read url; do filename=${url##*/}; filename=${filename%%\?*}; wget -c -nc $url -O $filename; done < feed5b624f14.txt
@visualblind
Copy link
Copy Markdown
Author

Very cool - thanks

No prob 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment