1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
78
79
80
81
82
83
84
85
86
87
|
# encoding: UTF-8
# api: streamtuner2
# title: ListenLive
# description: European radio stations streaming live on the internet
# url: http://listenlive.eu/
# version: 0.0
# type: channel
# category: radio
# config: -
# png:
# iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAARVBMVEWdHBWSg1Cbj1mnmF6jn5GuomajpaCrqYu3qmy0roi6
# r3rAsW25tae2t7HCvKfPv3rOw4zKxrfJyMDTzaXUz7LW1s7g4t727CdZAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJ
# cEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQffBQcAMynMUk7PAAAAkElEQVQY01VP2xbDIAizUq0WGS1e/v9TB9qdbXlLICE4
# Z9g8gN/cB1tAVmB4JI98tdbqlZJ/eBWS3u8jTCVx7RRNKEdKzgFffVBUfpdyItjCGJG6iCqZk0Nuo6tDiIp6cAqiDokx7hZi
# Fo3QBSp7xmChOhSxjNfJsM5OaKadncWWkL9V/6rrc7Ceg59/vWLRN2yqCjHMvARcAAAAAElFTkSuQmCC
# png-orig: https://openclipart.org/detail/148465/1-euro
# priority: extra
# extraction-method: regex
#
# And another radio directory, primarily collecting euro
# stations, mixed genres, and grouping by country.
#
# Also available:
# http://www.australianliveradio.com/
# http://www.nzradioguide.co.nz/
import re
from config import *
from channels import *
import ahttp
# listenlive.eu
class listenlive (ChannelPlugin):
# control flags
has_search = False
listformat = "srv"
audioformat = "mp3"
titles = dict(listeners=False, playing="Location")
categories = []
base = "http://listenlive.eu/{}.html"
# short list of categories
def update_categories(self):
html = ahttp.get("http://listenlive.eu/")
ls = re.findall(r"""b.gif"[\s/]*>\s+<a\s+href="(\w+).html">([^<>]+)</a>""", html)
self.catmap = {title: link for link, title in ls}
self.categories = [title for link, title in ls]
# Fetch entries
def update_streams(self, cat, search=None):
r = []
# split into table rows
html = ahttp.get(self.base.format(self.catmap[cat]), encoding="utf-8")
for tr in html.split("<tr>"):
# extract fields
ls = re.findall("""
<a\s+href="([^<">]+)"> # homepage
<b>([^<>]+)</b> # title
.*? <td>([^<>]+)</td> # location
.+ alt="(\w+)" # format
.+ <a\s+href="([^<">]+)"> # url
(\d+) # bitrate
""", tr, re.X|re.S)
# assemble into rows
if len(ls) and len(ls[0]) == 6:
homepage, title, location, format, url, bitrate = ls[0]
genre = re.findall("<td>([^<>]+)</td>\s</tr>", tr)
r.append(dict(
homepage = homepage,
playing = location,
title = unhtml(title),
url = url,
genre = genre[0] if genre else cat,
bitrate = int(bitrate),
format = mime_fmt(format),
))
return r
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|