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
|
"url": url,
"genre": self.strip_tags(genre),
"homepage": http.fix_url(homepage),
"title": title,
"playing": playing,
"bitrate": int(bitrate),
"listeners": int(listeners if listeners else 0),
"format": "audio/mp3", # 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
})
# DOM parsing
else:
# 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")
entries.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/mp3",
"playing": dir.find("td").eq(1).children().remove().end().text()[13:].strip(),
})
# next page?
if str(page+1) not in rx_pages.findall(html):
max = 0
else:
|
|
|
|
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
|
"url": url,
"genre": self.strip_tags(genre),
"homepage": http.fix_url(homepage),
"title": title,
"playing": playing,
"bitrate": int(bitrate),
"listeners": int(listeners if listeners else 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
})
# DOM parsing
else:
# 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")
entries.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(),
})
# next page?
if str(page+1) not in rx_pages.findall(html):
max = 0
else:
|