Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr3962 :: It's your data

Ken shows a safer way to get episodes from HPR

<< First, < Previous, , Latest >>

Thumbnail of Ken Fallon
Hosted by Ken Fallon on 2023-10-10 is flagged as Clean and is released under a CC-BY-SA license.
response, bash, rss, xml, xmlstarlet. (Be the first).
The show is available on the Internet Archive at: https://archive.org/details/hpr3962

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:07:22

Bash Scripting.

This is an open series in which Hacker Public Radio Listeners can share their Bash scripting knowledge and experience with the community. General programming topics and Bash commands are explored along with some tutorials for the complete novice.

This is a response show to hpr3959 :: Download any HPR series with english file names "A dir with the series name will be created and all shows will be renamed to ShowTitle.mp3 inside it"

This was the first show by gemlog and he used Bash, sed, grep, wget, to scrape the HPR site. This is great but as he points out any change to the site will break the script.

A safer way to get the episodes is by scraping the rss feed, and the following is an example of how you might do that

#!/bin/bash

series_url="https://hackerpublicradio.org/hpr_mp3_rss.php?series=42&full=1&gomax=1"
download_dir="./"

wget "${series_url}" -O - | xmlstarlet sel -T -t -m 'rss/channel/item' -v 'concat(enclosure/@url, "→", title)' -n - | sort | while read episode
do
  url="$( echo ${episode} | awk -F '→' '{print $1}' )"
  ext="$( basename "${url}" )"
  title="$( echo ${episode} | awk -F '→' '{print $2}' | sed -e 's/[^A-Za-z0-9]/_/g' )"
  wget "${url}" -O "${download_dir}/${title}.${ext}"
done

Comments

Subscribe to the comments RSS feed.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
What is the HOST_ID for the host of this show?
What does HPR mean to you?