Check-in [85f1271d4d]
Overview
| Comment: | Enable search with post/json=1 and seperating token from other params{} |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
85f1271d4d94caca21e9fb4d877139a5 |
| User & Date: | mario on 2017-02-26 21:43:25 |
| Other Links: | manifest | tags |
Context
|
2017-02-26
| ||
| 21:44 | Collect audio format form URL guessing into new class heuristic_funcs check-in: 7a1577bf74 user: mario tags: trunk | |
| 21:43 | Enable search with post/json=1 and seperating token from other params{} check-in: 85f1271d4d user: mario tags: trunk | |
| 21:42 | Support json= POST requests. check-in: ef2604c3a4 user: mario tags: trunk | |
Changes
Modified channels/dirble.py from [8ed175109e] to [5db6fb7163].
1 2 3 4 5 | # encoding: UTF-8 # api: streamtuner2 # title: Dirble # description: Song history tracker for Internet radio stations. # url: http://dirble.com/ | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 |
# encoding: UTF-8
# api: streamtuner2
# title: Dirble
# description: Song history tracker for Internet radio stations.
# url: http://dirble.com/
# version: 2.4
# type: channel
# category: radio
# config:
# { name: dirble_api_key, value: "", type: text, description: Alternative API access key., hidden: 1 }
# png:
# iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAA3NCSVQICAjb4U/gAAACP0lE
# QVQokVVSO0+UURA9M/d+jyWbBVcQFSQhPqJSYBRFA5pVoFGURApjYYWtvYUNP8FKOwsttDFq
|
| ︙ | ︙ | |||
56 57 58 59 60 61 62 |
# for "best" format+bitrate combinations.
# ยท Leave favicons to regular behaviour,
# station banners are not accessible per CDN.
#
class dirble (ChannelPlugin):
# control flags
| | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# for "best" format+bitrate combinations.
# ยท Leave favicons to regular behaviour,
# station banners are not accessible per CDN.
#
class dirble (ChannelPlugin):
# control flags
has_search = True
listformat = "srv"
titles = dict(playing="Location")
base = "http://api.dirble.com/v2/{}"
key = "a0bdd7b8efc2f5d1ebdf1728b65a07ece4c73de5"
# Retrieve cat list and map
|
| ︙ | ︙ | |||
80 81 82 83 84 85 86 |
self.categories = ["Popular", "Recent"] + cats
# Fetch entries
def update_streams(self, cat, search=None):
self.progress(1)
if search:
| | | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
self.categories = ["Popular", "Recent"] + cats
# Fetch entries
def update_streams(self, cat, search=None):
self.progress(1)
if search:
r = self.api("search", query=search, page=0, pages=1, post=1)
elif cat in ("Popular", "Recent"):
r = self.api("stations/{}".format(cat.lower()), pages=5)
else:
r = self.api("category/{}/stations".format(self.catmap.get(cat, 0)), pages=5)
return [self.unpack(row) for row in r]
# Extract rows
def unpack(self, r):
listeners = 0
|
| ︙ | ︙ | |||
153 154 155 156 157 158 159 |
state_map = {0:"gtk-media-pause", 1:"gtk-media-next", 2:"gtk-media-rewind"}
# Weighting bitrate and audio format for alternative stream URLs
format_q = {"?":0.75, "audio/mpeg":1.0, "audio/aac":1.25, "audio/aacp":1.35, "audio/ogg":1.50}
# Patch API url together, send request, decode JSON list
| | > > > | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
state_map = {0:"gtk-media-pause", 1:"gtk-media-next", 2:"gtk-media-rewind"}
# Weighting bitrate and audio format for alternative stream URLs
format_q = {"?":0.75, "audio/mpeg":1.0, "audio/aac":1.25, "audio/aacp":1.35, "audio/ogg":1.50}
# Patch API url together, send request, decode JSON list
def api(self, method, pages=1, post=0, **params):
# pagination parameters
if pages > 1:
params["page"] = 0
params["per_page"] = 30
params["offset"] = 0
params["token"] = conf.dirble_api_key or self.key
try:
r = []
# paginate results
for params["page"] in range(0, pages):
self.progress(pages)
# send HTTP request and extract JSON
if post:
method += "?token=" + params["token"]
del params["token"]
add = ahttp.get(self.base.format(method), params, post=post, json=post, encoding="utf-8")
add = json.loads(add)
# check for errors
if isinstance(add, dict) and add.get("error"):
if r:
log.WARN(add["error"])
break
else:
|
| ︙ | ︙ |