Index: channels/ubuntuusers.py ================================================================== --- channels/ubuntuusers.py +++ channels/ubuntuusers.py @@ -23,21 +23,25 @@ import re from config import * from channels import * import ahttp +import itertools # UU Wiki radio list class ubuntuusers (ChannelPlugin): # description has_search = False listformat = "srv" titles = dict(playing=False, listeners=False, bitrate=False) - base = "http://wiki.ubuntuusers.de/Internetradio/Stationen?action=export&format=raw" - categories = ["stations"] + base = { + "stations": "http://wiki.ubuntuusers.de/Internetradio/Stationen?action=export&format=raw", + "tv": "http://wiki.ubuntuusers.de/Internet-TV/Stationen?action=export&format=raw", + } + categories = ["stations", "tv"] # Nope def update_categories(self): pass @@ -53,21 +57,33 @@ # }}} # def update_streams(self, cat, search=None): # fetch page - wiki = ahttp.get(self.base) + wiki = ahttp.get(self.base[cat]) + f = "audio/mpeg" if cat == "stations" else "video/mp4" + + # split on headlines + return itertools.chain( + self.join(src, f) for src in re.split("^==+", wiki, 0, re.M) + ) + + # Extract individual stations + def join(self, src, f): + # regexp lists out, just one srv url per entry ls = re.findall(r""" - ^==\s*([\w\s.-]+)\s*==\s+ - ^\[(http[^\s\]]+).*?\{(\w+)\}\s+ - ^\{\{\{\s+ - ^(http\S+) - """, wiki, re.X|re.S|re.M) + ^\s*([\w\s.-]+)\s*==+\s+ + (?: ^\[(http[^\s\]]+) .*? \{(\w+)\} )? + .*? + ^\{\{\{ + .*? + (\w+://[^"'\s]+) + """, src, re.X|re.S|re.M) # pack into row list return [ - dict(genre=g, title=t, url=u, homepage=h, bitrate=0, listeners=0) + dict(genre=g, title=t, url=u, homepage=h, bitrate=0, listeners=0, format=f, listformat="href") for t,h,g,u in ls ]