Skip to content

Instantly share code, notes, and snippets.

@adamvr
Created March 1, 2012 04:52
Show Gist options
  • Save adamvr/1947360 to your computer and use it in GitHub Desktop.
Save adamvr/1947360 to your computer and use it in GitHub Desktop.
A script for downloading 'This American Life' episodes
tal.sh
A script for downloading 'This American Life' episodes
Requires:
rtmpdump
id3v2
curl
#!/bin/sh
usage() {
echo "Usage: `basename ${0%%.sh}` <episode_number>" 1>&2
exit 1
}
nexist() {
echo "Episode $1 does not exist" 1>&2
exit 2
}
echo Script starting...
[ $# -ne 1 ] && usage
ep=$1
info=http://www.thisamericanlife.org/radio-archives/episode/${ep}
rtmp=rtmp://wbez.fcod.llnwd.net/a3989/o35/thislife/jomamashouse/ismymamashouse/${ep}.mp3
echo Getting episode information...
curl -sfX HEAD $info || nexist $ep
title="$(curl -sL $info |
grep '<title>' |
sed 's/<[^<]*>//g' |
sed 's/ | /;/;s/^ *//' |
awk -F';' '{print $1}')"
echo Downloading episode number $ep - $title
output="$(echo NPR_${title}.mp3 | sed 's/ /_/g')"
#echo $output
rtmpdump -r $rtmp -o $output 2>/dev/null && echo Download complete || echo Download failed
echo Setting tags
id3v2 -a 'Chicago Public Radio' -A 'This American Life' -t "$title" -T "$ep" $output
echo Done
@EBADBEEF
Copy link

rtmpdump -q -r "rtmp://wbez.fcod.llnwd.net/a3989/o35/thislife/jomamashouse/ismymamashouse/${ep}.mp3" -o "${ep}.flv"
ffmpeg -v 0 -i "${ep}.flv" -acodec copy "${ep}.mp3" && rm "${ep}.flv"

@eriken
Copy link

eriken commented Sep 26, 2015

#!/bin/sh

usage() {
  echo "Usage: `basename ${0%%.sh}` <episode_number>" 1>&2
  exit 1
}

nexist() {
  echo "Episode $1 does not exist" 1>&2
  exit 2
}

echo Script starting...

[ $# -ne 1 ] && usage

ep=$1
info=http://www.thisamericanlife.org/radio-archives/episode/${ep}
hls=http://stream.thisamericanlife.org/${ep}/stream/${ep}_64k.m3u8
echo Getting episode information...

curl -sfX HEAD $info || nexist $ep

echo Downloading episode number $ep

ffmpeg -loglevel panic -i $hls -vn -acodec mp3 "${ep}.mp3" && echo Download complete || echo Download failed

echo Done

This should work after they moved to hls streaming, no ID3 though, just simple download.

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