Skip to content

Commit af80c26

Browse files
committed
Clear library cache and try retrieving library again
1 parent 063c7ef commit af80c26

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

plexapi/library.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ def section(self, title):
9696
try:
9797
sections = self._sectionsByTitle[normalized_title]
9898
except KeyError:
99-
raise NotFound(f'Invalid library section: {title}') from None
99+
# Invalidate cached libraries and try again
100+
self._invalidateCachedProperties()
101+
try:
102+
sections = self._sectionsByTitle[normalized_title]
103+
except KeyError:
104+
raise NotFound(f'Invalid library section: {title}') from None
100105

101106
if len(sections) > 1:
102107
warnings.warn(
@@ -117,7 +122,12 @@ def sectionByID(self, sectionID):
117122
try:
118123
return self._sectionsByID[sectionID]
119124
except KeyError:
120-
raise NotFound(f'Invalid library sectionID: {sectionID}') from None
125+
# Invalidate cached libraries and try again
126+
self._invalidateCachedProperties()
127+
try:
128+
return self._sectionsByID[sectionID]
129+
except KeyError:
130+
raise NotFound(f'Invalid library sectionID: {sectionID}') from None
121131

122132
def hubs(self, sectionID=None, identifier=None, **kwargs):
123133
""" Returns a list of :class:`~plexapi.library.Hub` across all library sections.

0 commit comments

Comments
 (0)