Index: channels/internet_radio.py ================================================================== --- channels/internet_radio.py +++ channels/internet_radio.py @@ -2,11 +2,11 @@ # api: streamtuner2 # title: Internet-Radio.com # description: Broad list of webradios from all genres. # type: channel # category: radio -# version: 1.1 +# version: 1.2 # priority: standard # # Internet-Radio.co.uk/.com is one of the largest directories of streams. # Available music genre classifications are mirrored verbatim and flatly. # @@ -108,51 +108,10 @@ continue # fin return entries - # Normal - """ - """ - # Variation - """ -
-
-
- -
- -
-

SoftRockRadio.net - Classic Soft Rock (Soft Rock Radio)

-
- Kenny Loggins - Heart To Heart
- http://www.softrockradio.net -
Genres: 70s 80s classic rock - - -

- 139 Listeners
- 128 Kbps
-

- PLS - M3U - RAM - FLA - - """ # Regex extraction def with_regex(self, html): __print__(dbg.PROC, "internet-radio, regex") r = [] @@ -161,11 +120,11 @@ # Break up into blocks before extracting bits rx_tr = re.compile("""]*>(.+?)""", re.S) rx_data = re.compile(r""" playjp',\s*'(https?://[^'">]+) .*? ([^<>]+)([^<>]+) + .*? ([^<>]*) (?: .*? href="(.*?)" )? (?: .*? Genres:((?:]+>|\w+|\s+)+) )? .*? (\d+)\s*Listeners .*? (\d+)\s*Kbps """, re.S|re.X) @@ -199,24 +158,36 @@ rx_numbers = re.compile("(\d+)") r = [] for html in html_list: # the streams are arranged in table rows doc = pq(html) - for dir in (pq(e) for e in doc("tr.stream")): + for dir in (pq(e) for e in doc("tr")): - bl = dir.find("td[align=right]").text() + # bitrate/listeners + bl = dir.find("p").text() bl = rx_numbers.findall(str(bl) + " 0 0") + # stream url + url = dir.find("i").eq(0).attr("onclick") + if url: + url = re.search("(http://[^\'\"\>]+)", url) + if url: + url = url.group(0) + else: + url = "" + else: + url = "" + r.append({ - "title": dir.find("b").text(), - "homepage": http.fix_url(dir.find("a.url").attr("href")), - "url": dir.find("a").eq(2).attr("href"), - "genre": dir.find("td").eq(0).text(), - "bitrate": int(bl[0]), - "listeners": int(bl[1]), + "title": dir.find("h4").text(), + "homepage": http.fix_url(dir.find("a.small").attr("href")), + "url": url, + "genre": dir.find("a[href^='/stations/']").text(), + "listeners": int(bl[0]), + "bitrate": int(bl[1]), "format": "audio/mpeg", - "playing": dir.find("td").eq(1).children().remove().end().text()[13:].strip(), + "playing": dir.find("b").text(), }) return r