Check-in [976c41ca3a]
Overview
| Comment: | Fix https:// URL prefix, to avoid extraneous redirects. Add referer=1, ajax=1 to all GET/POST requests. More readable extraction (rx/pq) callback. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
976c41ca3ade3fea6cbe69f4fffbd1bc |
| User & Date: | mario on 2015-09-10 19:08:37 |
| Other Links: | manifest | tags |
References
|
2015-09-10
| ||
| 19:11 | • Fixed ticket [036c00275d]: Radionomy repeats station entries again plus 4 other changes artifact: ca79006ed7 user: mario | |
Context
|
2015-09-10
| ||
| 19:09 | Fix POST requests to use data= instead of params=, else would turn into GET-style parameters. Add extra debugging (commented out). check-in: 8f5515beb8 user: mario tags: trunk | |
| 19:08 | Fix https:// URL prefix, to avoid extraneous redirects. Add referer=1, ajax=1 to all GET/POST requests. More readable extraction (rx/pq) callback. check-in: 976c41ca3a user: mario tags: trunk | |
|
2015-06-01
| ||
| 21:43 | Add missing pages to HTML manual version. check-in: 9d10307ec9 user: mario tags: trunk | |
Changes
Modified channels/radionomy.py from [df5905438c] to [ccaf9dfc02].
1 2 3 4 5 | # encoding: UTF-8 # api: streamtuner2 # title: Radionomy # description: Modern radio directory and streaming provider # url: http://radionomy.com/ | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 |
# encoding: UTF-8
# api: streamtuner2
# title: Radionomy
# description: Modern radio directory and streaming provider
# url: http://radionomy.com/
# version: 0.6
# type: channel
# category: radio
# config: -
# { name: radionomy_pages, type: int, value: 3, category: limit, description: Number of pages per category to scan. }
# { name: radionomy_update, type: boolean, value: 1, description: Also fetch OnAir updates about currently playing songs. }
# png:
# iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAACXBIWXMAAAsTAAALEwEAmpwYAAABIElEQVQ4y62Uv0rEQBCHv/yRQziJ1bYWV/gCaxrhGrtrg1f5GMc+xOKLeIetVjZXHRrwAewstxMWFDViM5EQcrk9yTRJZn+/j51h
|
| ︙ | ︙ | |||
41 42 43 44 45 46 47 |
# control attributes
has_search = False
listformat = "srv"
audioformat = "audio/mpeg"
titles = dict(listeners=False, bitrate=False)
categories = []
| | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# control attributes
has_search = False
listformat = "srv"
audioformat = "audio/mpeg"
titles = dict(listeners=False, bitrate=False)
categories = []
base = "https://www.radionomy.com"
playing = {} # OnAir/Update dict
# categories
def update_categories(self):
|
| ︙ | ︙ | |||
77 78 79 80 81 82 83 |
# stations
def update_streams(self, cat, search=None):
r = []
# category or search
if cat:
req = self.base + self.catmap[cat]
| | | > > | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# stations
def update_streams(self, cat, search=None):
r = []
# category or search
if cat:
req = self.base + self.catmap[cat]
# https://www.radionomy.com/de/style/GENRE
html = ahttp.get(req, ajax=1, referer=1)
# https://www.radionomy.com/de/OnAir/Update
self.onair_update(req)
# collect additional pages
for i in range(0, int(conf.radionomy_pages) - 1):
add = ahttp.get(req, { "scrollOffset": i }, post=1, ajax=1, referer=1)
if add.find("browseRadio") < 0:
break
html += add
self.onair_update(req)
# extractzz
for data in self.data_play_stream(html):
|
| ︙ | ︙ | |||
104 105 106 107 108 109 110 |
homepage = "http://www.radionomy.com/en/radio/{}/index".format(data["url"]),
img = re.sub("\.s\d+\.", ".s32.", data["logo"]),
uid = data["radioUID"],
))
return r
| | > > | > > > | > | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
homepage = "http://www.radionomy.com/en/radio/{}/index".format(data["url"]),
img = re.sub("\.s\d+\.", ".s32.", data["logo"]),
uid = data["radioUID"],
))
return r
# Extracts the data-play-stream= JSON blob attributes
@use_rx
def data_play_stream(self, html, use_rx):
if use_rx:
return [
entity_decode(json_attr) for json_attr in
re.findall('data-play-stream="({.*?})"', html)
]
else:
# fix up for PyQuery, else ignores appended content
html = re.sub("</html>|</body>", "", html) + "</body></html>"
return [
div.attrib["data-play-stream"] for div in
pq(html)(".browseRadioWrap .radioPlayBtn")
]
# Retrieve en/OnAir/Update for per-UID song titles
def onair_update(self, req):
if conf.radionomy_update:
try:
d = json.loads(
ahttp.get("https://www.radionomy.com/en/OnAir/Update", post=1, referer=req, ajax=1)
)
if not d:
return
print d
self.playing.update(
{row["RadioUID"]: "{Title} - {Artist}".format(**row) for row in d}
)
except Exception as e:
log.ERR("Radionomy title update:", e)
|