Index: contrib/radiolist.py ================================================================== --- contrib/radiolist.py +++ contrib/radiolist.py @@ -1,11 +1,11 @@ # encoding: UTF-8 # api: streamtuner2 # title: radiolist.net # description: Station list by continent+country # url: http://radiolist.net/ -# version: 0.3 +# version: 0.4 # type: channel # category: radio # priority: extra # png: # iVBORw0KGgoAAAANSUhEUgAAABgAAAAYBAMAAAASWSDLAAAAFVBMVEVKb61qibyDnMegs9S6yeDV4O37/vyx66abAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMB @@ -74,31 +74,34 @@ c.append(sorted(sub)) self.categories = c # extract stream urls def update_streams(self, cat): - rx_title = re.compile(']+)" target="_blank">(.+?)', re.I) - rx_urls = re.compile(']+)">(\d+)(?: Kbps)?', re.I) - rx_genre = re.compile('([^<]+)', re.I) + rx_title = re.compile(']+)"[^>]+target="_blank"[^>]*>(.+?)', re.I) + rx_urls = re.compile(']+)">(\d+)(?: Kbps)*', re.I) + rx_genre = re.compile(']+>(\w*[^<>]*)\s*]+>(\w+[^<>]+)\s*$', re.I) entries = [] - html = ahttp.get("http://www.radiolist.net/" + self.catmap[cat]) + html = ahttp.get("http://radiolist.net/" + self.catmap[cat]) + log.DATA(html) for block in re.findall("(.+?)", html, re.S): + log.BLOCK(block) ut = re.findall(rx_title, block) # homepage+title uu = re.findall(rx_urls, block) # urls+bitrates lg = re.findall(rx_genre, block) # location+genre #print ut, uu, lg if ut and uu and lg: + log.D(ut,uu,lg) url, br = self.best_url(uu) entries.append(dict( homepage = ut[0][0], title = unhtml(ut[0][1]), url = url, bitrate = br, format = self.mime_guess(url, "audio/mpeg"), listformat = self.list_guess(url), - playing = lg[0], - genre = lg[1] + playing = lg[0][0], + genre = lg[0][1] )) # done [log.DATA(e) for e in entries] return entries