209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226 | 209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226 |
-
-
+
+
-
+
| .*? 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),
genre = unhtml(tags),
title = unhtml(title),
homepage = ahttp.fix_url(homepage),
playing = clean(playing),
playing = unhtml(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 |
515
516
517
518
519
520
521
522
523
524
525
526
527 | 515
516
517
518
519
520
521
522
|
-
-
-
-
- | return 0
# Extract mime type from text
rx_fmt = re.compile("ogg|mp3|mp4|theora|nsv|webm|opus|mpeg")
def guess_format(str):
return rx_fmt.findall(str.lower() + "mpeg")[0]
# Clean up HTML text snippets
def clean(str):
return nl(entity_decode(strip_tags(str)))
|