# api: streamtuner2 # title: surfmusik browser # # import re import http from config import conf from channels import * # Surfmusik sharing site class surfmusik (ChannelPlugin): # description title = "surfmusik" module = "surfmusik" homepage = "http://www.surfmusik.de/" version = 0.1 base = "http://www.surfmusik.de/land/" listformat = "url/http" categories = [] titles = dict( title="Artist", playing="Album/Song", bitrate=False, listeners=False ) config = [ {"name":"surf_stream_format", "value":"ogg2", "type":"text", "description":"streaming format, 'ogg2' or 'mp31'"} ] def item_exists(seq, item): """ Check, if an item is part of the list """ for i in seq: if i == item: return i return None # refresh category list def update_categories(self): self.categories = [] # "70`s 70ger+80`s 80ger", "80`s 80ger", "Campusradio", "Dance+Hip Hop", "Dance+House", "Dance+Top 40", "Doowop+Funk", "Hip Hop", "Hip Hop+Top 40", "Holiday-Hits", "House+Trance", "Jazz+Klassik", "Kinderradio", "Kirchlich", "Klassik", "Lounge", "Mix", "Mix+Dance", "News", "Oldies", "Pop+Dance+Top 40", "RnB", "RnB+Hip Hop", "Rock", "Rock+Pop", "Schlager", "Schlager+Volksmusik", "Sport", "Techno+Dance", "Techno+House", "Top 40", "Top 40+Pop", "Urban+Rock+Pop", "Volksmusik", "Volksmusik+Oldies" #] html = http.get(self.base + "deutschland.html") rx_cat = re.compile(r'.*?.*?(.*?)') for uu in rx_cat.findall(html): found = 0 for entry in self.categories: if entry == uu: found = 1 break if found == 0: self.categories.append(uu) self.categories.sort() # download links from surfmusik listing def update_streams(self, cat, force=0): entries = [] html = http.get(self.base + "deutschland.html") rx_current = re.compile(r'(.*?)(.*?)(.*?)') # top list for uu in rx_current.findall(html): (homepage, name, stadt, genre, url) = uu if cat == genre: htmlsub = http.get(url) rx_sub = re.compile(r'') streams = rx_sub.findall(htmlsub) if len(streams) == 0: streams.append("") entries.append({ "title": name, "homepage": homepage, "url": streams[0], "genre": cat, }) # done return entries