37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 |
# streams and gui
class internet_radio (ChannelPlugin):
# control data
listformat = "pls"
categories = []
base_url = "http://www.internet-radio.com/"
# load genres
def update_categories(self):
html = http.get(self.base_url)
rx = re.compile("""="/stations/[-+&.\w\s%]+/">([^<]+)<""") |
|
| 37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 |
# streams and gui
class internet_radio (ChannelPlugin):
# control data
listformat = "pls"
categories = []
base_url = "https://www.internet-radio.com/"
# load genres
def update_categories(self):
html = http.get(self.base_url)
rx = re.compile("""="/stations/[-+&.\w\s%]+/">([^<]+)<""") |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 | "/" + ("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
#log.HTTP(html)
for use_rx in [not conf.pyquery, conf.pyquery]:
try:
entries = (self.with_regex(html) if use_rx else self.with_dom(html))
if len(entries):
break
except Exception as e:
log.ERR(e)
continue
# fin
return entries
# Regex extraction
def with_regex(self, html):
log.PROC("internet-radio, regex")
r = [] |
|
>
| 77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 | "/" + ("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
#log.HTTP(html)
for use_rx in [not conf.pyquery, conf.pyquery]:
try:
entries = (self.with_regex(html) if use_rx else self.with_dom(html))
if len(entries):
break
except Exception as e:
log.ERR(e)
continue
# fin
log.FINISHED("internet_radio.update_streams")
return entries
# Regex extraction
def with_regex(self, html):
log.PROC("internet-radio, regex")
r = [] |