@@ -99,41 +99,17 @@ } self.record = { "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 + # Presets are redundant now. On first startup the `priority:` field of each plugin is checked. self.plugins = { # core plugins, cannot be disabled anyway "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, - "live365": 0, - "radiotray": 0, - "timer": 0, - "history": 0, - "global_key": 0, - "useragentswitcher": 0, - # obsolete / removed - "file": 0, - "punkcast": 0, - "basicch": 0, - "tv": 0, } self.tmp = os.environ.get("TEMP", "/tmp") self.max_streams = "500" self.show_bookmarks = 1 self.show_favicons = 1 @@ -157,11 +133,12 @@ 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") + conf.plugins[module] = meta.get("priority") in ("core", "builtin", "always", "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"], @@ -171,10 +148,11 @@ } 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")) @@ -244,10 +222,11 @@ if type(value) == dict: self[key].update(value) else: self[key] = value # descends into sub-dicts instead of wiping them with subkeys + # update old setting names def migrate(self): # 2.1.1 if "audio/mp3" in self.play: @@ -258,10 +237,11 @@ # check for existing filename in directory list def find_in_dirs(self, dirs, file): for d in dirs: if os.path.exists(d+"/"+file): return d+"/"+file + # standard user account storage in ~/.netrc or less standard but contemporarily in ~/.config/netrc def netrc(self, varhosts=("shoutcast.com")): global netrc if not netrc: @@ -280,13 +260,13 @@ # Retrieve content from install path or pyzip archive (alias for pkgutil.get_data) # -def get_data(fn, decode=False, z=False): +def get_data(fn, decode=False, z=False, file_base="config"): try: - bin = pkgutil.get_data("config", fn) + bin = pkgutil.get_data(file_base, fn) if z: bin = zlib.decompress(bin) if decode: return bin.decode("utf-8") else: @@ -296,14 +276,14 @@ # Search through ./channels/ and get module basenames. # (Reordering channel tabs is now done by uikit.apply_state.) # -def module_list(): +def module_list(plugin_base="channels"): # Should list plugins within zips as well as local paths - ls = pkgutil.iter_modules([conf.share+"/channels", "channels"]) + ls = pkgutil.iter_modules([plugin_base, conf.share+"/"+plugin_base, conf.dir+"/plugins"]) return [name for loader,name,ispkg in ls] # Plugin meta data extraction @@ -313,16 +293,16 @@ # · fn= to read from literal files, out of a .pyzip package # · src= to extract from pre-read script code # · module= utilizes pkgutil to read # · frame= automatically extract comment header from caller # -def plugin_meta(fn=None, src=None, module=None, frame=1): +def plugin_meta(fn=None, src=None, module=None, frame=1, plugin_base="channels"): # try via pkgutil first if module: fn = module - src = pkgutil.get_data("channels", fn+".py") + src = pkgutil.get_data(plugin_base, fn+".py") # get source directly from caller elif not src and not fn: module = inspect.getmodule(sys._getframe(frame)) fn = inspect.getsourcefile(module)