Check-in [9eeccf1f29]
Overview
| Comment: | Detect more absent variables/login, introduce UI delay on submission. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
9eeccf1f297ae00ca1a5332b45a4acec |
| User & Date: | mario on 2017-01-05 21:22:05 |
| Other Links: | manifest | tags |
Context
|
2017-01-05
| ||
| 21:23 | Introduce FeaturePlugin as new base class for channels and all other plugins. Pre-defines the meta, module attributes and calls init2(). check-in: ea924e3c27 user: mario tags: trunk | |
| 21:22 | Detect more absent variables/login, introduce UI delay on submission. check-in: 9eeccf1f29 user: mario tags: trunk | |
| 21:21 | Catch unset time prior queueing. Use new FeaturePlugin class. check-in: 9cff8f85d7 user: mario tags: trunk | |
Changes
Modified channels/myoggradio.py from [1e246c384f] to [c318545725].
1 2 3 4 5 6 | # encoding: utf-8 # api: streamtuner2 # title: MyOggRadio # description: Open source internet radio directory. # type: channel # category: radio | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# encoding: utf-8
# api: streamtuner2
# title: MyOggRadio
# description: Open source internet radio directory.
# type: channel
# category: radio
# version: 0.7.5
# url: http://www.myoggradio.org/
# depends: json, ahttp >= 1.5
# config:
# { name: myoggradio_login, type: text, value: "user:password", description: "Account for storing personal favourites." }
# { name: myoggradio_morph, type: boolean, value: 0, description: "Convert pls/m3u into direct shoutcast url." }
# priority: standard
# png:
|
| ︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | from channels import * from config import * import action from uikit import uikit import ahttp import re import json import copy from uikit import gtk | > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | from channels import * from config import * import action from uikit import uikit import ahttp import time import re import json import copy from uikit import gtk |
| ︙ | ︙ | |||
86 87 88 89 90 91 92 |
# bookmarks
elif (cat == "personal") and self.user_pw():
data = ahttp.get(self.api + "favoriten.json?user=" + self.user_pw()[0], encoding="utf-8")
entries = json.loads(data)
# unknown
else:
| | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# bookmarks
elif (cat == "personal") and self.user_pw():
data = ahttp.get(self.api + "favoriten.json?user=" + self.user_pw()[0], encoding="utf-8")
entries = json.loads(data)
# unknown
else:
self.status("Unknown category")
pass
# augment result list
for i,e in enumerate(entries):
entries[i]["homepage"] = self.api + "c_common_details.jsp?url=" + e["url"]
entries[i]["genre"] = cat
entries[i]["format"] = "audio/mpeg"
|
| ︙ | ︙ | |||
126 127 128 129 130 131 132 |
if row["title"] in (r.get("title") for r in self.streams["common"]):
pass
elif row["url"] in (r.get("url") for r in self.streams["common"]):
pass
# send
else:
| | | | > > | | | > > | > > > > | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
if row["title"] in (r.get("title") for r in self.streams["common"]):
pass
elif row["url"] in (r.get("url") for r in self.streams["common"]):
pass
# send
else:
self.status("Sharing station URL...")
if (self.upload(row)):
# artificial slowdown, else user will assume it didn't work
self.status(0.5)
time.sleep(0.1)
# tell Gtk we've handled the situation
self.status("Shared '" + row["title"][:30] + "' on MyOggRadio.org", icon="gtk-save")
else:
self.status()
return True
# upload bookmarks
def send_bookmarks(self, entries=[]):
for e in (entries if entries else parent.bookmarks.streams["favourite"]):
self.upload(e)
# send row to MyOggRadio
def upload(self, e, form=0):
return True
if e:
login = self.user_pw()
if not login:
return
submit = {
"user": login[0], # api
"passwort": login[1], # api
"url": e["url"],
"bemerkung": e["title"],
"genre": e["genre"],
"typ": e["format"][6:],
"eintragen": "eintragen", # form
}
|
| ︙ | ︙ | |||
184 185 186 187 188 189 190 |
if len(conf.myoggradio_login) and conf.myoggradio_login != "user:password":
return conf.myoggradio_login.split(":")
else:
lap = conf.netrc(["myoggradio", "myoggradio.org", "www.myoggradio.org"])
if lap:
return [lap[0] or lap[1], lap[2]]
else:
| | < < | 193 194 195 196 197 198 199 200 201 202 |
if len(conf.myoggradio_login) and conf.myoggradio_login != "user:password":
return conf.myoggradio_login.split(":")
else:
lap = conf.netrc(["myoggradio", "myoggradio.org", "www.myoggradio.org"])
if lap:
return [lap[0] or lap[1], lap[2]]
else:
self.status("No login data for MyOggRadio configured. See F12 for setup, or F1 for help.", timeout=10, icon="gtk-dialog-error")
pass
|