My name is Phil Lewis. I am a Linux geek who likes to code mainly in Perl. I’m really quite fanatical about Linux and have been using it on the desktop exclusively since late 1993 (that makes me feel old!).
Unusually I also like Beer (the Real Ale variety). I’ve been a CAMRA member for a long time and try to get involved in serving at the Reading Beer and Cider Festival each year.
I work as a Senior Linux Systems Administrator for Nexagent. Nexagent was acquired in March ‘08 by the unmentionable company that was acquired by HP in Q3 2008. I’ve also worked for Amazon.co.uk, Adeptra, Electec (Singapore) and Electric Eye (Singapore). I ran my own Linux/Security/Networking contracting and consultancy company (Secure Networking Ltd) from 1999 until 2003 and had Compaq and HP as major clients.
I graduated with a degree in Electronic and Electrical Engineering from University of Birmingham in 1994 and now I live in South Oxfordshire, UK.

hi phil
pibs here call me thick but when i try to download the i player thing all i get is pages of writting now not being computerlitrate what does it do lol
can you put and idiots version up cheers me dears form the very sunny middle east
pibs
@pibs,
Hi, try looking at using the ‘Windows Automated Installer’ under http://linuxcentre.net/getiplayer/installation/
Hi Phil
Thanks for your fantastic script - it’s completely changed my working day having previously run out of fresh things to listen to from my podcast selection! Anyway, I thought you might be able to share or modify and share this script I’m using. It’s a bash script that runs get_iplayer’s pvr every hour to download my subscriptions, then uses eyeD3 to tag the audio files with episode/show info, and renames and moves all downloaded video and audio to a network share drive as show/episode.ext. It’s all commented (although probably doesn’t conform to coding standards - I’m still a relative noob with bash.)
If you don’t have space to publish the script, please let me know and I’ll submit this on ubuntuforums instead. Thanks once again for a fantastic tool.
#!/bin/bash# A script to download all pvr subscribed iplayer programmes then parse them
# ID3 tag them (if audio files) and move all files to their related folders on
# a network share drive (audio shared with mt-daap on an unslung NSLU2)
# then remove any files older than ## days
# Please share and repost if you know of better ways to do this
# I'm definitely not a command-line guru, so I'd love feedback
# Dependencies for this script tested in Ubuntu Intrepid
# get_iplayer: wget http://linuxcentre.net/get_iplayer/get_iplayer
# eyeD3: sudo aptitude install eyeD3
# For some reason, rhythmbox doesn’t read the comments field when browsing my mt-daap share,
# so I add a prefix to the artist field in order to sort tracks in date order
# I like to keep all of my files tidy by naming everything in lowercase and spaces converted to hyphens
# When creating the ID3 tag, I add “BBC iPlayer” as the album, and the current year to the year field
if [ \! -f /tmp/iplayer-running ]
then
echo “Running” > /tmp/iplayer-running # Flag script as running
DIR=/home/username/scripts # Loction of get_iplayer script
VIDEO=/home/username/video/iplayer # Where get_iplayer saves its video files - you can set this in iplayer
VIDEOTO=/mnt/video-fink/video/iplayer # Folder to move video files to once parsed
VIDEODAYS=0 # Set number of days to keep recordings
MUSIC=/home/username/music/iplayer # Where get_iplayer saves its audio files - you can set this in iplayer
MUSICTO=/mnt/video-fink/music/iplayer # Folder to move audio files to once parsed
AUDIODAYS=21 # Set number of days to keep recordings
STAMP=$(date ‘+%y%m%d%H%M%S’) # Create a detailed timestamp
PREFIX=$(date ‘+%y%m%d’) # Create a shorter timestamp for using as a prefix in the artist field
LOG=/home/username/log/iplayer-$STAMP.log # Set the location of the log file
if [[ $(date '+%k') -lt 16 ]] # Check to make sure it’s before Plus.net’s peak time
then
$DIR/get_iplayer --pvr # Start get_iplayer’s pvr downloading
fi
# Start sorting out the downloaded music files
cd $MUSIC
for i in *.mp3
do
ID3TAGS=$( echo $i | sed ’s/_default//g’ | sed ’s/\.partial//g’ | sed ’s/_\([a-z0-9]\)\{8\}\.mp3//g’ | sed ’s/_\-_/\`/g’ | tr ‘_’ ‘ ‘ ) # Parse the filename to grab the ID3 data
TITLE=$( echo $ID3TAGS | cut -d ‘`’ -f 2 ) # Get the title field
ARTIST=$( echo $ID3TAGS | cut -d ‘`’ -f 1 ) # Get the artist field
ARTISTFOLDER=$( echo $ARTIST | tr A-Z a-z | tr ‘ ‘ ‘-’ ) # Convert the artist field into a folder name
FILENAME=$( echo $TITLE | tr A-Z a-z | tr ‘ ‘ ‘-’ ) # Convert the title to lowercase hyphened format
eyeD3 -t “$PREFIX $TITLE” -A “BBC iPlayer” -a “$ARTIST” -Y “$( date ‘+%Y’ )” $i # Add ID3 tag to file
mkdir -p $MUSICTO/$ARTISTFOLDER # Create the show folder if it doesn’t exist
mv $i $MUSICTO/$ARTISTFOLDER/$STAMP-$ARTISTFOLDER-$FILENAME.mp3 # Move the file to the folder
echo AUDIO: $TITLE - $ARTIST >> $LOG # Log the result
done
# Start sorting out the downloaded video files
cd $VIDEO
for i in *.mov
do
ID3TAGS=$( echo $i | sed ’s/_default//g’ | sed ’s/\.partial//g’ | sed ’s/_\([a-z0-9]\)\{8\}\.mov//g’ | sed ’s/_\-_/\`/g’ | tr ‘_’ ‘ ‘ ) # Parse the filename to grab the filename data
TITLE=$( echo $ID3TAGS | cut -d ‘`’ -f 2 | tr A-Z a-z | tr ‘ ‘ ‘-’ ) # Get the title of the programme
ARTIST=$( echo $ID3TAGS | cut -d ‘`’ -f 1 | tr A-Z a-z | tr ‘ ‘ ‘-’ ) # Get the name of the series
mkdir -p $VIDEOTO/$ARTIST # Create the series folder if it doesn’t exist
mv $i $VIDEOTO/$ARTIST/$ARTIST-$TITLE.mov # Move the file to the folder
echo VIDEO: $TITLE - $ARTIST >> $LOG # Log the result
done
# Clean up any files older than $VIDEODAYS and $AUDIODAYS
if [[ $VIDEODAYS -gt 0 ]]
then
find $VIDEOTO -mtime +$VIDEODAYS | xargs rm
fi
if [[ $AUDIODAYS -gt 0 ]]
then
find $AUDIOTO -mtime +$AUDIODAYS | xargs rm
fi
rm /tmp/iplayer-running # Remove flag
else
echo “ERROR: get_iplayer already running - closing script”;
fi
exit 0
Sorry Phil… I put the code tags in, but it looks like Wordpress parses newlines as paragraph tags! Messed up your page a bit.
@wayfarer_boy,
Have you looked at the --command (run arbitrary commands with substitution after a successful d/l), --file-prefix (specify a custom filename), and --id3v2 (where your id3v2 binary is to do the id3 tagging) options of get_iplayer. I suspect you could use those to greatly simplify your script. Also, if you are using --pvr, there is already lockfile detection so you don’t need to detect an already running instance of get_iplayer. You can find examples on some of these in http://linuxcentre.net/getiplayer/documentation/ or by running ‘get_iplayer -h’
I just wanted so say thank you for such a great little utility!