Downloading or streaming podcasts from BBC from linux shell.

I like listening to podcasts when I code. Not only I get to learn something when I am doing mundane tasks but it also acts as a white noise when I am concentration on the task at hand. So recently I wanted to download this podcast from bbc as mp3 files on to my laptop so that I can listen to them offline during my commute. I would have ususally done it manually but with my newly learned shell knowlege, I did it with this script instead.

#! /bin/zsh


for PAGE in {0..5};
  if [ $PAGE = 0 ]; 
    then PAGE="" else PAGE="\?page\=$i" 
  echo "$URL$PAGE " ; 
done \
  | xargs curl \
  | grep -Po 'href="\K.*?(?=")' \
  | grep ".mp3" \
  | grep "low" \
  | xargs wget

The for loop creates 6 loops for each page in the downloads section. The if else condition appends the page number and formats the urls. xargs then passes this url into curl to get the contents of the page. grep then searches the returned page for links. The second and third greps search only for the links with words “.mp3” and ‘low’ in them. The second xargs converts them into arguments and passes to wget which then downloads those links to disk. When we run the command, we go through all six pages and download all the low quality mp3s for each episodes.

As a bonus we can then rename the resulting files based on the information on their id3 tags. using the id3 utility.

> id3 -f "%y_%t.mp3" *.mp3

This will rename all the files with the format “year_title.mp3”.

If we dont want to download them to disk but send them to vlc as a playlist for streaming, then we can do xargs vlc rather than xargs wget at the end.

2 thoughts on “Downloading or streaming podcasts from BBC from linux shell.”

  1. Hi Bala, I use YouTube-dl ( from the command line. It works well with BBC downloads. Combined with html-xml-utils, the following prepares a download command of available episodes:

    echo “youtube-dl $(curl “” | hxnormalize -x | hxwls -b ‘’ | grep ‘#play’ | cut -d ‘#’ -f 1 | tr -s ‘\n’ ‘ ‘)”

    Hope all’s well with you! Rowan

Leave a Reply