Exemplo n.º 1
0
 def browse(self, browse_uri):
     if browse_uri == uri.get_vdir_uri('root'):
         root_vdir_names = ["rootdirs", "artists", "albums"]
         root_vdirs = [
             self._vdirs[vdir_name] for vdir_name in root_vdir_names
         ]
         sorted_root_vdirs = sorted(root_vdirs,
                                    key=lambda vdir: vdir["name"])
         return [self._raw_vdir_to_ref(vdir) for vdir in sorted_root_vdirs]
     elif browse_uri == uri.get_vdir_uri("rootdirs"):
         return self.browse_rootdirs()
     elif browse_uri == uri.get_vdir_uri("artists"):
         return self.browse_artists()
     elif browse_uri == uri.get_vdir_uri("albums"):
         return self.browse_albums()
     else:
         uri_type = uri.get_type(browse_uri)
         if uri_type == uri.DIRECTORY:
             return self.browse_diritems(uri.get_directory_id(browse_uri))
         elif uri_type == uri.ARTIST:
             return self.browse_albums(uri.get_artist_id(browse_uri))
         elif uri_type == uri.ALBUM:
             return self.browse_songs(uri.get_album_id(browse_uri))
         else:
             return []
Exemplo n.º 2
0
 def __create_vdirs():
     vdir_templates = [
         dict(id="root", name="Subsonic"),
         dict(id="artists", name="Artists"),
         dict(id="albums", name="Albums"),
         dict(id="rootdirs", name="Directories"),
     ]
     # Create a dict with the keys being the `id`s in `vdir_templates`
     # and the values being objects containing the vdir `id`,
     # the human readable name as `name`, and the URI as `uri`.
     vdirs = {}
     for template in vdir_templates:
         vdir = template.copy()
         vdir.update(uri=uri.get_vdir_uri(vdir["id"]))
         vdirs[template['id']] = vdir
     return vdirs