Index: channels/radionomy.py ================================================================== --- channels/radionomy.py +++ channels/radionomy.py @@ -1,11 +1,11 @@ # encoding: UTF-8 # api: streamtuner2 # title: Radionomy # description: Modern radio directory and streaming provider # url: http://radionomy.com/ -# version: 0.5 +# version: 0.6 # type: channel # category: radio # config: - # { name: radionomy_pages, type: int, value: 3, category: limit, description: Number of pages per category to scan. } # { name: radionomy_update, type: boolean, value: 1, description: Also fetch OnAir updates about currently playing songs. } @@ -43,11 +43,11 @@ listformat = "srv" audioformat = "audio/mpeg" titles = dict(listeners=False, bitrate=False) categories = [] - base = "http://www.radionomy.com" + base = "https://www.radionomy.com" playing = {} # OnAir/Update dict # categories @@ -79,15 +79,17 @@ r = [] # category or search if cat: req = self.base + self.catmap[cat] - # assemble page input - html = ahttp.get(req) + # https://www.radionomy.com/de/style/GENRE + html = ahttp.get(req, ajax=1, referer=1) + # https://www.radionomy.com/de/OnAir/Update self.onair_update(req) + # collect additional pages for i in range(0, int(conf.radionomy_pages) - 1): - add = ahttp.get(req, { "scrollOffset": i }, post=1, ajax=1) + add = ahttp.get(req, { "scrollOffset": i }, post=1, ajax=1, referer=1) if add.find("browseRadio") < 0: break html += add self.onair_update(req) @@ -106,27 +108,33 @@ uid = data["radioUID"], )) return r - # Extracts the data- attribute JSON blob + # Extracts the data-play-stream= JSON blob attributes @use_rx def data_play_stream(self, html, use_rx): if use_rx: - return [entity_decode(j) for j in re.findall('data-play-stream="({.*?})"', html)] + return [ + entity_decode(json_attr) for json_attr in + re.findall('data-play-stream="({.*?})"', html) + ] else: # fix up for PyQuery, else ignores appended content html = re.sub("|", "", html) + "" - return [div.attrib["data-play-stream"] for div in pq(html)(".browseRadioWrap .radioPlayBtn")] + return [ + div.attrib["data-play-stream"] for div in + pq(html)(".browseRadioWrap .radioPlayBtn") + ] # Retrieve en/OnAir/Update for per-UID song titles def onair_update(self, req): if conf.radionomy_update: try: d = json.loads( - ahttp.get("https://www.radionomy.com/en/OnAir/Update", post=1, referer=req) + ahttp.get("https://www.radionomy.com/en/OnAir/Update", post=1, referer=req, ajax=1) ) if not d: return print d self.playing.update(