Index: channels/liveradio.py
==================================================================
--- channels/liveradio.py
+++ channels/liveradio.py
@@ -1,21 +1,22 @@
# encoding: UTF-8
# api: streamtuner2
-# title: Liveradio.ie
+# title: LiveRadio
# description: Irish/worldwide radio station directory
# url: http://liveradio.ie/
# version: 0.4
# type: channel
# category: radio
# config: -
+# { name: liveradio_tld, value: ie, type: select, select: ie=LiveRadio.ie|uk=LiveRadio.uk, description: Website to fetch from. }
# png:
# iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABB0lEQVR4nLWTQUpDMRCGv0lregDBI3gAfW/hRrp8ZOMh5PUMXkFcu7EbTxHd
# CC4EhfQkQg/QR5txYQqvMdVHwdnMZJj555uQwH+YurpaNZUOqTWl5i5qGIusDxIAZgBGuBhCsiOgrq7WUa+tkReAjepHystQgmn8zt0As40y
# skYa4HwfSS5w2otd8svtWurqHyvnCZcXAHRRW7v8nANnq6bSPk0ucFQS+M3G2fkduMqLrJF5d3zSTnyYATsXmhO89WLfix8A1NWjvwhek5+m
# praLGibPC8knFwnEh4U1ct9FvUvoLk0uPbjiCgCPyd+KD0/WyKX4EPcJFLG2/8EaMeLDoE91sH0B3ERWq2CKMoYAAAAASUVORK5CYII=
# priority: standard
-# extraction-method: regex, action-handler
+# extraction-method: regex, dom, action-handler
#
# LiveRadio.ie, based in Ireland, is a radio station directory. It provides
# genre or country browsing (not in this plugin). Already lists over 5550
# stations (more unique selections). Also accepts user submissions.
#
@@ -49,14 +50,23 @@
# data store
categories = ["Top 20"]
catmap = {"Top 20":"top-20"}
base = "http://www.liveradio.ie/"
+
+ # override meta based on TLD setting (.ie / .uk)
+ def init2(self, parent):
+ if not "liveradio_tld" in conf:
+ conf.liveradio_tld = "ie"
+ self.base = "http://www.liveradio.{}/".format(conf.liveradio_tld)
+ self.meta["url"] = self.base
+ #self.meta["title"] = "LiveRadio.{}".format(conf.liveradio_tld)
+
# Extract genre links and URL aliases (e.g. "Top 20" maps to "/top-20")
def update_categories(self):
- html = ahttp.get("http://www.liveradio.ie/genres")
+ html = ahttp.get(self.base + "genres")
self.categories = ["Top 20"]
for row in re.findall(r"""([^<]+)""", html):
self.categories.append(unhtml(row[1]))
self.catmap[unhtml(row[1])] = unhtml(row[0])
@@ -97,11 +107,11 @@
#
def rx_extract(self, html):
r = []
ls = re.findall("""
itemtype="http://schema.org/RadioStation"> .*?
- href="(?:https?://www.liveradio.ie)?/stations/([\w-]+) .*?
+ href="(?:https?://www.liveradio.\w+)?/stations/([\w-]+) .*?
([^<]+)< .*?
itemprop="name">]+>([^<]+) .*?
class="genre">([^<]+)<
""", html, re.X|re.S)