25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 | # static genre list. Podcasts, scheduled programs aren't fetched.
import re
from config import *
from channels import *
import ahttp
# Basic HTML scraping
class publicradiofan (ChannelPlugin):
# control attributes
has_search = True
listformat = "href"
titles = dict(listeners=False, bitrate=False, playing="Description")
categories = ["adult alternative", "adult contemporary", "blues", "business", "classical", "community", "contemporary", "country", "easy", "education", "ethnic", "folk", "free-form", "full service", "government", "international", "jazz", "military", "news", "nostalgia", "oldies", "reading", "regional", "religious", "rock", "seasonal", "sports", "student", "talk", "traffic", "urban", "variety", "world", "youth"]
# static
def update_categories(self):
pass
# Extract from listing tables
def update_streams(self, cat, search=None):
html = ahttp.get("http://www.publicradiofan.com/cgibin/statsearch.pl?format={}&lang=".format(cat))
html = re.split("<H2>", html, 2, re.S)[1]
r = []
for html in re.split("<TR VALIGN=TOP>", html, 0):
m = re.search(r"""
<A .*? HREF=" (?P<url> .+?) ">
<B> (?P<title> .*?) </B>
.*? stt> (?P<descr> .*?) [<&]
.*? stt> (?P<genre> .*?) [<&]
.*? <I> .*? HREF="(?P<homepage> .*?)"
""", html, re.X|re.S)
if m:
r.append(dict(
genre = m.group("genre"),
url = m.group("url"),
title = m.group("title"),
playing = m.group("descr"),
homepage = m.group("homepage"),
))
return r
|
>
>
>
>
| 25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 | # static genre list. Podcasts, scheduled programs aren't fetched.
import re
from config import *
from channels import *
import ahttp
import action
# Basic HTML scraping
class publicradiofan (ChannelPlugin):
# control attributes
has_search = True
format = "mp3"
listformat = "href"
titles = dict(listeners=False, bitrate=False, playing="Description")
categories = ["adult alternative", "adult contemporary", "blues", "business", "classical", "community", "contemporary", "country", "easy", "education", "ethnic", "folk", "free-form", "full service", "government", "international", "jazz", "military", "news", "nostalgia", "oldies", "reading", "regional", "religious", "rock", "seasonal", "sports", "student", "talk", "traffic", "urban", "variety", "world", "youth"]
# static
def update_categories(self):
pass
# Extract from listing tables
def update_streams(self, cat, search=None):
html = ahttp.get("http://www.publicradiofan.com/cgibin/statsearch.pl?format={}&lang=".format(cat))
html = re.split("<H2>", html, 2, re.S)[1]
probe = action.extract_playlist()
r = []
for html in re.split("<TR VALIGN=TOP>", html, 0):
m = re.search(r"""
<A .*? HREF=" (?P<url> .+?) ">
<B> (?P<title> .*?) </B>
.*? stt> (?P<descr> .*?) [<&]
.*? stt> (?P<genre> .*?) [<&]
.*? <I> .*? HREF="(?P<homepage> .*?)"
""", html, re.X|re.S)
if m:
r.append(dict(
genre = m.group("genre"),
url = m.group("url"),
title = m.group("title"),
playing = m.group("descr"),
homepage = m.group("homepage"),
listformat = probe.probe_ext(m.group("url")) or "srv",
))
return r
|