Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Check-in [d34fb69dda]

Overview
Comment:add hooks{} support
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d34fb69dda7d064f24117257489ab9f96b80277d
User & Date: mario on 2014-05-19 19:26:38
Other Links: manifest | tags
Context
2014-05-19
19:27
update config dialog check-in: 9d4259a324 user: mario tags: trunk
19:26
add hooks{} support check-in: d34fb69dda user: mario tags: trunk
2014-05-15
20:07
Better probe for None and empty "" string in titles or urls check-in: 9bfbde8091 user: mario tags: trunk
Changes

Modified st2.py from [95ed169041] to [ed4fb66de3].

105
106
107
108
109
110
111



112
113
114
115
116
117
118
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121







+
+
+








        # object containers
        widgets = {}     # non-glade widgets (the manually instantiated ones)
        channels = {}    # channel modules
        features = {}    # non-channel plugins
        working = []     # threads
        add_signals = {} # channel gtk-handler signals
        hooks = {
            "play": [favicon.download_playing],  # observers queue here
        }

        # status variables
        channel_names = ["bookmarks"]    # order of channel notebook tabs
        current_channel = "bookmarks"    # currently selected channel name (as index in self.channels{})


        # constructor
126
127
128
129
130
131
132
133

134
135
136
137
138
139
140
129
130
131
132
133
134
135

136
137
138
139
140
141
142
143







-
+







            gtk.Builder.add_from_file(self, conf.find_in_dirs([".", conf.share], ui_file)), gui_startup(2/20.0)
            # manual gtk operations
            self.extensionsCTM.set_submenu(self.extensions)  # duplicates Station>Extension menu into stream context menu

            # initialize channels
            self.channels = {
              "bookmarks": bookmarks(parent=self),   # this the remaining built-in channel
              "shoutcast": None,#shoutcast(parent=self),
              #"shoutcast": None,#shoutcast(parent=self),
            }
            gui_startup(3/20.0)
            self.load_plugin_channels()   # append other channel modules / plugins


            # load application state (widget sizes, selections, etc.)
            try:
306
307
308
309
310
311
312
313

314
315
316
317
318
319
320
309
310
311
312
313
314
315

316
317
318
319
320
321
322
323







-
+









        # play button
        def on_play_clicked(self, widget, event=None, *args):
            row = self.row()
            if row:
                self.channel().play(row)
                favicon.download_playing(row)
                [hook(row) for hook in self.hooks["play"]]


        # streamripper
        def on_record_clicked(self, widget):
            row = self.row()
            action.record(row.get("url"), "audio/mpeg", "url/direct", row=row)

846
847
848
849
850
851
852
853

854
855
856
857
858
859
860
849
850
851
852
853
854
855

856
857
858
859
860
861
862
863







-
+







        def add_plugins(self):

            for name,meta in channels.module_meta().items():

                # add plugin load entry
                if name:
                    cb = gtk.CheckButton(name)
                    cb.child.set_markup("<b>%s</b> <i>(%s)</i> %s\n<small>%s</small>" % (meta["title"], meta["type"], meta.get("version", ""), meta["description"]))
                    cb.get_children()[0].set_markup("<b>%s</b> <i>(%s)</i> %s\n<small>%s</small>" % (meta["title"], meta["type"], meta.get("version", ""), meta["description"]))
                    self.add_( "config_plugins_"+name, cb )

                # look up individual plugin options, if loaded
                if self.channels.get(name) or self.features.get(name):
                    c = self.channels.get(name) or self.features.get(name)
                    for opt in c.config:

956
957
958
959
960
961
962
963
964
965
966

967
968
969
970
971
972
973
959
960
961
962
963
964
965

966
967

968
969
970
971
972
973
974
975







-


-
+







# Some feature extensions inject custom categories[] into streams{}
# e.g. "search" adds its own category once activated, as does the "timer" plugin.
#
class bookmarks(GenericChannel):


        # desc
        api = "streamtuner2"
        module = "bookmarks"
        title = "bookmarks"
        version = 4/10
        version = 0.4
        base_url = "file:.config/streamtuner2/bookmarks.json"
        listformat = "*/*"

        
        # i like this
        config = [
            {"name":"like_my_bookmarks", "type":"boolean", "value":0, "description":"I like my bookmarks"},