119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 | return r
# api search is gone, now requires to fetch streamUrl from per-radio homepage
def resolve_urn(self, row):
if row.get("url", "-").find("urn:radionet:") != 0:
return
html = ahttp.get(row["homepage"])
stream = re.findall('"streamUrl":\s*"([^"]+)"', html, re.S)
if stream:
row["url"] = stream[0]
return row
# extract JavaScript key from any HTML blob (needed for station query)
def set_key(self, html):
ls = re.findall("""apiKey: '(\w+)'""", html)
if ls:
self.apiKey = ls[0]
|
|
| 119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 | return r
# api search is gone, now requires to fetch streamUrl from per-radio homepage
def resolve_urn(self, row):
if row.get("url", "-").find("urn:radionet:") != 0:
return
html = ahttp.get(row["homepage"])
stream = re.findall('"stream[s:[{"\s]+url"[\s:]+"([^"]+)"', html, re.S|re.I)
if stream:
row["url"] = stream[0]
return row
# extract JavaScript key from any HTML blob (needed for station query)
def set_key(self, html):
ls = re.findall("""apiKey: '(\w+)'""", html)
if ls:
self.apiKey = ls[0]
|