1
2
3
4
5
6
7
8
9
10
11
12
13
|
# api: streamtuner2
# title: Internet-Radio
# description: Broad list of webradios from all genres.
# type: channel
# category: radio
# version: 1.5
# url: http://www.internet-radio.com/
# config:
# { name: internetradio_max_pages, type: int, value: 5, category: limit, description: How many pages to fetch and read. }
# priority: standard
# png:
# iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAaZJREFUOI2N0j1PlEEUBeBnlsVoRJcCPwINxIJGAoWVFbVK4g8w
# oUUTFRNbG3+FhVErK36BhcYCrTR8FS4mRGUXFEKCUizRwLXgnfV1Awk3mUzmnHPvPXNnUkSE40RKFYxhHKMYxFb1GIlnMLVN/etBUjuGWDm6wEHHyQbLW/Qd
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# api: streamtuner2
# title: Internet-Radio
# description: Broad list of webradios from all genres.
# type: channel
# category: radio
# version: 1.6
# url: http://www.internet-radio.com/
# config:
# { name: internetradio_max_pages, type: int, value: 5, category: limit, description: How many pages to fetch and read. }
# priority: standard
# png:
# iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAaZJREFUOI2N0j1PlEEUBeBnlsVoRJcCPwINxIJGAoWVFbVK4g8w
# oUUTFRNbG3+FhVErK36BhcYCrTR8FS4mRGUXFEKCUizRwLXgnfV1Awk3mUzmnHPvPXNnUkSE40RKFYxhHKMYxFb1GIlnMLVN/etBUjuGWDm6wEHHyQbLW/Qd
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
log.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)
|
|
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
log.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"""
\?server=(https?://[^'">]+)
.*? <h4.*?>([^<>]+)</
.*? <b>([^<>]*)</b>
(?: .*? href="(.*?)" )?
(?: .*? Genres:((?:</?a[^>]+>|\w+|\s+)+) )?
.*? (\d+)\s*Listeners
.*? (\d+)\s*Kbps
""", re.S|re.X)
|
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
174
175
176
|
"listeners": int(listeners or 0),
"format": "audio/mpeg", # there is no stream info on that, but internet-radio.org.uk doesn't seem very ogg-friendly anyway, so we assume the default here
})
else:
log.DATA("Regex couldn't decipher entry:", div)
return r
# DOM traversing
def with_dom(self, html_list):
log.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")):
#log.HTML(dir)
# bitrate/listeners
bl = dir.find("p")
if bl:
bl = rx_numbers.findall(str(bl.text()) + " 0 0")
else:
bl = [0, 0]
# stream url
url = dir.find("i").eq(0).parent().attr("onclick")
if url:
url = re.search("(http://[^\'\"\>]+)", url)
if url:
url = url.group(0)
else:
url = ""
else:
url = ""
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
"listeners": int(listeners or 0),
"format": "audio/mpeg", # there is no stream info on that, but internet-radio.org.uk doesn't seem very ogg-friendly anyway, so we assume the default here
})
else:
log.DATA("Regex couldn't decipher entry:", div)
return r
"""
[HTML] <tr>
<td id="play_nohtml5_1" style="display: none;" width="74">
<a title="PLS Playlist File" style="margin:1px" href="/servers/tools/playlistgenerator/?u=http://95.211.206.80:8000/listen.pls?sid=1&t=.pls">
<i class="text-danger mdi-av-play-circle-outline"/> .pls
</a>
<br/>
<a title="M3U Playlist File" style="margin:1px" href="/servers/tools/playlistgenerator/?u=http://95.211.206.80:8000/listen.pls?sid=1&t=.m3u">
<i class="text-danger mdi-av-play-circle-outline"/> .m3u
</a>
<br/>
<small>
<a href="/community/threads/why-is-no-web-player-available.51536/" target="_blank">
No Web Player
<i class="text-danger mdi-action-help"/>
</a>
</small>
</td>
<td id="play_1" width="74" class="text-center">
<a title="Play in new window" style="cursor: pointer; margin:1px; text-decoration: none;" onclick="window.open('http://player.internet-radio.com/?server=http://95.211.206.80:8000','PopupPlayer','width=450,height=150');"><i style="font-size: 60px;" class="mdi-av-play-circle-outline"/></a><br/><small class="hidden-xs"><a title="PLS Playlist File" style="margin:1px" href="/servers/tools/playlistgenerator/?u=http://95.211.206.80:8000/listen.pls?sid=1&t=.pls">.pls</a> <a title="M3U Playlist File" style="margin:1px" href="/servers/tools/playlistgenerator/?u=http://95.211.206.80:8000/listen.pls?sid=1&t=.m3u">.m3u</a><br/><a style="cursor: pointer;" title="Play in new window" onclick="window.open('http://player.internet-radio.com/?server=http://95.211.206.80:8000','PopupPlayer','width=450,height=150');">popup <i style="font-size: 14px;" class="mdi-action-launch"/></a> </small></td>
<td>
<h4 class="text-danger" style="display: inline;">Radio Acacia</h4>
<br/>
<b>Nu Live Met Dj Joop En Dj Hansie veel luister plezier</b><br/>
<a class="small text-success" href="http://www.radioacacia.nl" target="_blank">http://www.radioacacia.nl</a>
<br/>Genres: various nederlands piraat hollands piraten duits engels polka <a href="/stations/folk/">folk</a>
</td>
<td width="120" class="text-right hidden-xs">
<p style="margin-bottom: 4px;">
82 Listeners<br/>
<span title="High Quality"><i class="listingicon mdi-av-high-quality"/></span> 192 Kbps<br/>
</p>
<p style="margin: 0;">
<br/><br/>
</p>
</td>
</tr>
"""
# DOM traversing
def with_dom(self, html_list):
log.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")):
#log.HTML(dir)
# bitrate/listeners
bl = dir.find("p")
if bl:
bl = rx_numbers.findall(str(bl.text()) + " 0 0")
else:
bl = [0, 0]
# stream url
url = dir.find("a[onclick]").attr("onclick")
if url:
url = re.search("(https?://[^\'\"\>]+)", url)
if url:
url = url.group(0)
else:
url = ""
else:
url = ""
|