Exemple #1
0
 def search(self, query, include_media_types=[]):
     """
     Searches Emby from a given query
     :param query:
     :param include_media_types:
     :return:
     """
     response = self.client.search(query, include_media_types)
     search_items = EmbyCroft.parse_search_hints_from_response(response)
     return EmbyMediaItem.from_list(search_items)
Exemple #2
0
 def test_songs_by_playlist(self):
     playlist = 'Xmas Music'
     client = EmbyClient(HOST, USERNAME, PASSWORD)
     response = client.search(playlist, [MediaItemType.PLAYLIST.value])
     search_items = EmbyCroft.parse_search_hints_from_response(response)
     playlists = EmbyMediaItem.from_list(search_items)
     assert len(playlists) == 1
     playlist_id = playlists[0].id
     songs = client.get_songs_by_playlist(playlist_id)
     assert songs is not None
 def test_songs_by_album(self):
     album = 'deadweight'
     client = EmbyClient(HOST, USERNAME, PASSWORD)
     response = client.search(album, [MediaItemType.ALBUM.value])
     search_items = EmbyCroft.parse_search_hints_from_response(response)
     albums = EmbyMediaItem.from_list(search_items)
     assert len(albums) == 1
     album_id = albums[0].id
     songs = client.get_songs_by_album(album_id)
     assert songs is not None
     for song in songs.json()['Items']:
         assert album == song['Album'].lower()
 def test_songs_by_artist(self):
     artist = 'slaves'
     client = EmbyClient(HOST, USERNAME, PASSWORD)
     response = client.search(artist, [MediaItemType.ARTIST.value])
     search_items = EmbyCroft.parse_search_hints_from_response(response)
     artists = EmbyMediaItem.from_list(search_items)
     assert len(artists) == 1
     artist_id = artists[0].id
     songs = client.get_songs_by_artist(artist_id)
     assert songs is not None
     for song in songs.json()['Items']:
         assert artist in [a.lower() for a in song['Artists']]
Exemple #5
0
    def get_instant_mix_songs(self, item_id):
        """
        Requests an instant mix from an Emby item id
        and returns song uris to be played by the Audio Service
        :param item_id:
        :return:
        """
        response = self.client.instant_mix(item_id)
        queue_items = EmbyMediaItem.from_list(
            EmbyCroft.parse_response(response))

        song_uris = []
        for item in queue_items:
            song_uris.append(self.client.get_song_file(item.id))
        return song_uris
Exemple #6
0
 def convert_response_to_playable_songs(self, item_query_response):
     queue_items = EmbyMediaItem.from_list(
         EmbyCroft.parse_response(item_query_response))
     return self.convert_to_playable_songs(queue_items)