Check-in [2b3b50b6ad]
Overview
| Comment: | Removed static .title and .module properties. Plugin discovery now realized through pkgutil.iter_modules(). |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
2b3b50b6ad9b7e64e1f616c9e27e8238 |
| User & Date: | mario on 2015-03-29 03:03:50 |
| Other Links: | manifest | tags |
Context
|
2015-03-29
| ||
| 03:06 | More complete plugin_meta() regex patterns. Now defaults to inspect.get_comments() on previous stack frame, src= or fn= only accepted as fallback. Complete default meta fields, splits doc block out, autostrips hash prefixes and indentation. check-in: 70c2e437fd user: mario tags: trunk | |
| 03:03 | Removed static .title and .module properties. Plugin discovery now realized through pkgutil.iter_modules(). check-in: 2b3b50b6ad user: mario tags: trunk | |
|
2015-03-28
| ||
| 18:50 | Merged _generic into channels/__init__. check-in: 817010842c user: mario tags: trunk | |
Changes
Modified channels/__init__.py from [da5f3b55c8] to [14b4644be4].
1 2 3 4 5 | # # encoding: UTF-8 # api: streamtuner2 # type: base # category: ui | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # # encoding: UTF-8 # api: streamtuner2 # type: base # category: ui # title: Channel plugins # description: Base implementation for channels and feature plugins # version: 1.1 # license: public domain # author: mario # url: http://fossil.include-once.org/streamtuner2/ # pack: # file.py global_key.py history.py icast.py internet_radio.py # itunes.py jamendo.py links.py live365.py modarchive.py # myoggradio.py punkcast.py shoutcast.py surfmusik.py tunein.py # timer.py xiph.py youtube.py radiotray.py *.png # priority: core # config: - |
| ︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import action
import favicon
import os.path
import xml.sax.saxutils
import re
import copy
import inspect
# Only export plugin classes
__all__ = [
"GenericChannel", "ChannelPlugin", "module_list"
]
# Search through ./channels/ and get module basenames.
# Also order them by conf.channel_order
#
def module_list():
| > | | | < < < < < < < < < < | < | 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 |
import action
import favicon
import os.path
import xml.sax.saxutils
import re
import copy
import inspect
import pkgutil
# Only export plugin classes
__all__ = [
"GenericChannel", "ChannelPlugin", "module_list"
]
# Search through ./channels/ and get module basenames.
# Also order them by conf.channel_order
#
def module_list():
# Should list plugins within zips as well as local paths
ls = pkgutil.iter_modules(["channels"])
ls = [name for loader,name,ispkg in ls]
# resort with tab order
order = [module.strip() for module in conf.channel_order.lower().replace(".","_").replace("-","_").split(",")]
ls = [module for module in (order) if (module in ls)] + [module for module in (ls) if (module not in order)]
return ls
# generic channel module ---------------------------------------
class GenericChannel(object):
# desc
meta = { "config": [] }
homepage = "http://fossil.include-once.org/streamtuner2/"
base_url = ""
listformat = "audio/x-scpls"
audioformat = "audio/mpeg" # fallback value
config = []
has_search = False
|
| ︙ | ︙ | |||
133 134 135 136 137 138 139 |
# constructor
def __init__(self, parent=None):
#self.streams = {}
self.gtk_list = None
self.gtk_cat = None
| | | > > > > > > > > > > > | 124 125 126 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 |
# constructor
def __init__(self, parent=None):
#self.streams = {}
self.gtk_list = None
self.gtk_cat = None
self.meta = plugin_meta(None, inspect.getcomments(inspect.getmodule(self)))
self.config = self.meta.get("config", [])
self.title = self.meta.get("title", self.module)
# only if streamtuner2 is run in graphical mode
if (parent):
self.cache()
self.gui(parent)
pass
# called before application shutdown
# some plugins might override this, to save their current streams[] data
def shutdown(self):
pass
#__del__ = shutdown
# get class name
@property
def module(self):
return self.__class__.__name__
# get title
@property
def title(self):
return self.meta.get("title", self.module)
# returns station entries from streams[] for .current category
def stations(self):
return self.streams.get(self.current, [])
def rowno(self):
pass
|
| ︙ | ︙ | |||
206 207 208 209 210 211 212 |
# load default category
if (self.current):
self.load(self.current)
else:
mygtk.columns(self.gtk_list, self.datamap, [])
# add to main menu
| | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# load default category
if (self.current):
self.load(self.current)
else:
mygtk.columns(self.gtk_list, self.datamap, [])
# add to main menu
mygtk.add_menu(parent.channelmenuitems, self.meta["title"], lambda w: parent.channel_switch(w, self.module) or 1)
# make private copy of .datamap and modify field (title= only ATM)
def update_datamap(self, search="name", title=None):
if self.datamap == GenericChannel.datamap:
self.datamap = copy.deepcopy(self.datamap)
for i,row in enumerate(self.datamap):
|
| ︙ | ︙ | |||
573 574 575 576 577 578 579 |
fn = "/usr/share/streamtuner2/channels/" + self.module + ".png"
if os.path.exists(fn):
icon = gtk.Image()
icon.set_property("pixbuf", gtk.gdk.pixbuf_new_from_file(fn))
icon.set_property("icon-size", 1)
icon.set_property("visible", True)
label.pack_start(icon, expand=False, fill=True)
| | | | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
fn = "/usr/share/streamtuner2/channels/" + self.module + ".png"
if os.path.exists(fn):
icon = gtk.Image()
icon.set_property("pixbuf", gtk.gdk.pixbuf_new_from_file(fn))
icon.set_property("icon-size", 1)
icon.set_property("visible", True)
label.pack_start(icon, expand=False, fill=True)
if self.meta["title"]:
text = gtk.Label(self.meta["title"])
text.set_property("visible", True)
label.pack_start(text, expand=True, fill=True)
# pack it into an event container to catch double-clicks
ev_label = gtk.EventBox()
ev_label.add(label)
ev_label.connect('event', parent.on_homepage_channel_clicked)
|
| ︙ | ︙ |