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

⌈⌋ branch:  streamtuner2


Diff

Differences From Artifact [43829d8ff1]:

To Artifact [31dd5cfc2a]:


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
112










113
114
115


116
117
118
119
120
121
122
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
112
113
114
115
116
117
118
119
120
121



122
123
124
125
126
127
128
129
130
131



132
133
134
135
136
137
138
139
140







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


-
-
+
+

+

+
-
+



+


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






            self.save("settings")
            self.firstrun = 1


    # some defaults
    def defaults(self):
        self.play = {
           "audio/mpeg": "audacious ",	# %u for url to .pls, %g for downloaded .m3u
           "audio/ogg": "audacious ",
           "audio/*": "audacious ",
           "video/youtube": "totem $(youtube-dl -g %srv)",
           "video/*": "vlc --one-instance %srv",
           "url/http": "sensible-browser",
           "audio/mpeg": self.find_player(),
           "audio/ogg": self.find_player(),
           "audio/*": self.find_player(),
           "video/youtube": self.find_player(typ="video") + " $(youtube-dl -g %srv)",
           "video/*": self.find_player(typ="video", default="vlc"),
           "url/http": self.find_player(typ="browser"),
        }
        self.record = {
           "audio/*": "xterm -e streamripper %srv",   # -d /home/***USERNAME***/Musik
           "video/youtube": "xterm -e \"youtube-dl %srv\"",
           "audio/*": self.find_player(typ="xterm") + " -e streamripper %srv",   # -d /home/***USERNAME***/Musik
           "video/youtube": self.find_player(typ="xterm") + " -e \"youtube-dl %srv\"",
        }
        # these presets are a temporary workaround, until `priority:` is checked before module loading
        self.plugins = {
             # core plugins, cannot be disabled anyway
            "bookmarks": 1, # built-in plugin, cannot be disabled
            "bookmarks": 1,
            "search": 1,
            "streamedit": 1,
            "configwin": 1,
            # standard channels
            "shoutcast": 1,
            "xiph": 1,
            "myoggradio": 1,
            "internet_radio": 1,
            "surfmusik": 1,
            "jamendo": 1,
            "icast": 1,
            "itunes": 1,
            # disabled per default
            "radiobrowser": 0,
            "youtube": 0,
            "modarchive": 0, # disable per default
            "file": 0,      # disable per default
            "punkcast": 0,  # disable per default
            "modarchive": 0,
            "live365": 0,
            "radiotray": 0,
            "timer": 0,
            "history": 0,
            "global_key": 0,
            "useragentswitcher": 0,
            # obsolete / removed
            "file": 0,
            "punkcast": 0,
            "history": 0,
            "basicch": 0,   # ceased
            "tv": 0,        # ceased
            "basicch": 0,
            "tv": 0,
        }
        self.tmp = os.environ.get("TEMP", "/tmp")
        self.max_streams = "500"
        self.show_bookmarks = 1
        self.show_favicons = 1
        self.load_favicon = 1
        self.heuristic_bookmark_update = 0
140
141
142
143
144
145
146







147





148
149
150
151
152
153
154
158
159
160
161
162
163
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
179
180
181
182
183







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






            if ("name" in opt) and ("value" in opt) and (opt["name"] not in vars(self)):
                self.__dict__[opt["name"]] = opt["value"]

        # plugin state
        if module and module not in conf.plugins:
             conf.plugins[module] = meta.get("priority") in ("core", "builtin", "default", "standard")

    # look at system binaries for standard audio players
    def find_player(self, typ="audio", default="xdg-open"):
        players = {
           "audio": ["audacious %g", "audacious2", "exaile %p", "xmms2", "banshee", "amarok %g", "clementine", "qmmp", "quodlibet", "aqualung", "mp3blaster %g", "vlc --one-instance %srv", "totem"],
           "video": ["parole", "umplayer", "xnoise", "gxine", "totem", "vlc --one-instance", "smplayer", "gnome-media-player", "xine", "bangarang"],
           "browser": ["opera", "midori", "sensible-browser"],
           "xterm": ["xfce4-terminal", "x-termina-emulator", "gnome-terminal", "xterm", "rxvt"],
    
        }
        for bin in players[typ]:
            if find_executable(bin.split()[0]):
                return bin
        return default
        
    # http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
    def xdg(self, path="/streamtuner2"):
        home = os.environ.get("HOME", self.tmp)
        config = os.environ.get("XDG_CONFIG_HOME", os.environ.get("APPDATA", home+"/.config"))
        
        # storage dir
270
271
272
273
274
275
276
277
278


279
280
281
282
283
284
285
299
300
301
302
303
304
305


306
307
308
309
310
311
312
313
314







-
-
+
+






#
def module_list():

    # Should list plugins within zips as well as local paths
    ls = pkgutil.iter_modules([conf.share+"/channels", "channels"])
    ls = [name for loader,name,ispkg in ls]
    
    # resort with tab order
    order = [module.strip() for module in conf.channel_order.lower().replace(".","_").replace("-","_").split(",")]
    # resort according to configured channel tab order
    order = re.findall("\w+", conf.channel_order.lower())
    ls = [module for module in (order) if (module in ls)] + [module for module in (ls) if (module not in order)]

    return ls



# Plugin meta data extraction