diff --git a/homeassistant/components/plex/manifest.json b/homeassistant/components/plex/manifest.json index 1319e4bbf49..647590f7cf2 100644 --- a/homeassistant/components/plex/manifest.json +++ b/homeassistant/components/plex/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/plex", "requirements": [ - "plexapi==4.4.1", + "plexapi==4.5.0", "plexauth==0.0.6", "plexwebsocket==0.0.12" ], diff --git a/homeassistant/components/plex/media_browser.py b/homeassistant/components/plex/media_browser.py index cfc5a12d6c5..f3f92880c44 100644 --- a/homeassistant/components/plex/media_browser.py +++ b/homeassistant/components/plex/media_browser.py @@ -153,7 +153,7 @@ def browse_media(entity, is_internal, media_content_type=None, media_content_id= title = entity.plex_server.friendly_name elif media_content_type == "library": library_or_section = entity.plex_server.library.sectionByID( - media_content_id + int(media_content_id) ) title = library_or_section.title try: @@ -193,7 +193,7 @@ def browse_media(entity, is_internal, media_content_type=None, media_content_id= return server_payload(entity.plex_server) if media_content_type == "library": - return library_payload(media_content_id) + return library_payload(int(media_content_id)) except UnknownMediaType as err: raise BrowseError( @@ -223,7 +223,7 @@ def library_section_payload(section): return BrowseMedia( title=section.title, media_class=MEDIA_CLASS_DIRECTORY, - media_content_id=section.key, + media_content_id=str(section.key), media_content_type="library", can_play=False, can_expand=True, diff --git a/requirements_all.txt b/requirements_all.txt index 203cecd6525..67c0988bf0d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1131,7 +1131,7 @@ pillow==8.1.2 pizzapi==0.0.3 # homeassistant.components.plex -plexapi==4.4.1 +plexapi==4.5.0 # homeassistant.components.plex plexauth==0.0.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 2ce2cac591b..115f77c35dc 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -577,7 +577,7 @@ pilight==0.1.1 pillow==8.1.2 # homeassistant.components.plex -plexapi==4.4.1 +plexapi==4.5.0 # homeassistant.components.plex plexauth==0.0.6 diff --git a/tests/components/plex/conftest.py b/tests/components/plex/conftest.py index 372a06f15b6..295b560f4d1 100644 --- a/tests/components/plex/conftest.py +++ b/tests/components/plex/conftest.py @@ -108,6 +108,12 @@ def library_music_sort_fixture(): return load_fixture("plex/library_music_sort.xml") +@pytest.fixture(name="library_movies_filtertypes", scope="session") +def library_movies_filtertypes_fixture(): + """Load filtertypes payload for movie library and return it.""" + return load_fixture("plex/library_movies_filtertypes.xml") + + @pytest.fixture(name="library", scope="session") def library_fixture(): """Load library payload and return it.""" diff --git a/tests/components/plex/test_browse_media.py b/tests/components/plex/test_browse_media.py index f9966a18c27..d9f02c49341 100644 --- a/tests/components/plex/test_browse_media.py +++ b/tests/components/plex/test_browse_media.py @@ -10,7 +10,9 @@ from homeassistant.components.websocket_api.const import ERR_UNKNOWN_ERROR, TYPE from .const import DEFAULT_DATA -async def test_browse_media(hass, hass_ws_client, mock_plex_server, requests_mock): +async def test_browse_media( + hass, hass_ws_client, mock_plex_server, requests_mock, library_movies_filtertypes +): """Test getting Plex clients from plex.tv.""" websocket_client = await hass_ws_client(hass) @@ -86,6 +88,11 @@ async def test_browse_media(hass, hass_ws_client, mock_plex_server, requests_moc assert len(result["children"]) == len(mock_plex_server.library.onDeck()) # Browse into a special folder (library) + requests_mock.get( + f"{mock_plex_server.url_in_use}/library/sections/1/all?includeMeta=1", + text=library_movies_filtertypes, + ) + msg_id += 1 library_section_id = next(iter(mock_plex_server.library.sections())).key await websocket_client.send_json( @@ -127,7 +134,7 @@ async def test_browse_media(hass, hass_ws_client, mock_plex_server, requests_moc assert msg["success"] result = msg["result"] assert result[ATTR_MEDIA_CONTENT_TYPE] == "library" - result_id = result[ATTR_MEDIA_CONTENT_ID] + result_id = int(result[ATTR_MEDIA_CONTENT_ID]) assert len(result["children"]) == len( mock_plex_server.library.sectionByID(result_id).all() ) + len(SPECIAL_METHODS) diff --git a/tests/fixtures/plex/library_movies_filtertypes.xml b/tests/fixtures/plex/library_movies_filtertypes.xml new file mode 100644 index 00000000000..0f305f385c2 --- /dev/null +++ b/tests/fixtures/plex/library_movies_filtertypes.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +