Realplayer to mp3: a configurable Python wrapper

It’s one of the worst-kept tech secrets in the world, but Real Audio streams can be downloaded using software such as mplayer and then converted to MP3 format with lame. Both of these are available in Ubuntu using the non-Ubuntu package manager Automatix. The possibility of doing this conversion implies that, although the BBC offer all their programs in Real Audio and only a few as podcasts, you can in principle put any you like on your portable music device.

Similar solutions abound on the web: Tom Taylor has a method involving mencoder; other methods can be found all over the place. However, these all involve a bit of ad hoc command-line intervention, or scripts which aren’t terribly configurable. There are GUI and proprietary commands, but they tend not to offer great support for command-line and therefore scheduled operation.

I’ve knocked together a Python application called rmrip: it’s available in a tar file from If you unzip this to a directory you’ll find a number of .py files and a config.conf configuration file. Edit config.conf to match your system requirements and stream preferences, make sure is executable, then run it. mp3s should eventually appear in a subdirectory called YYYYMMDD unless you configure the system otherwise.

The application can in principle be run from a cronjob, so it could tick over late at night when everyone’s internet is otherwise nice and quiet. In addition, conversion works via a named pipe, which is a funky way of piping the intermediary, enormous .wav audio file straight into lame, rather than saving it to disk. This does unfortunately restrict the application to non-Windows machines, but it’s a great help for audiophiles with limited disk space: .ra and .mp3 files can be in the hundreds of megabytes for many-hour programmes, but the associated .wav would take up gigabytes.

Current requirements include (please give any feedback on this!):

  • mplayer and lame: their locations are configurable
  • The subprocess module in Python

Current file types supported:

  • Direct rtsp://….ra Real Audio stream links
  • http://….ram references to Real Audio streams
  • http://….rpm Real Audio playlists (BBC so far only format tested)

To get you started, has provided information on how to get stream information using a standalone Python program, and also has potentially out-of-date static pages detailing the current BBC streams.


Very cool, I've been getting into Python a bit recently - I'll check this out.

This is lovely. Is it possible to pass the configuration file as an argument? I'd really like to cron this every few days with a different list of jobs.

Python isn't my bag so if I start to hack it then either,

i) It'll get badly munged
ii) It'll get re-written in PHP

Maybe I'll try i) and find out if it already does this already..



thanks very much for the feedback. I think I was holding off putting any command-line arguments in place as once you do that it's hard to change your mind at a later date if anyone's actually using it by then.

That does seem a reasonable addition to the functionality, though, so I'll look into it when I have my old, cranky development machine up and running.

In the mean time, if you edit and change:

# Get config and parse into config and meta config
conf = config.load_config()


# Get config and parse into config and meta config
conf = config.load_config("my_file/location.whatever")

then that should override the default value.

What I actually did was in the crontab CD into a directory with that particular day's config.conf and then run rmrip from the directory that was put in. e.g.

0 2 * * 2 cd $HOME/rmrip/tuesday; $HOME/rmrip/
0 2 * * 3 cd $HOME/rmrip/wednesday; $HOME/rmrip/

Though I think

0 2 * * 2 $HOME/rmrip/ tuesday.conf
0 2 * * 3 $HOME/rmrip/wednesday wednesday.conf

would be neater. So I'll have to read a python manual and work out how to get argv[1] and pass that into config.load_config

[...] Seb James dropped me an email to say that’s he’d enhanced my BBC Radio recording script and added Ogg Vorbis encoding as well as cleverer file handling. He’s named it ‘listenagain’, and I’ve included the full script below. This follows JP Stacey’s Python wrapper, using rmrip, which skips the intermediate wav file and allows the use of a configuration file. [...]