Example #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 []
Example #2
0
 def search_uri_iter(self, lookup_uri, include_self=True):
     type = uri.get_type(lookup_uri)
     if type == uri.ARTIST:
         artistid = uri.get_artist_id(lookup_uri)
         artist = self.subsonic_api.get_artist_by_id(artistid)
         if artist is not None:
             if include_self:
                 yield (uri.ARTIST, artist)
             for i in self.subsonic_api.get_albums_as_albums(artistid):
                 yield (uri.ALBUM, i)
             for i in self.subsonic_api.get_artist_as_songs_as_tracks_iter(
                     artistid):
                 yield (uri.SONG, i)
     elif type == uri.ALBUM:
         albumid = uri.get_album_id(lookup_uri)
         album = self.subsonic_api.get_album_by_id(albumid)
         if album is not None:
             if include_self:
                 yield (uri.ALBUM, album)
             for i in self.lookup_album(albumid):
                 yield (uri.SONG, i)
     elif type == uri.DIRECTORY:
         for i in self.lookup_directory(uri.get_directory_id(lookup_uri)):
             yield (uri.SONG, i)
     elif type == uri.SONG:
         if include_self:
             song = self.subsonic_api.get_song_by_id(
                 uri.get_song_id(lookup_uri))
             if song:
                 yield (uri.SONG, song)
Example #3
0
 def get_coverart_image(self, a_uri):
     utype = uri.get_type(a_uri)
     if utype == uri.ARTIST:
         coverart_item_id = self.subsonic_api.coverart_item_id_by_artist_id(
             uri.get_artist_id(a_uri))
     elif utype == uri.ALBUM:
         coverart_item_id = self.subsonic_api.coverart_item_id_by_album_id(
             uri.get_album_id(a_uri))
     elif utype == uri.SONG:
         coverart_item_id = self.subsonic_api.coverart_item_id_by_song_id(
             uri.get_song_id(a_uri))
     elif utype == uri.DIRECTORY:
         coverart_item_id = self.subsonic_api.coverart_item_id_by_directory_id(
             uri.get_directory_id(a_uri))
     else:
         return []
     if coverart_item_id is not None:
         image_uri = self.subsonic_api.get_coverart_image_by_id(
             coverart_item_id)
         if image_uri is not None:
             return [image_uri]
         else:
             return []
     else:
         return []
Example #4
0
 def lookup_one(self, lookup_uri):
     type = uri.get_type(lookup_uri)
     if type == uri.ARTIST:
         return self.lookup_artist(uri.get_artist_id(lookup_uri))
     if type == uri.ALBUM:
         return self.lookup_album(uri.get_album_id(lookup_uri))
     if type == uri.DIRECTORY:
         return self.lookup_directory(uri.get_directory_id(lookup_uri))
     if type == uri.SONG:
         return self.lookup_song(uri.get_song_id(lookup_uri))
     if type == uri.PLAYLIST:
         return self.lookup_playlist(uri.get_playlist_id(lookup_uri))