From 921356099e13412cd199a02ed2c213f43a1e9287 Mon Sep 17 00:00:00 2001 From: blacktwin Date: Tue, 26 Oct 2021 17:47:34 -0400 Subject: [PATCH] create isBrowseable method in server.PlexServer --- plexapi/server.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plexapi/server.py b/plexapi/server.py index c31c9a69..d429427b 100644 --- a/plexapi/server.py +++ b/plexapi/server.py @@ -3,6 +3,7 @@ from urllib.parse import urlencode from xml.etree import ElementTree import requests +import os from plexapi import (BASE_HEADERS, CONFIG, TIMEOUT, X_PLEX_CONTAINER_SIZE, log, logfilter) from plexapi import utils @@ -384,6 +385,18 @@ class PlexServer(PlexObject): for path, paths, files in self.walk(_path): yield path, paths, files + def isBrowsable(self, path): + """ Returns True if the Plex server can browse the given path. + + Parameters: + path (:class:`~plexapi.library.Path` or str): Full path to browse. + """ + if isinstance(path, Path): + path = path.path + path = os.path.normpath(path) + paths = [p.path for p in self.browse(os.path.dirname(path), includeFiles=False)] + return path in paths + def clients(self): """ Returns list of all :class:`~plexapi.client.PlexClient` objects connected to server. """ items = []