Created
June 28, 2012 08:39
-
-
Save Elwell/3009947 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# script to parse out the metadata from soma fm and send to mqtt | |
xmlurl = 'http://api.somafm.com/channels.xml' | |
from lxml import etree | |
tree = etree.parse(xmlurl) | |
interesting = ('title','description','image','twitter','listeners','dj') | |
for chan in tree.getiterator('channel'): | |
for thing in interesting: | |
for key in chan.iterchildren(tag=thing): | |
print "somafm/%s/%s %s" % (chan.attrib['id'], key.tag, key.text) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/usr/bin/env python
script to parse out the metadata from soma fm and send to mqtt
xmlurl = 'http://api.somafm.com/channels.xml'
from pyquery import PyQuery
query = PyQuery(url=xmlurl, parser='xml')
for channel in query('channel'):
channel = PyQuery(channel)
print channel.find('title').text()
print channel.find('description').text()
print channel.find('image').text()
print channel.find('twitter').text()
print channel.find('listeners').text()
print channel.find('dj').text()