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

⌈⌋ ⎇ branch:  streamtuner2


Changes To write a plugin

Changes to "write a plugin" between 2015-04-03 18:39:25 and 2015-04-03 19:20:30

1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19











+







Wrting a new plugin is often trivial.
Just create a new `channels/name.py` following this structure:

    # title: MyPlugin
    # description: my radio list
    # version: 0.1
    # type: channel
    # category: radio
    # url: http://www.mymusicstation.com/
    # config: -

    from config import *
    from channels import *

    class myplugin (ChannelPlugin):
        title = "MyNewChannel"
        module = "myplugin"

        has_search = False
64
65
66
67
68
69
70
71

72
73
74
75
76
77


78
79
80

65
66
67
68
69
70
71

72
73
74
75
76


77
78
79
80

81







-
+




-
-
+
+


-
+

   * With a `datamap=[]` declaration custom field names could be displayed.

   * Often you just want to rename the column titles however - per `title=dict(listeners="Whatever")` in the class declaration.

Received station lists get stored internally in a `streams={"Pop":[...]}` dict, and cached in the `~/.config/streamtuner2/cache/` directory of course.

There's also a `config=[]` list, in case your plugin needs to keep some settings. (For example an API key.)
You can access your <kbd>config:</kbd> options per the global `conf.*` dict. Take care to prefer unambigious names like `conf.myplugin_pagesize` etc.

The `has_search` class flag permits live server searches. If one is issued, the `update_streams()` method will be called with `cat=None` and `search="Find me maybe"` set instead.

  * Other class options include `listformat="audio/x-scpls"` for declaring the station URL mime type (here `pls` for example).
  * And `audioformat="audio/mpeg"` for the audio mime type.
  * While `current=""` and `default="Pop"` can specify which category is visible per default, or currently active. (Both will be retired in later versions. More a clutch for current Gtk handling.)
  * And `audioformat="audio/mpeg"` for the default audio mime type.
  * While `default="Pop"` can specify which category is visible per default. (Will be retired in later versions. More a clutch for current Gtk handling.)
  * Other internal fields are listed in `channels/_generic.py`

To have a new plugin picked up, you need to copy/symlink the file into `/usr/share/streamtuner2/channels/`. It's imported from the `channels` module group automatically. Which allows relocatability, and later even local plugins. (Which is commonly unneeded featuritis though, so not yet implemented.)
To have a new plugin picked up, you need to copy/symlink the file into `/usr/share/streamtuner2/channels/`. It's imported from the `channels` module group automatically. Which allows relocatability, and later even local plugins. (Which is commonly unneeded featuritis though. So not yet implemented.)