Index: contrib/delicast.py ================================================================== --- contrib/delicast.py +++ contrib/delicast.py @@ -1,11 +1,11 @@ # encoding: UTF-8 # api: streamtuner2 # title: Delicast # description: directory of streaming media # url: http://delicast.com/ -# version: 0.3 +# version: 0.4 # type: channel # category: radio # config: - # png: # iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA @@ -26,10 +26,11 @@ import re from config import * from channels import * import ahttp +import action # Delayed streaming URL discovery class delicast (ChannelPlugin): @@ -44,11 +45,11 @@ "Dance", "Disco", "Easy listening", "Electronic", "Folk", "Funk", "Gospel", "Hiphop", "House Indie", "Information", "Jazz", "Latin", "Lounge", "Love", "Metal", "Oldies", "Pop", "R n b", "Reggae", "Rock", "Romantic", "Soul", "Sports", "Student", "Talk", "Techno", "Trance", "Urban", "World music"] - + # static def update_categories(self): pass @@ -80,13 +81,12 @@ )) return r # Update `url` on station data access (incurs a delay for playing or recording) - def row(self): - r = ChannelPlugin.row(self) - if r.get("url") == "urn:delicast": + def resolve_urn(self, row): + if row.get("url").startswith("urn:delicast"): html = ahttp.get(r["homepage"]) ls = re.findall("^var url = \"(.+)\";", html, re.M) - r["url"] = ls[0] - return r + row["url"] = ls[0] + return row Index: contrib/reciva.py ================================================================== --- contrib/reciva.py +++ contrib/reciva.py @@ -1,9 +1,9 @@ # encoding: UTF-8 # api: streamtuner2 # title: Reciva -# url: https://radios.reciva.com/stations/genre/34?&start=100&count=50 +# url: https://radios.reciva.com/ # description: Home internet radio app and diverse station database. # version: 0.4 # type: channel # category: radio # config: - @@ -27,10 +27,11 @@ import re from pq import pq import ahttp +import action from config import * from channels import * # Reciva directory @@ -44,16 +45,10 @@ catmap = { 'classical': '14', 'dance': '18', 'bluegrass': '52', 'contemporary': '16', 'pop': '34', 'spanish': '66', 'college': '15', 'rap': '38', 'ambient': '69', 'talk': '43', 'alternative': '9', 'religious': '39', 'blues': '10', 'folk': '23', 'classic rock': '13', '90s': '7', 'adult contemporary': '8', 'oldies': '33', 'indie rock': '54', 'electronica': '21', 'unknown': '45', 'discussion': '19', 'news talk': '31', 'world mediterranean': '55', 'sports': '42', 'new age': '51', 'indie': '27', 'indian': '65', 'easy': '20', '80s': '6', 'world africa': '67', 'comedy': '62', 'public': '35', 'jungle': '72', 'reggae': '48', 'world middle east': '50', 'christian': '11', 'world caribbean': '68', '60s': '58', 'world europe': '56', 'jazz': '28', '70s': '5', 'soft rock': '41', 'top 40': '44', 'adult': '57', 'news': '30', 'bollywood': '60', 'world tropical': '53', 'latin hits': '29', 'varied': '46', 'christian contemporary': '12', 'kids': '59', 'short wave radio': '73', 'world': '49', 'world asia': '47', 'country': '17', 'news updates': '32', 'punk': '36', 'greek': '25', 'hip hop': '26', 'rock': '40', 'gospel': '24', 'experimental': '22' } titles = dict( genre="Genre", title="Station", playing="Location", bitrate="Bitrate", listeners=False ) base_url = "https://radios.reciva.com/stations/genre/%s?&start=0&count=%s" - # init - def __init__(self, parent): - ChannelPlugin.__init__(self, parent) - self.login() - - # update list def update_categories(self): self.categories = [] html = ahttp.get(self.base_url % (1, 1)) for c in re.findall('id="cg-(\d+)">([\w\d\s]+)', html): @@ -91,24 +86,24 @@ # done return entries # Fetch real `url` on stream access/playback (delay) - def row(self): - r = ChannelPlugin.row(self) - if not r["url"].startswith("http"): - html = ahttp.get("https://radios.reciva.com/streamer?stationid=%s&streamnumber=0" % r["id"]) + def resolve_urn(self, r): + if r["url"].startswith("urn:"): + id = r["url"].split(":")[2] + html = ahttp.get("https://radios.reciva.com/streamer?stationid=%s&streamnumber=0" % id) ls = re.findall("""(?: