1
2
3
4
5
6
7
8
9
10
11
12 | # encoding: UTF-8
# api: streamtuner2
# title: RadioBrowser
# description: Community collection of stations; votes, clicks, homepage links.
# version: 0.4
# type: channel
# url: http://www.radio-browser.info/
# category: radio
# priority: optional
# config:
# { name: radiobrowser_cat, type: select, value: tags, select="tags|countries|languages", description: Which category types to list. }
# { name: radiobrowser_srv, type: select, value: all, select:"all|de1|fr1|nl1|old", description: API server to utilize. } |
|
| 1
2
3
4
5
6
7
8
9
10
11
12 | # encoding: UTF-8
# api: streamtuner2
# title: RadioBrowser
# description: Community collection of stations; votes, clicks, homepage links.
# version: 0.5
# type: channel
# url: http://www.radio-browser.info/
# category: radio
# priority: optional
# config:
# { name: radiobrowser_cat, type: select, value: tags, select="tags|countries|languages", description: Which category types to list. }
# { name: radiobrowser_srv, type: select, value: all, select:"all|de1|fr1|nl1|old", description: API server to utilize. } |
79
80
81
82
83
84
85
86
87
88
89
90
91
92 | catmap = { "tags": "bytag", "countries": "bycountry", "languages": "bylanguage" }
tagmap = { "tags": "tag", "countries": "country", "languages": "language" }
# hook menu
def init2(self, parent):
if parent:
uikit.add_menu([parent.streammenu, parent.streamactions], "Share in Radio-Browser", self.submit, insert=5)
# votes, and tags, no countries or languages
def update_categories(self):
params = {"order":"name", "reverse":"false", "hidebroken":"true"}
self.categories = list(self.pricat) + [grp["name"] for grp in filter(
lambda grp: grp["stationcount"] >= conf.radiobrowser_min,
self.api(conf.radiobrowser_cat, params) |
>
| 79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 | catmap = { "tags": "bytag", "countries": "bycountry", "languages": "bylanguage" }
tagmap = { "tags": "tag", "countries": "country", "languages": "language" }
# hook menu
def init2(self, parent):
if parent:
uikit.add_menu([parent.streammenu, parent.streamactions], "Share in Radio-Browser", self.submit, insert=5)
parent.hooks["play"].append(self.click)
# votes, and tags, no countries or languages
def update_categories(self):
params = {"order":"name", "reverse":"false", "hidebroken":"true"}
self.categories = list(self.pricat) + [grp["name"] for grp in filter(
lambda grp: grp["stationcount"] >= conf.radiobrowser_min,
self.api(conf.radiobrowser_cat, params) |
157
158
159
160
161
162
163
164
165
166
167
168
169
170 | # request + json decode
j = ahttp.get(srv + method, params, post=post, **kwargs)
try:
return json.loads(j, strict=False) # some entries contain invalid character encodings
except:
return []
# Add radio station to RBI
def submit(self, *w):
cn = self.parent.channel()
row = cn.row()
# convert row from channel
data = dict( |
>
>
>
>
>
>
>
>
>
>
>
>
| 158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183 | # request + json decode
j = ahttp.get(srv + method, params, post=post, **kwargs)
try:
return json.loads(j, strict=False) # some entries contain invalid character encodings
except:
return []
# callback for general stream play event
def click(self, row, channel):
if not channel == self:
return
# fetch uuid, then register click
uuid = self.api("stations/byurl", {"url": row.get("url")})
if uuid:
if isinstance(uuid, list): # just vote on the first entry
uuid = uuid[0]
log.PROC_CLICK_COUNT(self.api("url/{}".format(uuid["stationuuid"])))
# Add radio station to RBI
def submit(self, *w):
cn = self.parent.channel()
row = cn.row()
# convert row from channel
data = dict( |