1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#
# api: streamtuner2
# title: Internet-Radio.com
# description: Broad list of webradios from all genres.
# type: channel
# category: radio
# version: 1.1
# priority: standard
#
# Internet-Radio.co.uk/.com is one of the largest directories of streams.
# Available music genre classifications are mirrored verbatim and flatly.
#
# The new version of this plugin alternates between PyQuery and Regex
# station extraction. Both overlook some paid or incomplete entries.
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#
# api: streamtuner2
# title: Internet-Radio.com
# description: Broad list of webradios from all genres.
# type: channel
# category: radio
# version: 1.2
# priority: standard
#
# Internet-Radio.co.uk/.com is one of the largest directories of streams.
# Available music genre classifications are mirrored verbatim and flatly.
#
# The new version of this plugin alternates between PyQuery and Regex
# station extraction. Both overlook some paid or incomplete entries.
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
except Exception as e:
__print__(dbg.ERR, e)
continue
# fin
return entries
# Normal
"""
"""
# Variation
"""
<tr><td width="74"> <div id="jquery_jplayer_19" class="jp-jplayer"></div>
<div id="jp_container_19" class="jp-audio-stream" role="application" aria-label="media player">
<div class="jp-type-single">
<div class="jp-gui jp-interface">
<div class="jp-controls">
<i onClick="ga('send', 'event', 'tunein', 'playjp', 'http://softrockradio.purestream.net:8032/listen.pls');" style="font-size: 60px;" class="jp-play text-danger mdi-av-play-circle-outline"></i>
<i style="font-size: 60px;" class="jp-pause text-danger mdi-av-pause-circle-outline"></i>
</div> </div>
<div class="jp-no-solution text-center">
<small><a href="http://get.adobe.com/flashplayer/" target="_blank">Flash Required</a></small>
</div></div>
<div id="volume19" class="text-center" style="visibility: hidden;">
<span class="jp-current-time"></span>
<div class="jp-volume-bar progress" style="margin:0;">
<div class="jp-volume-bar-value progress-bar active progress-bar-striped progress-bar-danger"></div>
</div> </div>
</div> </td> <td>
<h4 class="text-danger" style="display: inline;">SoftRockRadio.net - Classic Soft Rock (Soft Rock Radio)</h4>
<br>
<b>Kenny Loggins - Heart To Heart</b><br>
<a onClick="ga('send', 'event', 'externallink', 'listing', 'http://www.softrockradio.net');" class="small text-success" href="http://www.softrockradio.net" target="_blank">http://www.softrockradio.net</a>
<br>Genres: <a onClick="ga('send', 'event', 'genreclick', 'stationlisting', '70s');" href="/stations/70s/">70s</a> 80s <a onClick="ga('send', 'event', 'genreclick', 'stationlisting', 'classic rock');" href="/stations/classic rock/">classic rock</a><!--
<br><samp>19 http://softrockradio.purestream.net:8032/listen.pls shoutcast1 audio/mpeg</samp>
<div id="jplayer_inspector_19"></div>-->
</td>
<td width="120" class="text-right hidden-xs">
<p>
139 Listeners<br>
128 Kbps<br>
</p>
<a style="margin:1px" class="btn btn-default btn-xs" onClick="ga('send', 'event', 'tunein', 'playpls', 'http://softrockradio.purestream.net:8032/listen.pls');" href="/servers/tools/playlistgenerator/?u=http://softrockradio.purestream.net:8032/listen.pls&t=.pls">PLS</a>
<a style="margin:1px" class="btn btn-default btn-xs" onClick="ga('send', 'event', 'tunein', 'playm3u', 'http://softrockradio.purestream.net:8032/listen.pls');" href="/servers/tools/playlistgenerator/?u=http://softrockradio.purestream.net:8032/listen.pls&t=.m3u">M3U</a>
<a style="margin:1px" class="btn btn-default btn-xs" onClick="ga('send', 'event', 'tunein', 'playram', 'http://softrockradio.purestream.net:8032/listen.pls');" href="/servers/tools/playlistgenerator/?u=http://softrockradio.purestream.net:8032/listen.pls&t=.ram">RAM</a>
<a style="margin:1px" class="btn btn-default btn-xs" onClick="window.open('/player/?mount=http://softrockradio.purestream.net:8032/listen.pls&title=SoftRockRadio.net - Classic Soft Rock (Soft Rock Radio)&website=http://www.softrockradio.net','_blank','width=360,height=470'); ga('send', 'event', 'tunein', 'playpopup', 'http://softrockradio.purestream.net:8032/listen.pls');" href="#">FLA</a>
</td></tr>
"""
# Regex extraction
def with_regex(self, html):
__print__(dbg.PROC, "internet-radio, regex")
r = []
html = "\n".join(html)
# Break up into <tr> blocks before extracting bits
rx_tr = re.compile("""<tr[^>]*>(.+?)</tr>""", re.S)
rx_data = re.compile(r"""
playjp',\s*'(https?://[^'">]+)
.*? <h4.*?>([^<>]+)</
.*? <b>([^<>]+)</b>
(?: .*? href="(.*?)" )?
(?: .*? Genres:((?:</?a[^>]+>|\w+|\s+)+) )?
.*? (\d+)\s*Listeners
.*? (\d+)\s*Kbps
""", re.S|re.X)
for div in rx_tr.findall(html):
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
except Exception as e:
__print__(dbg.ERR, e)
continue
# fin
return entries
# Regex extraction
def with_regex(self, html):
__print__(dbg.PROC, "internet-radio, regex")
r = []
html = "\n".join(html)
# Break up into <tr> blocks before extracting bits
rx_tr = re.compile("""<tr[^>]*>(.+?)</tr>""", re.S)
rx_data = re.compile(r"""
playjp',\s*'(https?://[^'">]+)
.*? <h4.*?>([^<>]+)</
.*? <b>([^<>]*)</b>
(?: .*? href="(.*?)" )?
(?: .*? Genres:((?:</?a[^>]+>|\w+|\s+)+) )?
.*? (\d+)\s*Listeners
.*? (\d+)\s*Kbps
""", re.S|re.X)
for div in rx_tr.findall(html):
|
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
def with_dom(self, html_list):
__print__(dbg.PROC, "internet-radio, dom")
rx_numbers = re.compile("(\d+)")
r = []
for html in html_list:
# the streams are arranged in table rows
doc = pq(html)
for dir in (pq(e) for e in doc("tr.stream")):
bl = dir.find("td[align=right]").text()
bl = rx_numbers.findall(str(bl) + " 0 0")
r.append({
"title": dir.find("b").text(),
"homepage": http.fix_url(dir.find("a.url").attr("href")),
"url": dir.find("a").eq(2).attr("href"),
"genre": dir.find("td").eq(0).text(),
"bitrate": int(bl[0]),
"listeners": int(bl[1]),
"format": "audio/mpeg",
"playing": dir.find("td").eq(1).children().remove().end().text()[13:].strip(),
})
return r
|
|
>
|
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
156
157
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
184
185
186
187
188
189
190
191
192
193
|
def with_dom(self, html_list):
__print__(dbg.PROC, "internet-radio, dom")
rx_numbers = re.compile("(\d+)")
r = []
for html in html_list:
# the streams are arranged in table rows
doc = pq(html)
for dir in (pq(e) for e in doc("tr")):
# bitrate/listeners
bl = dir.find("p").text()
bl = rx_numbers.findall(str(bl) + " 0 0")
# stream url
url = dir.find("i").eq(0).attr("onclick")
if url:
url = re.search("(http://[^\'\"\>]+)", url)
if url:
url = url.group(0)
else:
url = ""
else:
url = ""
r.append({
"title": dir.find("h4").text(),
"homepage": http.fix_url(dir.find("a.small").attr("href")),
"url": url,
"genre": dir.find("a[href^='/stations/']").text(),
"listeners": int(bl[0]),
"bitrate": int(bl[1]),
"format": "audio/mpeg",
"playing": dir.find("b").text(),
})
return r
|