BashPodder mod – add podcasts to iTunes

As a podcatcher (among other things), iTunes sucks. Badly. iPodder is nicer, mainly because I can keep my follow list in the cloud at PodNova. However, it (or the combination with podnova) often ends up downloading gigs of old stuff, on some particular feeds. Worse, it consumes obscene quantities of memory and CPU, with its UI being unresponsive to the point of being unusable, like 30 second or more delays for each gesture. This is on an early macbook.

Anyway, I decided to rectify the situation and go back to bashpodder, a tiny shell script which proves the point that a podcatcher need not be grandiose, nor a resource gobbler. It’s also cool as it’s easily customisable for anyone with some bash-fu. I modded it a few years back to keep my follow list in the cloud. (I believe clouds were called “servers” back then.)

I’ve recently modded bashpodder to add files to iTunes. Yes, I still like iTunes and I definitely like the i* players which are, for most intents and purposes, constrained to the universe of iTunes. As for it’s podcatcher, not cool. The interface for exploring podcasts is cumbersome, and the result, the downloaded podcasts, are not handle with care. For example, if you download podcasts with iTunes, it marks them out specially as podcasts, and there’s no way to, say, delete all podcasts older than a week. If they’re normal tracks added from an external catcher, they’re just regular MP3s and you can do what you like with them. And you can’t keep your follow list in the cloud!

So here’s bashpodder modified to add to itunes. (The itunes part I added is the HERE doc section beginning with /usr/bin/osascript. You could easily extend it to, say, tag podcasts from certain feeds with a certain album name.)

Click on “Plain Text” and cut-and-paste it into a shell file. Easiest would be to download the several files required for bashpodder (there should be a mod to make it just a single self-modifying file), and replace contents with that below.


  1. #!/bin/bash
  2. # By Linc 10/1/2004
  3. # Find the latest script at
  4. # Revision 1.2 09/14/2006 - Many Contributers!
  5. # If you use this and have made improvements or have comments
  6. # drop me an email at linc dot fessenden at gmail dot com
  7. # I'd appreciate it!
  9. # Make script crontab friendly:
  10. cd $(dirname $0)
  12. # datadir is the directory you want podcasts saved to:
  13. datadir=$(date +%Y-%m-%d)
  15. # create datadir if necessary:
  16. mkdir -p $datadir
  18. # Delete any temp file:
  19. rm -f temp.log
  21. # Read the bp.conf file and wget any url not already in the podcast.log file:
  22. while read feed
  23.   do
  24.   podcast=`echo $feed | cut -f 1 -d ' '`
  25.   echo $podcast
  26.   file=$(xsltproc parse_enclosure.xsl $podcast 2> /dev/null || wget -q $podcast -O - | tr 'r' 'n' | tr ' " | sed -n 's/.*url="([^"]*)".*/1/p')
  27.   for url in $file ; do
  28.     echo "Retrieving $url"
  29.     echo $url >> temp.log
  30.     if ! grep "$url" podcast.log > /dev/null
  31.       then
  32.       # wget -t 10 -U BashPodder -c -q -O $datadir/$(echo "$url" | awk -F'/' {'print $NF'} | awk -F'=' {'print $NF'} | awk -F'?' {'print $1'}) "$url"
  33.       outpath=$datadir/$(echo "$url" | awk -F'/' {'print $NF'} | awk -F'=' {'print $NF'} | awk -F'?' {'print $1'})
  34.       curl --retry 10 -C - $url > $outpath
  35.       fullpath=`pwd`/"$outpath"
  36.       /usr/bin/osascript <<-EOF
  37.         tell application "iTunes"
  38.           set posix_path to "$fullpath"
  39.           set mac_path to posix_path as POSIX file
  40.           set new_track to add mac_path
  41.           set genre of new_track to "*Podcast"
  42.         end tell
  43. EOF
  44.     fi
  45.     done
  46.   done < bp.conf
  47. # Move dynamically created log file to permanent log file:
  48. cat podcast.log >> temp.log
  49. sort temp.log | uniq > podcast.log
  50. rm temp.log
  51. # Create an m3u playlist:
  52. ls $datadir | grep -v m3u > $datadir/podcast.m3u

4 thoughts on BashPodder mod – add podcasts to iTunes

  1. I see osascript saying,

    execution error: The variable new_track is not defined.

    … when I run the modified script. I don’t know enough about applescript to debug the problem at this point. Does this problem sound familar to you?

  2. A straightforward response is always helpful; even if it’s “I don’t know.” 🙂

    It’s a lot more than the entirety of my applescript knowledge.

    I have some inclination to buy an applescript book and use the doug’s scripts examples to enable me to get your mod working on my computer, but we’ll see. I’ll let you know if I find a change that makes it work on my computer.

    Thanks for the response.

Leave a Reply