Added the method for browse in containers
authorAndre L. V. Loureiro <loureiro.andrew@gmail.com>
Wed, 20 May 2009 02:43:37 +0000 (22:43 -0400)
committerHenry Bilby <henrymiller.engenheiro@gmail.com>
Sat, 23 May 2009 01:19:49 +0000 (21:19 -0400)
zukebox_server/src/plugins/audio_library/library.py

index db2a2c1..5dd9870 100644 (file)
@@ -17,6 +17,7 @@ class ZAudioLibrary(PluginInterface):
     lms = None
     audio_types = ["audio-dummy", "id3", "ogg", "pls", "m3u", "rm", "asf", "flac"]
     containers = {}
+    containers_cb = {}
 
     def load(self):
         self._load_config()
@@ -34,9 +35,10 @@ class ZAudioLibrary(PluginInterface):
             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)
+        self.lms = LightMediaScanner(self.db_path, self.audio_types, "utf8",
+                3, 3)
+        self.lms.check(self.audio_folder)
+        self.lms.process(self.audio_folder)
 
     def _load_audio(self):
         rp = self.plugin_manager.root_plugin
@@ -49,9 +51,17 @@ class ZAudioLibrary(PluginInterface):
         self.containers[self.all_container.id] = self.all_container
 
     def process_audio_folder(self):
-        for folder in self.audio_folders:
-            self.lms.process(folder)
+        self.lms.process(self.audio_folder)
 
+    def check_audio_folder(self):
+        self.lms.check(self.audio_folder)
+
+    def browse(self,id, browse_flag, filter, starting_index, requested_count, sort_criteria):
+        if id in self.containers:
+            if not self.containers[id].items:
+                # add the items from callback
+                self.containers[id].items = self.containers_cb[id]()
+            return self.containers[id].items
 
 class AudioLibraryResource(webserver.CustomResource):
     def get_render(self, uri, request):