14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# there's not a lot of information to fetch left. And this plugin is now back
# to defaulting to regex extraction instead of HTML parsing & DOM extraction.
#
#
#
import http
import urllib
import re
from config import conf, __print__, dbg
from pq import pq
#from channels import * # works everywhere but in this plugin(???!)
import channels
# SHOUTcast data module ----------------------------------------
class shoutcast(channels.ChannelPlugin):
# desc
|
|
<
>
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# there's not a lot of information to fetch left. And this plugin is now back
# to defaulting to regex extraction instead of HTML parsing & DOM extraction.
#
#
#
import ahttp as http
import re
from config import conf, __print__, dbg
from pq import pq
#from channels import * # works everywhere but in this plugin(???!)
import channels
from compat2and3 import urllib
# SHOUTcast data module ----------------------------------------
class shoutcast(channels.ChannelPlugin):
# desc
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# sub-categories are queried per 'AJAX'
def update_categories(self):
html = http.get(self.base_url)
self.categories = []
__print__( dbg.DATA, html )
# <h2>Radio Genres</h2>
rx = re.compile(r'<li((?:\s+id="\d+"\s+class="files")?)><a href="\?action=sub&cat=([\w\s]+)#(\d+)">[\w\s]+</a>', re.S)
sub = []
for uu in rx.findall(html):
__print__( dbg.DATA, uu )
(main,name,id) = uu
name = urllib.unquote(name)
# main category
if main:
if sub:
self.categories.append(sub)
sub = []
|
|
|
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# sub-categories are queried per 'AJAX'
def update_categories(self):
html = http.get(self.base_url)
self.categories = []
__print__( dbg.DATA, html )
# <h2>Radio Genres</h2>
rx = re.compile(r'<li((?:\s+id="\d+"\s+class="files")?)><a href="\?action=sub&cat=([\w\s]+)#(\d+)">[\w\s]+</a>', re.S)
sub = []
for uu in rx.findall(html):
__print__( dbg.DATA, uu )
(main,name,id) = uu
name = urllib.unquote(name)
# main category
if main:
if sub:
self.categories.append(sub)
sub = []
|