コード例 #1
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 []
コード例 #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)
コード例 #3
0
 def save(self, playlist):
     playlist_id = uri.get_playlist_id(playlist.uri)
     track_ids = []
     for trk in playlist.tracks:
         track_ids.append(uri.get_song_id(trk.uri))
     result = self.subsonic_api.save_playlist_raw(playlist_id, track_ids)
     if result is None:
         return None
     return playlist
コード例 #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))
コード例 #5
0
ファイル: library.py プロジェクト: zippyy/mopidy-subidy
 def search_uri(self, query):
     type = uri.get_type(lookup_uri)
     if type == uri.ARTIST:
         artist = self.lookup_artist(uri.get_artist_id(lookup_uri))
         if artist is not None:
             return SearchResult(artists=[artist])
     elif type == uri.ALBUM:
         album = self.lookup_album(uri.get_album_id(lookup_uri))
         if album is not None:
             return SearchResult(albums=[album])
     elif type == uri.SONG:
         song = self.lookup_song(uri.get_song_id(lookup_uri))
         if song is not None:
             return SearchResult(tracks=[song])
     return None
コード例 #6
0
 def translate_uri(self, translate_uri):
     song_id = uri.get_song_id(translate_uri)
     censored_url = self.subsonic_api.get_censored_song_stream_uri(song_id)
     logger.debug("Loading song from subsonic with url: '%s'" %
                  censored_url)
     return self.subsonic_api.get_song_stream_uri(song_id)