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 | 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"]
else:
name = re.sub("[^\w\s]+", "", name)
name = re.sub("\s", "-", name)
return "http://dirble.com/station/" + name.lower();
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]
j = http.get((self.base % (method, self.cid)) + "/".join([str(e) for e in params[1:]]))
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
|