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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
})
# send back the list
return l
genres = [
"pop",
[
"top40",
"90s",
"80s",
"britpop",
"disco",
"urban",
"party",
"mashup",
"kpop",
"jpop",
"lounge",
"softpop",
"top",
"popular",
"schlager",
],
"rock",
[
"alternative",
"electro",
"country",
"mixed",
"metal",
"eclectic",
"folk",
"anime",
"hardcore",
"pure"
"jrock"
],
"dance",
[
"electronic",
"deephouse",
"dancefloor",
"elektro"
"eurodance"
"b",
"r",
],
"hits",
[
"russian"
"hit",
"star"
],
"radio",
[
"live",
"community",
"student",
"internet",
"webradio",
],
"classic",
[
"classical",
"ebu",
"vivaldi",
"piano",
"opera",
"classix",
"chopin",
"renaissance",
"classique",
],
"talk",
[
"news",
"politics",
"medicine",
"health"
"sport",
"education",
"entertainment",
"podcast",
],
"various",
[
"hits",
"ruhit",
"mega"
],
"house",
[
"lounge",
"trance",
"techno",
"handsup",
"gay",
"breaks",
"dj",
"electronica",
],
"trance",
[
"clubbing",
"electronical"
],
"jazz",
[
"contemporary"
],
"oldies",
[
"golden",
"decades",
"info",
"70s",
"60s"
],
"religious",
[
"spiritual",
"inspirational",
"christian",
"catholic",
"teaching",
"christmas",
"gospel",
],
"music",
"unspecified",
"misc",
"adult",
"indie",
[
"reggae",
"blues",
"college",
"soundtrack"
],
"mixed",
[
"disco",
"mainstream",
"soulfull"
],
"funk",
"hiphop",
[
"rap",
"dubstep",
"hip",
"hop"
],
"top",
[
"urban"
],
"musica",
"ambient",
[
"downtempo",
"dub"
],
"promodj",
"world", # REGIONAL
[
"france",
"greek",
"german",
"westcoast",
"bollywood",
"indian",
"nederlands",
"europa",
"italia",
"brazilian",
"tropical",
"korea",
"seychelles",
"black",
"japanese",
"ethnic",
"country",
"americana",
"western",
"cuba",
"afrique",
"paris",
"celtic",
"ambiance",
"francais",
"liberte",
"anglais",
"arabic",
"hungary",
"folklore"
"latin",
"dutch"
"italy"
],
"artist", # ARTIST NAMES
[
"mozart",
"beatles",
"michael",
"nirvana",
"elvis",
"britney",
"abba",
"madonna",
"depeche",
],
"salsa",
"love",
"la",
"soul",
"techno",
[
"club",
"progressive",
"deep"
"electro",
],
"best",
"100%",
"rnb",
"retro",
"new",
"smooth",
[
"cool"
],
"easy",
[
"lovesongs",
"relaxmusic"
],
"chillout",
"slow",
[
"soft"
],
"mix",
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<
<
|
<
<
<
<
<
<
|
<
<
<
<
|
<
<
<
<
<
|
<
<
<
<
|
<
|
<
<
<
|
<
<
<
|
<
<
<
<
<
|
<
<
<
<
<
<
<
|
|
<
|
<
<
|
<
<
<
<
<
<
|
|
<
|
<
<
<
<
|
<
<
<
|
<
<
|
<
<
<
|
<
<
|
<
<
<
|
<
|
<
<
<
<
<
|
<
<
<
<
<
|
<
<
<
<
|
<
<
<
<
<
|
<
<
<
<
|
<
<
<
<
|
<
<
<
<
<
|
<
<
<
|
<
<
|
<
|
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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
})
# send back the list
return l
# Extract complete YP.XML, but just filter for genre/cat
def from_yp_xml(self, cat, search=None, buffy=[]):
# Theoretically we could really buffer the extracted station lists.
# But it's a huge waste of memory to keep it around for unused
# categories. Extracting all streams{} at once would be worse. Yet
# enabling this buffer method prevents partial reloading..
if conf.xiph_source != "buffy":
buffy = []
# Get XML blob
yp = ahttp.get(self.xml_url, statusmsg="Brace yourselves, still downloading the yp.xml blob.")
log.DATA("returned")
self.status("Yes, XML parsing isn't much faster either.", timeout=20)
for entry in xml.dom.minidom.parseString(yp).getElementsByTagName("entry"):
bits = bitrate(x(entry, "bitrate"))
if bits and conf.xiph_min_bitrate and bits >= int(conf.xiph_min_bitrate):
buffy.append({
"title": x(entry, "server_name"),
"url": x(entry, "listen_url"),
"format": self.mime_fmt(x(entry, "server_type")[6:]),
"bitrate": bits,
"channels": x(entry, "channels"),
"samplerate": x(entry, "samplerate"),
"genre": x(entry, "genre"),
"playing": x(entry, "current_song"),
"listeners": 0,
"max": 0,
"homepage": "",
})
self.status("This. Is. Happening. Now.")
# Filter out a single subtree
l = []
if cat:
rx = re.compile(cat.lower())
l = []
for row in buffy:
if rx.search(row["genre"]):
l.append(row)
elif search:
pass
# Result category
return l
# Fetch directly from website. Which Xiph does not approve of; but
# hey, it's a fallback option here. And the only way to actually
# uncover station homepages.
#@use_rx
def from_raw_html(self, cat, search=None, use_rx=False):
# Build request URL
if search:
return []
elif cat in ("Ogg_Vorbis", "NSV", "WebM", "Opus"):
url = "http://dir.xiph.org/by_format/{}".format(cat)
elif cat:
url = "http://dir.xiph.org/by_genre/{}".format(cat.title())
# Collect all result pages
html = ahttp.get(url)
for i in range(1,4):
self.status(i/5.1)
html += ahttp.get(url, {"search": cat.title(), "page": i})
try: html = html.encode("raw_unicode_escape").decode("utf-8")
except: pass
# Find streams
r = []
#for row in re.findall("""<tr class="row[01]">(.+?)</tr>""", html, re.X|re.S):
# pass
ls = re.findall("""
<tr\s+class="row[01]">
.*? class="name">
<a\s+href="(.*?)"[^>]*>
(.*?)</a>
.*? "listeners">\[(\d+)
.*? "stream-description">(.*?)<
.*? Tags: (.*?) </div>
.*? href="(/listen/\d+/listen.xspf)"
.*? class="format"\s+title="([^"]+)"
.*? /by_format/([^"]+)
""", html, re.X|re.S)
# Assemble
for homepage, title, listeners, playing, tags, url, bits, fmt in ls:
r.append(dict(
genre = clean(tags),
title = clean(title),
homepage = ahttp.fix_url(homepage),
playing = clean(playing),
url = "http://dir.xiph.org{}".format(url),
listformat = "xspf",
listeners = int(listeners),
bitrate = bitrate(bits),
format = self.mime_fmt(guess_format(fmt)),
))
return r
# Static list of categories
genres = [
"pop",
[
"top40", "90s", "80s", "britpop", "disco", "urban", "party",
"mashup", "kpop", "jpop", "lounge", "softpop", "top", "popular",
"schlager",
],
"rock",
[
"alternative", "electro", "country", "mixed", "metal",
"eclectic", "folk", "anime", "hardcore", "pure" "jrock"
],
"dance",
[
"electronic", "deephouse", "dancefloor", "elektro" "eurodance"
"rnb",
],
"hits",
[
"russian" "hit", "star"
],
"radio",
[
"live", "community", "student", "internet", "webradio",
],
"classic",
[
"classical", "ebu", "vivaldi", "piano", "opera", "classix",
"chopin", "renaissance", "classique",
],
"talk",
[
"news", "politics", "medicine", "health" "sport", "education",
"entertainment", "podcast",
],
"various",
[
"hits", "ruhit", "mega"
],
"house",
[
"lounge", "trance", "techno", "handsup", "gay", "breaks", "dj",
"electronica",
],
"trance",
[
"clubbing", "electronical"
],
"jazz",
[
"contemporary"
],
"oldies",
[
"golden", "decades", "info", "70s", "60s"
],
"religious",
[
"spiritual", "inspirational", "christian", "catholic",
"teaching", "christmas", "gospel",
],
"music",
"unspecified",
"misc",
"adult",
"indie",
[
"reggae", "blues", "college", "soundtrack"
],
"mixed",
[
"disco", "mainstream", "soulfull"
],
"funk",
"hiphop",
[
"rap", "dubstep", "hip", "hop"
],
"top",
[
"urban"
],
"musica",
"ambient",
[
"downtempo", "dub"
],
"promodj",
"world", # REGIONAL
[
"france", "greek", "german", "westcoast", "bollywood", "indian",
"nederlands", "europa", "italia", "brazilian", "tropical",
"korea", "seychelles", "black", "japanese", "ethnic", "country",
"americana", "western", "cuba", "afrique", "paris", "celtic",
"ambiance", "francais", "liberte", "anglais", "arabic",
"hungary", "folklore" "latin", "dutch" "italy"
],
"artist", # ARTIST NAMES
[
"mozart", "beatles", "michael", "nirvana", "elvis", "britney",
"abba", "madonna", "depeche",
],
"salsa",
"love",
"la",
"soul",
"techno",
[
"club", "progressive", "deep", "electro",
],
"best",
"100%",
"rnb",
"retro",
"new",
"smooth",
[
"cool"
],
"easy",
[
"lovesongs", "relaxmusic"
],
"chillout",
"slow",
[
"soft"
],
"mix",
|