--- /dev/null
+
+import os.path
+from lightmediascanner import LightMediaScanner
+
+from brisa.core.plugin import PluginInterface
+from brisa.core.config import manager as mgr
+from brisa.core import webserver
+
+plugin_section = "zukebox_server_plugin-audio-library"
+class ZAudioLibrary(PluginInterface):
+ """Audio Library enables sharing of locally stored audios
+
+ """
+ name = "audio_library"
+ usage = mgr.get_parameter_bool(plugin_section, "enable")
+ db_path = mgr.get_parameter(plugin_section, "database_location")
+ lms = None
+ audio_types = ["audio-dummy", "id3", "ogg", "pls", "m3u", "rm", "asf", "flac"]
+ containers = {}
+
+ def load(self):
+ self._load_config()
+ self._load_scanner()
+ self._load_audio()
+
+ def publish(self, webserver):
+ webserver.add_resource(self.name, AudioLibraryResource())
+
+ def _load_config(self):
+ self.audio_folder = mgr.get_parameter(plugin_section, "audio_folder")
+ self.already_scanned = mgr.get_parameter_bool(plugin_section, ".scanned")
+ if not self.already_scanned:
+ mgr.set_parameter(plugin_section, ".scanned", True)
+ mgr.save()
+
+ def _load_scanner(self):
+ self.lms = LightMediaScanner(self.db_path)
+ for type in self.audio_types:
+ self.lms.parser_find_and_add(type)
+
+ def _load_audio(self):
+ rp = self.plugin_manager.root_plugin
+ audio_container = rp.get_container("Audio")
+ if not audio_container:
+ audio_container = rp.add_container("Audio", 0)
+
+ self.all_container = rp.add_container("All Audios",
+ audio_container.id, self)
+ self.containers[self.all_container.id] = self.all_container
+
+ def process_audio_folder(self):
+ for folder in self.audio_folders:
+ self.lms.process(folder)
+
+
+class AudioLibraryResource(webserver.CustomResource):
+ def get_render(self, uri, request):
+ id = uri.split("/")[-1].split("-")[1]
+ #path =
+ return webserver.Data("", "")