Gpodder Post-Download Scripts

I’ve been an avid podcast listener ever since I bought my first (and so far only) mp3 player back in 2007.   To download and manage my podcasts I use Gpodder – it’s the best “podcatcher” software I’ve found for Linux/Gnome and it works on Windows too.  Gpodder has a very useful (but seemingly little known) feature that allows you to run a script every time a podcast is downloaded.  It’s handy because it allows you to process the downloaded audio or video file automatically before you listen to it.

My aforementioned 4-year old mp3 player is a Cowon D2.  It’s a great little player that plays both mp3 and ogg vorbis. Cowon only recently discontinued it.  I use it mainly for audio but it has a small video screen that I occasionally watch: video podasts mostly but I’ve also been known to watch NHL or NFL games on it.

The problem with video podcasts is that they’re usually formatted for the Ipod and are the wrong size and format for the D2.  That’s where the post-download scripts for Gpodder come in.  I’ve written some bash scripts that use ffmpeg to convert any downloaded video into a format compatible with the D2.  Gpodder runs the script as soon as the download is complete, the script reformats the video file and updates the Gpodder database.  Then I can sync and watch the video on my D2 without even having to think about converting it.

I never seem to have enough time to listen to all my podcasts these days (those Linux Outlaws guys are great but they can go on).  To help with the problem I’ve added in a script that speeds up audio podcasts.  It uses soundstretch to speed up the audio without affecting the pitch.  It makes everyone sound like they’re speaking frantically but it also saves me a lot of listening time.  I got it to work with both mp3 and ogg podcasts.


I wrote these scripts some time ago for my own use.  In case anyone else would find them useful I’m going to post them here.  They’re free to use or modify as you like.  If you do make any cool changes I’d be happy if you shared them with me.  Just remember I’m no programmer and far from a bash expert.

Ok, on to the scripts themselves.  Obviously they’re meant for formatting media compatible with the Cowon D2 but it shouldn’t be hard to modify the scripts to work for any player (as long ffmpeg can generate the required format).  I put a little effort into setting all the output parameters at the beginning of the scripts, so you should be able to specify any output format just by modifying those parameters.

I also tried to make the scripts somewhat intelligent about choosing the parameters it uses for the newly converted video and audio.  It will try to make full use of the screen size but never make the video any bigger.  The original aspect ratio is preserved. Audio will be down-sampled to a maximum bitrate (that you set) but it’s never needlessly up-sampled.  And so on. You can read the scripts themselves for commentary about what exactly they do.

There are several dependencies: ffmpeg, zenity, mediainfo, soundstretch, lame, vobis-tools, id3cp, sqlite3 – they should all be easily available on most Linux distros.  If you use Windows, Cygwin is probably your only hope but I have no idea if it’ll work.  All the best to you.

One note about ffmpeg: it seems to change regularly, often breaking backward compatibility.  These scripts work for me using the version of ffmpeg included with Ubuntu 10.10 – but it’s likely that in the future an ffmpeg update will make it necessary to alter the ffmpeg commands in the script.

There are a 5 scripts in all.  I’ve made them available in a .tar.gz archive at this link.

The scripts are all in bash.  The main script is called:  gpodder_download_complete

The audio and video conversion functions have been separated out into their own scripts called: convert_audio and convert_video

Put these scripts somewhere convenient like ~/scripts/gpodder and make sure they’re executable.  If you put them somewhere other than the above location you’ll need to edit lines 41 and 81 of gpodder_download_complete so it correctly points at convert_audio and convert_video.

Next, to get Gpodder to execute it: in the Gpodder menu go to Podcasts > Preferences and click the ‘Edit Config’ Button (this is for Gpodder 2.15 – other versions may be slightly different).  Find the cmd_download_complete parameter and add in the full path to the gpodder_download_complete script.  Now every time Gpodder downloads a podcast it will execute the script and convert it.

Finally, by separating out the audio and video conversion functions, I was able to write other scripts that utilize those functions.  To let me convert audio or video files independently of Gpodder, I wrote some Nautilus Scripts that let me do conversions in the same way but within Nautilus, just by right-clicking on the media file and selecting the script.  These scripts are called Audio Speedup and Video Converter.  If you want to use them you’ll need to put them in ~/.gnome2/nautilus-scripts and make sure they’re executable.  Also make sure they have the correct paths to convert_audio and convert_video (see line 37 of Audio Speedup and line 30 of Video Converter).

That’s it.  If you try these scripts I hope they work for you.  I’ll be happy to hear any feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>