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

⌈⌋ branch:  streamtuner2


Check-in [39b9182c6e]

Overview
SHA1 Hash:39b9182c6e6114cb6b0ef009b376d611700759bf
Date: 2017-02-13 16:47:58
User: mario
Comment:Add version and -V flags.
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2017-02-13
16:48
[c05cee4440] Simplify best_url() dict generation, typecasting, add more comments on channel webpage. (user: mario, tags: trunk)
16:47
[39b9182c6e] Add version and -V flags. (user: mario, tags: trunk)
2017-02-12
20:57
[82b87725e3] new plugin: streamlicensing (user: mario, tags: trunk)
Changes

Modified cli.py from [de8c726472] to [bf2c97a84d].

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
61
62
63
64
65
..
71
72
73
74
75
76
77
78











79
80
81
82
83
84
85
...
138
139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
...
161
162
163
164
165
166
167

168
169
170
171
172
173
    channel_modules = ["shoutcast", "xiph", "icast", "jamendo", "radiobrowser"]# module_list()
    current_channel = "cli"
    plugins = {} # only populated sparsely by .stream()
    
    
    # start
    def __init__(self, actions):


        # fake init    
        action.main = empty_parent()
        action.main.current_channel = self.current_channel

        # check if enough arguments, else  help


        if not actions:
            a = self.help
        # first cmdline arg == action
        else:
            command = actions[0]
            if command in dir(self):
                cmd = self.__getattribute__(command)
            else:
                log.ERR("No such command:", command)
                return

        # run

        result = cmd(*actions[1:])
        if result:
            self.json(result)
        
        
    # show help
    def help(self, *args): 
................................................................................
          streamtuner2 dump xiph
          streamtuner2 play "..."
          streamtuner2 url "..."
    load fresh:
          streamtuner2 category shoutcast "Top 40"
          streamtuner2 categories xiph
        """)
        











    # prints stream data from cache
    def stream(self, *args):
 
        # optional channel name, title
        if len(args) > 1:
            (channel_list, title) = args
            channel_list = channel_list.split(",")
................................................................................
        return r
        
        
    # load module
    def channel(self, module):
        plugin = __import__("channels."+module, None, None, [""])
        plugin_class = plugin.__dict__[module]
        p = plugin_class(None)
        p.parent = empty_parent()

        return p
    
    # load all channel modules    
    def channels(self, channels=None):
        if channels:
            channels = channels.split(",")
        else:
................................................................................
    
    
    
    
# trap for some main window calls
class empty_parent (object):    
    channel = {}

    null = lambda *a: None
    status = lambda *a: None
    thread = lambda *a: None


    







|
>





>
>
|
|










>







 







|
>
>
>
>
>
>
>
>
>
>
>







 







<
|
>







 







>






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
61
62
63
64
65
66
67
68
69
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
153
154
155
156
157
158
159

160
161
162
163
164
165
166
167
168
...
176
177
178
179
180
181
182
183
184
185
186
187
188
189
    channel_modules = ["shoutcast", "xiph", "icast", "jamendo", "radiobrowser"]# module_list()
    current_channel = "cli"
    plugins = {} # only populated sparsely by .stream()
    
    
    # start
    def __init__(self, actions):
        #log.INIT(actions)
        #log.CONF(conf.args)
        # fake init    
        action.main = empty_parent()
        action.main.current_channel = self.current_channel

        # check if enough arguments, else  help
        if conf.args.version:
            cmd = self.show_version
        elif not actions:
            cmd = self.help
        # first cmdline arg == action
        else:
            command = actions[0]
            if command in dir(self):
                cmd = self.__getattribute__(command)
            else:
                log.ERR("No such command:", command)
                return

        # run
        #log.CONF(cmd)
        result = cmd(*actions[1:])
        if result:
            self.json(result)
        
        
    # show help
    def help(self, *args): 
................................................................................
          streamtuner2 dump xiph
          streamtuner2 play "..."
          streamtuner2 url "..."
    load fresh:
          streamtuner2 category shoutcast "Top 40"
          streamtuner2 categories xiph
        """)

    # only show -V version
    def show_version(self, *args):
        print(plugin_meta(frame=3)["version"])

    # show modules and versions
    def modules(self, *args):
        self.channel("pluginmanager2")
        for name in ["st2", "config", "uikit", "pluginconf", "action", "cli", "ahttp"] + module_list():
            meta = plugin_meta(module=name, extra_base=["config"])
            print("%s: %s" % (name, meta["version"]))
    
    # prints stream data from cache
    def stream(self, *args):
 
        # optional channel name, title
        if len(args) > 1:
            (channel_list, title) = args
            channel_list = channel_list.split(",")
................................................................................
        return r
        
        
    # load module
    def channel(self, module):
        plugin = __import__("channels."+module, None, None, [""])
        plugin_class = plugin.__dict__[module]

        parent = empty_parent()
        p = plugin_class(parent)
        return p
    
    # load all channel modules    
    def channels(self, channels=None):
        if channels:
            channels = channels.split(",")
        else:
................................................................................
    
    
    
    
# trap for some main window calls
class empty_parent (object):    
    channel = {}
    hooks = { "init": [], "config_save": [], "config_load": [] }
    null = lambda *a: None
    status = lambda *a: None
    thread = lambda *a: None


    

Modified st2.py from [0e842350c3] to [13a6df97da].

514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
...
536
537
538
539
540
541
542

543
544
545
546
547
548



# startup procedure
def main():

    # graphical
    if not len(conf.args.action):

        # prepare for threading in Gtk+ callbacks
        gobject.threads_init()

        # prepare main window
        main = StreamTunerTwo()

................................................................................
        gtk.main()
        [callback() for callback in main.hooks["quit"]]
        log.PROC(r" gtk_main_quit ")
        
    # invoke command-line interface
    else:
        import cli

        cli.StreamTunerCLI(conf.args.action)

# run
if __name__ == "__main__":
    main()








|







 







>






514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
...
536
537
538
539
540
541
542
543
544
545
546
547
548
549



# startup procedure
def main():

    # graphical
    if not len(conf.args.action) and not conf.args.version:

        # prepare for threading in Gtk+ callbacks
        gobject.threads_init()

        # prepare main window
        main = StreamTunerTwo()

................................................................................
        gtk.main()
        [callback() for callback in main.hooks["quit"]]
        log.PROC(r" gtk_main_quit ")
        
    # invoke command-line interface
    else:
        import cli
        #print "CLI.py:"
        cli.StreamTunerCLI(conf.args.action)

# run
if __name__ == "__main__":
    main()