From ea88f229a32dd2435dd661869f3d8e4ee02ec056 Mon Sep 17 00:00:00 2001
From: jjlawren <jjlawren@users.noreply.github.com>
Date: Sun, 7 Aug 2022 12:41:12 -0500
Subject: [PATCH] Bump plexapi to 4.12.1 (#76393)

---
 homeassistant/components/plex/manifest.json |  2 +-
 homeassistant/components/plex/server.py     | 34 ++++++++++-----------
 requirements_all.txt                        |  2 +-
 requirements_test_all.txt                   |  2 +-
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/homeassistant/components/plex/manifest.json b/homeassistant/components/plex/manifest.json
index 912732efe98..1875b0e05dc 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.11.2",
+    "plexapi==4.12.1",
     "plexauth==0.0.6",
     "plexwebsocket==0.0.13"
   ],
diff --git a/homeassistant/components/plex/server.py b/homeassistant/components/plex/server.py
index b136bec73e9..058e8abbecd 100644
--- a/homeassistant/components/plex/server.py
+++ b/homeassistant/components/plex/server.py
@@ -462,24 +462,24 @@ class PlexServer:
                     continue
 
                 session_username = next(iter(session.usernames), None)
-                for player in session.players:
-                    unique_id = f"{self.machine_identifier}:{player.machineIdentifier}"
-                    if unique_id not in self.active_sessions:
-                        _LOGGER.debug("Creating new Plex session: %s", session)
-                        self.active_sessions[unique_id] = PlexSession(self, session)
-                    if session_username and session_username not in monitored_users:
-                        ignored_clients.add(player.machineIdentifier)
-                        _LOGGER.debug(
-                            "Ignoring %s client owned by '%s'",
-                            player.product,
-                            session_username,
-                        )
-                        continue
+                player = session.player
+                unique_id = f"{self.machine_identifier}:{player.machineIdentifier}"
+                if unique_id not in self.active_sessions:
+                    _LOGGER.debug("Creating new Plex session: %s", session)
+                    self.active_sessions[unique_id] = PlexSession(self, session)
+                if session_username and session_username not in monitored_users:
+                    ignored_clients.add(player.machineIdentifier)
+                    _LOGGER.debug(
+                        "Ignoring %s client owned by '%s'",
+                        player.product,
+                        session_username,
+                    )
+                    continue
 
-                    process_device("session", player)
-                    available_clients[player.machineIdentifier][
-                        "session"
-                    ] = self.active_sessions[unique_id]
+                process_device("session", player)
+                available_clients[player.machineIdentifier][
+                    "session"
+                ] = self.active_sessions[unique_id]
 
         for device in devices:
             process_device("PMS", device)
diff --git a/requirements_all.txt b/requirements_all.txt
index 54606de114a..48f802fa367 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -1256,7 +1256,7 @@ pillow==9.2.0
 pizzapi==0.0.3
 
 # homeassistant.components.plex
-plexapi==4.11.2
+plexapi==4.12.1
 
 # homeassistant.components.plex
 plexauth==0.0.6
diff --git a/requirements_test_all.txt b/requirements_test_all.txt
index c3fc6b31256..1ffcf08ea57 100644
--- a/requirements_test_all.txt
+++ b/requirements_test_all.txt
@@ -874,7 +874,7 @@ pilight==0.1.1
 pillow==9.2.0
 
 # homeassistant.components.plex
-plexapi==4.11.2
+plexapi==4.12.1
 
 # homeassistant.components.plex
 plexauth==0.0.6
-- 
GitLab