77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# extract stream urls
def update_streams(self, cat):
rx_title = re.compile('<a\s+href="([^">]+)"[^>]+target="_blank"[^>]*>(.+?)</a>', re.I)
rx_urls = re.compile('<a href="([^">]+)">(\d+)(?: Kbps)*</a>', re.I)
rx_genre = re.compile('<td[^>]+>(\w*[^<>]*)</td>\s*<td[^>]+>(\w+[^<>]+)</td>\s*$', re.I)
entries = []
html = ahttp.get("http://radiolist.net/" + self.catmap[cat])
log.DATA(html)
for block in re.findall("<tr>(.+?)</tr>", html, re.S):
log.BLOCK(block)
ut = re.findall(rx_title, block) # homepage+title
uu = re.findall(rx_urls, block) # urls+bitrates
lg = re.findall(rx_genre, block) # location+genre
#print ut, uu, lg
if ut and uu and lg:
log.D(ut,uu,lg)
url, br = self.best_url(uu)
entries.append(dict(
homepage = ut[0][0],
title = unhtml(ut[0][1]),
url = url,
bitrate = br,
format = self.mime_guess(url, "audio/mpeg"),
|
<
<
<
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# extract stream urls
def update_streams(self, cat):
rx_title = re.compile('<a\s+href="([^">]+)"[^>]+target="_blank"[^>]*>(.+?)</a>', re.I)
rx_urls = re.compile('<a href="([^">]+)">(\d+)(?: Kbps)*</a>', re.I)
rx_genre = re.compile('<td[^>]+>(\w*[^<>]*)</td>\s*<td[^>]+>(\w+[^<>]+)</td>\s*$', re.I)
entries = []
html = ahttp.get("http://radiolist.net/" + self.catmap[cat])
for block in re.findall("<tr>(.+?)</tr>", html, re.S):
ut = re.findall(rx_title, block) # homepage+title
uu = re.findall(rx_urls, block) # urls+bitrates
lg = re.findall(rx_genre, block) # location+genre
#print ut, uu, lg
if ut and uu and lg:
url, br = self.best_url(uu)
entries.append(dict(
homepage = ut[0][0],
title = unhtml(ut[0][1]),
url = url,
bitrate = br,
format = self.mime_guess(url, "audio/mpeg"),
|