Check-in [95f6f0f64f]
Overview
Comment: | Support netrc account lookup (for MyOggRadio). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
95f6f0f64fa263d8bf948e1e8af346b9 |
User & Date: | mario on 2015-03-30 17:41:46 |
Other Links: | manifest | tags |
Context
2015-03-30
| ||
17:42 | Use absolute path (conf.share) for plugin lookup with pkgutil. check-in: 665f4b36ad user: mario tags: trunk | |
17:41 | Support netrc account lookup (for MyOggRadio). check-in: 95f6f0f64f user: mario tags: trunk | |
17:40 | Load main module meta data. check-in: a678391248 user: mario tags: trunk | |
Changes
Modified channels/myoggradio.py from [a6b1955e45] to [013f2545e5].
1 2 3 4 5 6 | # # 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 | # # api: streamtuner2 # title: MyOggRadio # description: Open source internet radio directory. # type: channel # category: radio # version: 0.6 # url: http://www.myoggradio.org/ # depends: json, StringIO # 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 # |
︙ | ︙ | |||
35 36 37 38 39 40 41 | import copy # open source radio sharing stie class myoggradio(ChannelPlugin): | | | < < > > > | 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 | import copy # open source radio sharing stie class myoggradio(ChannelPlugin): # settings title ="MOR" module = "myoggradio" api = "http://www.myoggradio.org/" listformat = "url/direct" # hide unused columns titles = dict(playing=False, listeners=False, bitrate=False) # category map categories = ['common', 'personal'] default = 'common' current = 'common' # netrc instance netrc = None # prepare GUI def __init__(self, parent): ChannelPlugin.__init__(self, parent) if parent: |
︙ | ︙ | |||
169 170 171 172 173 174 175 | data = dict(zip(["benutzer", "passwort"], login)) http.get(self.api + "c_login.jsp", params=data, ajax=1) # let's hope the JSESSIONID cookie is kept # returns login (user,pw) def user_pw(self): | | | | > > > | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | data = dict(zip(["benutzer", "passwort"], login)) http.get(self.api + "c_login.jsp", params=data, ajax=1) # let's hope the JSESSIONID cookie is kept # returns login (user,pw) def user_pw(self): 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]] pass |
Modified config.py from [1687cc55ba] to [799d76f2f1].
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # export symbols __all__ = ["conf", "__print__", "dbg", "plugin_meta"] #-- create a stub instance of config object conf = object() #-- global configuration data --------------------------------------------- class ConfigDict(dict): | > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # export symbols __all__ = ["conf", "__print__", "dbg", "plugin_meta"] #-- create a stub instance of config object conf = object() # separate instance of netrc, if needed netrc = None #-- global configuration data --------------------------------------------- class ConfigDict(dict): |
︙ | ︙ | |||
122 123 124 125 126 127 128 | # plugin state if module and module not in conf.plugins: conf.plugins[module] = 1 # http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html | | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | # plugin state if module and module not in conf.plugins: conf.plugins[module] = 1 # http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html def xdg(self, path="/streamtuner2"): home = os.environ.get("HOME", self.tmp) config = os.environ.get("XDG_CONFIG_HOME", os.environ.get("APPDATA", home+"/.config")) # storage dir self.dir = config + path # create if necessary if (not os.path.exists(self.dir)): os.makedirs(self.dir) # store some configuration list/dict into a file |
︙ | ︙ | |||
207 208 209 210 211 212 213 214 215 216 217 218 219 220 | # check for existing filename in directory list def find_in_dirs(self, dirs, file): for d in dirs: if os.path.exists(d+"/"+file): return d+"/"+file # Plugin meta data extraction # # Extremely crude version for Python and streamtuner2 plugin usage. # Fetches module source, or reads from filename / out of zip package. | > > > > > > > > > > > > > > > > > | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | # check for existing filename in directory list def find_in_dirs(self, dirs, file): for d in dirs: if os.path.exists(d+"/"+file): return d+"/"+file # standard user account storage in ~/.netrc or less standard but contemporarily in ~/.config/netrc def netrc(self, varhosts=("shoutcast.com")): global netrc if not netrc: netrc = {} try: from netrc import netrc as parser try: netrc = parser().hosts except: netrc = parser(self.xdg() + "/netrc").hosts except: pass for server in varhosts: if server in netrc: return netrc[server] # Plugin meta data extraction # # Extremely crude version for Python and streamtuner2 plugin usage. # Fetches module source, or reads from filename / out of zip package. |
︙ | ︙ |
Modified help/channel_myoggradio.page from [23cd12b6a8] to [c7e655e988].
︙ | ︙ | |||
19 20 21 22 23 24 25 | streamtuner2 provides an option to share radion station links. Use <guiseq><gui>Station</gui> <gui>Extensions</gui> <gui>Share on MyOggRadio...</gui></guiseq> menu entry to upload the currently selected radio (e.g. from your favourite bookmarks).</p> <p>The personal section is empty per default. You need to specify an user account in the settings dialog, and actually bookmark stations in the MyOggRadio web site. | | > | < | | | > > > > > > > > > > > > > > | 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 | streamtuner2 provides an option to share radion station links. Use <guiseq><gui>Station</gui> <gui>Extensions</gui> <gui>Share on MyOggRadio...</gui></guiseq> menu entry to upload the currently selected radio (e.g. from your favourite bookmarks).</p> <p>The personal section is empty per default. You need to specify an user account in the settings dialog, and actually bookmark stations in the MyOggRadio web site. Shared entries aren't automatically in the <gui style="button">personal</gui> list.</p> <note style="tip"><p>MyOggRadio also has a neat cross-platform player: <link href="http://freshcode.club/projects/jmorp">JMyOggRadioPlayer</link>.</p></note> <terms> <title>Channel options.</title> <item> <title><code>Login settings</code></title> <p>If you want to upload station infos to MyOggRadio, you need an account there. Registration is free and doesn't require personal information nor email address. Specify it as <input>username:</input> separated with a : colon in this field.</p> <note style="advanced"> <p>Alternatively you can store your account settings in the central <file>~/.netrc</file> config file. Or in <file>~/.config/netc</file> even.</p> <p>Your entry for MyOggRadio should follow the common format:</p> <code> machine myoggradio.org login usr123 password pw123 </code> <p>Which is useful because it's a standard format, and prevents leaking authorization data into per-application config stores. Note that a user:pw setting in streamtuner takes precedence though.</p> </note> </item> <item> <title><code>stream URL format</code></title> <p>When uploading stations, the streaming URL can be converted into RAW format. You can however leave it as .PLS link file.</p> </item> </terms> </page> |