59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 | default = ""
# load genres
def update_categories(self):
html = http.get(self.homepage)
rx = re.compile("""<option[^>]+value="/stations/[-+&.\w\s%]+/">([^<]+)</option>""")
self.categories = rx.findall(html)
# fetch station lists
def update_streams(self, cat):
entries = []
if cat not in self.categories: |
|
|
>
>
|
| 59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 | default = ""
# load genres
def update_categories(self):
html = http.get(self.homepage)
rx = re.compile("""="/stations/[-+&.\w\s%]+/">([^<]+)<""")
cats = rx.findall(html)
cats = list(set(cats))
cats = [s.capitalize() for s in cats]
self.categories = sorted(cats)
# fetch station lists
def update_streams(self, cat):
entries = []
if cat not in self.categories: |
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 | html.append(
http.get(
self.homepage + "stations/" +
cat.lower().replace(" ", "%20") +
"/" + ("page"+str(page) if page>1 else "")
)
)
# Is there a next page?
if str(page+1) not in rx_pages.findall(html[-1]):
break
self.parent.status(float(page)/float(max_pages+1))
# Alternatively try regex or pyquery parsing
#__print__(dbg.HTTP, html) |
|
| 88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 | html.append(
http.get(
self.homepage + "stations/" +
cat.lower().replace(" ", "%20") +
"/" + ("page"+str(page) if page>1 else "")
)
)
# Is there a next page?
if str(page+1) not in rx_pages.findall(html[-1]):
break
self.parent.status(float(page)/float(max_pages+1))
# Alternatively try regex or pyquery parsing
#__print__(dbg.HTTP, html) |