1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#
# encoding: UTF-8
# api: streamtuner2
# type: base
# category: ui
# title: Channel plugin handling
# description: Base implementation for channels and feature plugins
# version: 1.1
# license: public domain
# author: mario
# 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: -
|
|
>
|
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
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
87
88
89
90
91
92
93
94
95
|
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():
# find plugin files
ls = os.listdir(conf.share + "/channels/")
ls = [fn[:-3] for fn in ls if re.match("^[a-z][\w\d_]+\.py$", fn)]
# 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
# dict==object
#class struct(dict):
# def __init__(self, *xargs, **kwargs):
# self.__dict__ = self
# self.update(kwargs)
# [self.update(x) for x in xargs]
# pass
# generic channel module ---------------------------------------
class GenericChannel(object):
# desc
module = "generic"
meta = {}
title = "GenericChannel"
homepage = "http://fossil.include-once.org/streamtuner2/"
base_url = ""
listformat = "audio/x-scpls"
audioformat = "audio/mpeg" # fallback value
config = []
has_search = False
|
>
|
|
|
<
<
<
<
<
<
<
<
<
<
|
<
|
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# constructor
def __init__(self, parent=None):
#self.streams = {}
self.gtk_list = None
self.gtk_cat = None
self.meta = plugin_meta(inspect.getsourcefile(inspect.getmodule(self)))
self.config = self.meta["config"]
# 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
# returns station entries from streams[] for .current category
def stations(self):
return self.streams.get(self.current, [])
def rowno(self):
pass
|
|
|
>
>
>
>
>
>
>
>
>
>
>
|
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
213
214
215
216
217
218
219
220
|
# 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.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):
|
|
|
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
580
581
582
583
584
585
586
587
588
|
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.title:
text = gtk.Label(self.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)
|
|
|
|
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)
|
︙ | | | ︙ | |