September 11, 2012

ABC Radio Shows Streaming Ripper

Filed under: Technical — Tags: , , , — James Bunton @ 7:29 pm

This code is obsolete and probably doesn’t work anymore.

Most ABC radio shows are available to download as MP3s, usually with a convenient podcast feed. Unfortunately sometimes, probably due to copyright stupidity, they make a programme available only by Windows Media or RealPlayer streaming. I’ve written a simple tool to snatch this streaming audio from ABC’s servers.

Dependencies

  • python (2.6 or newer)
  • python-lxml
  • mplayer
  • lame
  • Mercurial (or download the files manually)

Download

Get the software using Mercurial with this command:
$ hg clone https://delx.au/hg/webdl

Usage

Running it will look something like this:

$ ./grab-abc-stream
Paste 'Listen Now' URLs from ABC... Press CTRL-D to finish
http://www.abc.net.au/radio/player/rnmodplayer.html?pgm=Airplay<snipped>
Downloading mms://media3.abc.net.au/rn/items/apy-2012-09-09-15-05.asf

You will end up with a file called apy-2012-09-09-15-05.mp3 with some basic ID3 metadata. The URLs here are obtained by right-clicking on “Listen Now” on the ABC website and pasting the result. You can paste several URLs, separated by newlines, and they will be grabbed in sequence. Press CTRL-D to start the download.

6 comments

Robert says:

Hi thanks for this – I’m trying this on a Windows 7 64-bit and getting this error:

ImportError: No module named common

I see in the code there is an import request as follows

“from common import exec_subprocess”

Should I have a “common” module somewhere?

I’m not at all familiar with Python (actually I really only know html and css inside out and a tiny bit of php haha).

Can you point me in the right direction? Love to get this working as the constant need to “stream” drives me nuts.

Thanks in advance!

delx says:

Hi @Robert,

Sometime after writing the post I made the dependency on common.py, but forgot to mention it! Thanks for pointing that out, I’ve fixed the text now. Hopefully it will work for you. Make sure you have all the other dependencies installed and on your PATH. I’ve only tried this on Linux, but it should work on Windows too I think.

Good luck, please let me know how you go :)

Robert says:

Thanks very much for responding so quickly – downloaded “common.py” and now I get an error:

ImportError: No module named autosocks

(Running Python 2.7 btw – I also have installed 3.3 and have it available if that helps)

Sorry to be such a pain!

delx says:

Fixed another dependency and actually tested it this time! Third time lucky? :)

Robert says:

Hi me again – OK we are getting much closer in that the script is now “working” or sorts – it gets to the part where it is asking to paste the URLs (which I do with one only at this point), then after that press “Ctrl D” to begin the download.

But Ctrl D does not start any download – it just sits there.

In the Windows Command Prompt this looks like this:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\REMOVED>C:\Python27\Lib\rip-abc-stream.py
Paste ‘Listen Now’ URLs from ABC… Press CTRL-D to finish
mms://media3.abc.net.au/classic/audio/cdn-4-2012-10-08.wma
^D

You can see the “^D” is where I have pressed Ctrl D.

It’s the same if I execute from inside python.exe using execfile()

Any clues so far? Seems like the command “Ctrl D” is not recognized?

Thanks – I’m actually starting to enjoy getting this figured out (with your help of course!).

Robert says:

OK update – in fact the command is “Ctrl Z” then “Enter” I think in Windows?

If I do that then I get this error:

C:\Users\REMOVED>C:\Python27\Lib\rip-abc-stream.py
Paste ‘Listen Now’ URLs from ABC… Press CTRL-D to finish
http://www.abc.net.au/classic/classic100/audio/cdn-5-2012-10-14.asx
^Z
Traceback (most recent call last):
File “C:\Python27\Lib\rip-abc-stream.py”, line 63, in
grab(line)
File “C:\Python27\Lib\rip-abc-stream.py”, line 45, in grab
wmfile = qs[“w”][0]
KeyError: ‘w’

Does that help?!!!!

Comments are closed.