ADDED contrib/radionet.py Index: contrib/radionet.py ================================================================== --- contrib/radionet.py +++ contrib/radionet.py @@ -0,0 +1,123 @@ +# encoding: UTF-8 +# api: streamtuner2 +# title: radio.net +# description: Europe's biggest radio platform +# url: http://radio.net/ +# version: 0.3 +# type: channel +# category: radio +# png: +# iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAt0lEQVR42mNgYGD4r+Ar/F/BDwkD+SBxojBMs1mLPBArgGlFqEEENYMNQNLsukIDYkirAvGu +# ABsA1OC6XOP/5f8nwIaYAg0k2gBFsAsgTgcZkvnfDugFEeK9AFKsCPMG0CU6eZJgQ4R1eP8H7LLEivWyFJANQcQCLPBAmkGG4MJohmA6C6QA5gI5OxEUDNII +# MwSvASBFIA3ociCxkWQAKMDICkSQIpgh2LDnSmP80YhsCFEJiRIMADpmeUOpqgjRAAAAAElFTkSuQmCC +# priority: optional +# +# Radio.net lists around 20.000 worldwide radio stations. +# A maximum of three pages from each genre are fetched here, +# some of the empty categories already omitted. +# +# The website heavily depends on JavaScript, a Flash player, +# some social tracking cookies. But still feasible to access +# per custom JSON extractor. +# +# May require refreshing the station lists once in a while, +# because there's an API key in each JSON station info URL. + + +import time +import json +import re +from config import * +from channels import * +import ahttp +import action + + +# hook special JSON format in to avoid grepping images by generic handler +action.playlist_fmt_prio.insert(5, "rnjs") +action.playlist_content_map.insert(7, ("rnjs", r'"logo175x175rounded"')) +action.extract_playlist.extr_urls["rnjs"] = dict( + url = r" (?x) \"streamUrl\" \s*:\s* \"(\w+:\\?/\\?/[^\"]+)\" ", + title = r" (?x) \"(?:description|seoTitle)\" \s*:\s* \"([^\"]+)\" ", + unesc = "json", +) + + +# Radio.net extraction relies on HTML grepping, finding an api key required for station details, +# and letting the action module extract the station/stream URL from that JSON format. +# +class radionet (ChannelPlugin): + + # control flags + has_search = False + audioformat = "audio/mpeg" + listformat = "rnjs" + titles = dict(listeners=False, playing="Description") + + # sources + apiPrefix = "https://api.radio.net/info/v2" + genre_url = "http://www.radio.net/genre/{}/" + apiKey = None + + + # Retrieve cat list and map + def update_categories(self): + html = ahttp.get("http://www.radio.net/") + self.set_key(html) + ls = re.findall("""