Hacker Public Radio

HPR3959: Download any HPR series with english file names


Listen Later

Hello all. This is gemlog from Terrace, bc, canada just up near the
alaska panhandle.
Some of you may know me from in COM chat on sdf dot org or as a
fedizen on the tilde dot zone instance of mastodon.
Now, the other day I finally got around to checking out HPR properly,
even though my masto-pal claw-dio-m turned me on to it a couple of years
ago.
Recently, on a friday night in irc on tilde radio, I noticed there
were whole series on hpr and not only single shows and that got me kind
of excited.
I guess I'm easily excitable.
Anyhow, something I could listen to at work or while driving. Still,
I managed to forget about it until /just/ before I was leaving the house
for work on Monday morning. I rushed to copy over a few shows - nearly
at random onto my phone and headed out to work.
After I got my morning sorted at work, I told VLC to play-all and
enjoyed a couple of shows. I noticed that each show I had chosen had a
beg post at the beginning. I figured I could make one on at least
something from my messy gemlog/bin dir.
However, after a break, I came back and couldn't remember which 4
digit numbered dot mp3 I had finished up on, which mildly irked me.
Well, as we all know, irk becomes itch and I put my sad regex skills to
the test scraping the hpr website with a custom bash script later when I
got home.
A very custom bash script. Like all scrapers, if any of the guys at
hpr even breathe the wrong way, it will probably break horribly. On the
other hand, I've had scrapers that looked just as sad running for many
years against a canadian government site. So. Who knows?
All the script uses are some built-ins from bash along with sed and
wget for the actual getting. My local instance of searX N G was left
smoking as scrambled for sed incantations to string together. I'm not a
sed guy.
Usage is simple, as the script only accepts one argument: ... the
four digit series number of the show you want to download. It will
create a dir with the series name and download every mp3 it finds,
renaming each show to the show title.
I was tempted to doll it up with some niceties like options for
download dir, a selector for a series with a dialog of some kind... yada
yada yada.
But... we all know what happens when you stretch a quick hack with a
bash script too far for the scripting language: hours of misery wishing
you'd started with some other language.
So far, I've used the script to download 8 series. DU dash S H tells
me they add up to 2 dot 2 gig, so it seems to work well enough.
It comes with the same iron clad warranty as everything I write:
If it breaks, you get to keep all the pieces. Thanks for
listening.
#!/bin/bash
# [email protected] 2023-08-26
# License: CC BY-SA 4.0.
# not proud of my continuing lack of regex foo frankly...
if [ $# -lt 1 ]; then
echo 1>&2 "$0: You need to enter the HPR Series Number to download as 4 digits"
echo "The full list of HPR Series is at https://hackerpublicradio.org/series/index.html"
exit 2
fi
snumber=$1
re='^[[:digit:]]{4}$'
if [[ $snumber =~ $re ]]; then
wget https://hackerpublicradio.org/series/$snumber.html -q -O /tmp/$snumber.html
content=$(</tmp/$snumber.html)
declare -a shows
shows=$(grep -P '^(?=.*h3)(?=.*title)' /tmp/$snumber.html)
else
echo "'$snumber' is not exactly 4 digits like an HPR series number"
exit 2
fi
series=$(echo $content | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | grep -o -P -m1 '(?<=In-Depth Series:).*(?=Number)' | sed 's/[ t]*$//' )
series=$(echo ${series// /_} | cut -b 2-50 | sed 's/_*$//' | sed 's/^_*//' | sed s/[^A-Za-z0-9_.]/_/g)
#outdir="/home/gemlog/Music/Audio/HPR/$series-Se$snumber/"
outdir=~/"Downloads/HPR/$series-Se$snumber/"
mkdir -p "$outdir"
echo "Files for the ser
...more
View all episodesView all episodes
Download on the App Store

Hacker Public RadioBy Hacker Public Radio

  • 4.2
  • 4.2
  • 4.2
  • 4.2
  • 4.2

4.2

34 ratings


More shows like Hacker Public Radio

View all
The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

289 Listeners

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec by Jerry Bell and Andrew Kalat

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec

373 Listeners

LINUX Unplugged by Jupiter Broadcasting

LINUX Unplugged

268 Listeners

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast) by Johannes B. Ullrich

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast)

653 Listeners

Curious Cases by BBC Radio 4

Curious Cases

826 Listeners

The Strong Towns Podcast by Strong Towns

The Strong Towns Podcast

422 Listeners

Late Night Linux by The Late Night Linux Family

Late Night Linux

164 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

8,035 Listeners

Cybersecurity Today by Jim Love

Cybersecurity Today

181 Listeners

CISO Series Podcast by David Spark, Mike Johnson, and Andy Ellis

CISO Series Podcast

189 Listeners

TechCrunch Daily Crunch by TechCrunch

TechCrunch Daily Crunch

42 Listeners

Strict Scrutiny by Crooked Media

Strict Scrutiny

5,799 Listeners

2.5 Admins by The Late Night Linux Family

2.5 Admins

98 Listeners

Cyber Security Headlines by CISO Series

Cyber Security Headlines

139 Listeners

What the Hack? by DeleteMe

What the Hack?

221 Listeners