5 from pprint import pprint
6 from plugins.modules.PlaylistGenerator import PlaylistGenerator
8 tvguide_url="http://www.teleguide.info/download/new3/jtv.zip"
10 def parseXML(filename):
11 datasource = open(filename)
12 return xml.dom.minidom.parse(datasource) # parse an open file
16 nodelist = element.childNodes
18 if node.nodeType == node.TEXT_NODE:
24 sys.stderr.write("Usage: %s <xml-file>\n" % (argv[0],))
27 if not os.path.exists(argv[1]):
28 sys.stderr.write("ERROR: Channel file %r was not found!\n" % (argv[1],))
31 dom = parseXML(argv[1])
32 tracklist = dom.getElementsByTagName('playlist')[0].getElementsByTagName('trackList')[0].getElementsByTagName('track')
34 channels = PlaylistGenerator()
36 for track in tracklist:
40 channel['name'] = getText(track.getElementsByTagName('title')[0])
41 channel['url'] = getText(track.getElementsByTagName('location')[0])
43 channel['logo'] = getText(track.getElementsByTagName('image')[0])
47 channel['country'] = getText(track.getElementsByTagName('country')[0])
51 channel['group'] = getText(track.getElementsByTagName('category')[0])
55 channels.addItem(channel)
57 print channels.dumpm3u().encode('utf8')
59 if __name__ == "__main__":
60 sys.exit(main(sys.argv))