Ensure that we only connect to servers in the Plex provider (#650)
authormicha91 <michael.harbarth@gmx.de>
Mon, 8 May 2023 20:07:25 +0000 (22:07 +0200)
committerGitHub <noreply@github.com>
Mon, 8 May 2023 20:07:25 +0000 (22:07 +0200)
* Ensure that we only connect to servers

* Update music_assistant/server/providers/plex/helpers.py

Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com>
* minor fix

---------

Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com>
music_assistant/server/providers/plex/helpers.py

index 15461d957b88e2a310aefddd83a329220395b08b..87f514a2236aef5f6bbcdb60f29777bd5d0d7064 100644 (file)
@@ -26,9 +26,11 @@ async def get_libraries(mass: MusicAssistant, auth_token: str) -> set[str]:
         # create a listing of available music libraries on all servers
         all_libraries: list[str] = []
         plex_account = MyPlexAccount(token=auth_token)
-        for server_resource in plex_account.resources():
+        for resource in plex_account.resources():
+            if "server" not in resource.provides:
+                continue
             try:
-                plex_server: PlexServer = server_resource.connect(None, 10)
+                plex_server: PlexServer = resource.connect(None, 10)
             except plexapi.exceptions.NotFound:
                 continue
             for media_section in plex_server.library.sections():
@@ -36,7 +38,7 @@ async def get_libraries(mass: MusicAssistant, auth_token: str) -> set[str]:
                 if media_section.type != PlexMusicSection.TYPE:
                     continue
                 # TODO: figure out what plex uses as stable id and use that instead of names
-                all_libraries.append(f"{server_resource.name} / {media_section.title}")
+                all_libraries.append(f"{resource.name} / {media_section.title}")
         return all_libraries
 
     if cache := await mass.cache.get(cache_key, checksum=auth_token):