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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [61c7ecec61]

Overview
Comment:Fix dbus ids, add genre to API (needs mapping perhaps), test against example patch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 61c7ecec61d9a17ab19dd6ddfce743baa0ec69cb
User & Date: mario on 2015-03-28 07:24:56
Other Links: manifest | tags
Context
2015-03-28
07:25
Disable some debugging, move gui_startup() to mygtk collection, allow markup for mygtk.label() text. check-in: 164043075d user: mario tags: trunk
07:24
Fix dbus ids, add genre to API (needs mapping perhaps), test against example patch. check-in: 61c7ecec61 user: mario tags: trunk
2015-03-27
19:33
Experimental plugin for bookmarking stations in RadioTray. (Doesn't work yet, feature request for `addRadio()` in RT.) But at least works the other way round already, displays radiotray stations in bookmarks category. check-in: d4c3eccf15 user: mario tags: trunk
Changes

Modified channels/radiotray.py from [736517c854] to [589665392e].

1
2

3
4

5
6
7
8
9
10
11
12
13
14









15
16
17



18
19

20
21
22

23
24
25
26
27
28
29
30
31
32
33
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
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
96
97
98

99
100
101
102
103
1

2
3

4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
19
20
21


22
23
24
25

26
27
28

29
30
31
32
33
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
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

96
97
98
99
100
101
102
103
104
105

106
107
108
109
110
111

-
+

-
+







-
-
-
+
+
+
+
+
+
+
+
+

-
-
+
+
+

-
+


-
+














+

















-
+











-
+





-
+






-
+








-
+









-
+





# api: dbus
# title: RadioTray interface
# title: RadioTray hook
# description: Allows to bookmark stations to RadioTray
# version: 0.1
# version: 0.2
# type: feature
# category: bookmarks
# depends: deb:python-dbus, deb:streamtuner2, deb:python-xdg
# priority: extra
# id: streamtuner2-radiotray
# pack: radiotray.py=/usr/share/streamtuner2/channels/
#
# Adds a context menu "Share in RadioTray.." to bookmark a station
# in RadioTray.  Currently just starts playing.  RT doesn't expose
# its addRadio() method yet.
# Adds a context menu "Keep in RadioTray.." to bookmark streams
# in RadioTray.  Until a newer version exposes addRadio(), this
# plugin will fall back to just playUrl().
#
# The patch for radiotray/DbusFacade.py would be:
#   +
#   +    @dbus.service.method('net.sourceforge.radiotray')
#   +    def addRadio(self, title, url, group="root"):
#   +        self.dataProvider.addRadio(title, url, group)
#
# Supposed to read RadioTrays bookmarks as well, and make them available
# in bookmarks>radiotray channel.
# Displays existing radiotray stations in ST2 bookmarks category
# as read from ~/.local/share/radiotray/bookmarks.xml. They're not
# refetched during runtime.
#
# Can be packaged up separately.
# This plugin may be packaged up separately.
#

from config import conf, __print__, dbg
from config import *
from channels import *
from mygtk import mygtk

import dbus
from xdg.BaseDirectory import xdg_data_home
from xml.etree import ElementTree


# not a channel plugin, just a category in bookmarks, and a context menu
class radiotray:

    # plugin info
    module = "radiotray"
    title = "RadioTray"
    meta = plugin_meta()
    # configuration settings
    config = [
    ]
    # bookmarks cat
    parent = None
    bm = None
    # radiotray config file / bookmarks
    rt_xml = "%s/%s/%s" % (xdg_data_home, "radiotray", "bookmarks.xml")


    # DBUS connector
    def radiotray(self):
        return dbus.Interface(
            dbus.SessionBus().get_object(
                "net.sourceforge.radiotray",
                "/net/sourceforge/radiotray"
            ),
            "net.sourceforge.radiotry"
            "net.sourceforge.radiotray"
        )


    # hook up to main tab
    def __init__(self, parent):

        # keep reference to main window    
        self.parent = parent
        self.bm = parent.channels["bookmarks"]

        # create category
        self.bm.add_category("radiotray");
        self.bm.add_category("radiotray", plugin=self);
        self.bm.streams["radiotray"] = self.update_streams(cat="radiotray")
        self.bm.reload_if_current(self.module)

        # add context menu
        if parent:
            mygtk.add_menu(parent.extensions, "Share in RadioTray", self.share)
            mygtk.add_menu(parent.extensions, "Keep in RadioTray", self.share)
        

    # load RadioTray bookmarks
    def update_streams(self, cat):
        r = []
        try:
            for group in ElementTree.parse(self.rt_xml).findall("//group"):
            for group in ElementTree.parse(self.rt_xml).findall(".//group"):
                for bookmark in group.findall("bookmark"):
                    r.append({
                        "genre": group.attrib["name"],
                        "title": bookmark.attrib["name"],
                        "url": bookmark.attrib["url"],
                        "playing": "",
                    })
        except:
            r
            pass
        return r


    # send to 
    def share(self, *w):
        row = self.parent.row()
        if row:
            # RadioTray doesn't have an addRadio method yet, so just fall back to play the stream URL
            try:
                self.radiotray().addRadio(row["title"], row["url"])
                self.radiotray().addRadio(row["title"], row["url"], row.get("genre", d="root"))
            except:
                self.radiotray().playUrl(row["url"])
        pass