get current 3fm song in python

>>> import pprint, datetime, json, urllib2
>>> p=lambda:json.loads(urllib2.urlopen('http://radioplayer.omroep.nl/helper/now-on-air.json?ac=%s&channel_id=3' % datetime.datetime.now().strftime('%Y%m%d%H%M')).read())
>>> pprint.pprint(p()['current_song'])

or parsing this HTML

http://radioplayer.omroep.nl/helper/playlist.html?ac=201210101540&channel_id=3

ac is the timestamp. channel_id=3 is 3FM Serious Radio.

Comments