1
2
3
4
5
6
7
8
9
10
11
|
# encoding: UTF-8
# api: streamtuner2
# title: Dirble
# description: New open radio station directory.
# version: 0.2
# type: channel
# category: radio
# priority: optional
# documentation: http://dirble.com/developer/api
#
# Provides a nice JSON API, so is easy to support.
|
|
|
1
2
3
4
5
6
7
8
9
10
11
|
# encoding: UTF-8
# api: streamtuner2
# title: Dirble
# description: Open radio station directory.
# version: 0.2
# type: channel
# category: radio
# priority: optional
# documentation: http://dirble.com/developer/api
#
# Provides a nice JSON API, so is easy to support.
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
))
return r
# Request homepage for stations, else try to deduce Dirble page
def get_homepage(self, id, name):
if conf.dirble_fetch_homepage:
return self.api("station", "id", id)["website"]
else:
name = re.sub("[^\w\s]+", "", name)
name = re.sub("\s", "-", name)
return "http://dirble.com/station/" + name.lower();
# Patch API url together, send request, decode JSON and whathaveyou
def api(self, *params):
method = params[0]
j = http.get((self.base % (method, self.cid)) + "/".join([str(e) for e in params[1:]]))
try:
r = json.loads(j);
except:
r = []
return r
|
>
|
|
>
|
|
|
<
>
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
))
return r
# Request homepage for stations, else try to deduce Dirble page
def get_homepage(self, id, name):
if conf.dirble_fetch_homepage:
try:
return self.api("station", "id", id)["website"]
except:
None
name = re.sub("[^\w\s]+", "", name)
name = re.sub("\s", "-", name)
return "http://dirble.com/station/" + name.lower();
# Patch API url together, send request, decode JSON and whathaveyou
def api(self, *params):
method = params[0]
try:
j = http.get((self.base % (method, self.cid)) + "/".join([str(e) for e in params[1:]]))
r = json.loads(j);
except:
r = []
return r
|