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

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [2fd23e85be]:

To Artifact [43e8c0d215]:


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
# api: dbus
# title: RadioTray hook
# description: Allows to bookmark stations to RadioTray
# version: 0.2
# type: feature
# category: bookmarks
# depends: deb:python-dbus, deb:streamtuner2, deb:python-xdg
# config: -

# url: http://radiotray.sourceforge.net/
# priority: extra
# id: streamtuner2-radiotray
# pack: radiotray.py=/usr/share/streamtuner2/channels/
#
# 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)
#
# Displays existing radiotray stations in ST2 bookmarks category
# as read from ~/.local/share/radiotray/bookmarks.xml. They're not
# refetched during runtime.
#
# This plugin may be packaged up separately.
#

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



|



|
>





|
|
|







|
|
<






|







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
# api: dbus
# title: RadioTray hook
# description: Allows to bookmark stations to RadioTray
# version: 0.3
# type: feature
# category: bookmarks
# depends: deb:python-dbus, deb:streamtuner2, deb:python-xdg
# config:
#   { name: radiotray_map, type: select, value: 1, select: '0=root|1=group', description: 'Map genres to default RadioTray groups, or just "root".' }
# url: http://radiotray.sourceforge.net/
# priority: extra
# id: streamtuner2-radiotray
# pack: radiotray.py=/usr/share/streamtuner2/channels/
#
# Adds a context menu "Keep in RadioTray.." for bookmarking.
# 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)
#
# Displays existing radiotray stations in ST2 bookmarks
# category as read from ~/.local/share/radiotray/bookmarks.xml.

#
# This plugin may be packaged up separately.
#

from config import *
from channels import *
from uikit import uikit

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
        # create category
        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, "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"):







|







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
        # create category
        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:
            uikit.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"):
98
99
100
101
102
103
104
105
106
107
108
109














110







    # 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"], row.get("genre", d="root"))
            except:
                self.radiotray().playUrl(row["url"])
        pass





























|




>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

    # 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.map_group(row.get("genre")))
            except:
                self.radiotray().playUrl(row["url"])
        pass

    # match genre to RT groups
    def map_group(self, genre):
        if not genre or not len(genre) or not int(conf.radiotray_map) == 0:
            return "root"
        map = {
            "Jazz": "jazz|fusion|swing",
            "Pop / Rock": "top|pop|rock|metal",
            "Latin": "latin|flamenco|tango|salsa|samba",
            "Classical": "classic|baroque|opera|symphony|piano|violin",
            "Oldies": "20s|50s|60s|70s|oldie",
            "Chill": "chill|easy|listening",
            "Techno / Electronic": "techno|electro|dance|house|beat|dubstep|progressive|trance",
            "Country": "country|bluegrass|western",
            "Community": "community|talk|sports|spoken|educational",
        }
        #for str in (genre,title):
        for cat,rx in map.items():
            if re.match(rx, genre, re.I):
                return cat
        return "root"