Open krin-san opened 8 months ago
Found a quick workaround: store librarySectionID
value before reload()
and restore it after:
librarySectionID = album.librarySectionID
album.reload()
album.librarySectionID = librarySectionID
I can't reproduce the issue.
>>> from plexapi.server import PlexServer
>>> plex = PlexServer()
>>> album = plex.library.section("Music").searchAlbums(limit=1)[0]
>>> album.section()
<MusicSection:11:Music>
>>> album.reload()
<Album:651:Layers>
>>> album.section()
<MusicSection:11:Music>
>>> plex.version
'1.40.1.8120-6dc7f7fd8'
>>> import plexapi
>>> plexapi.__version__
'4.15.10'
Then what's the difference? I don't think that Plex version difference alone causes it. I repeated the same test in Python shell on both Jupyter container and on MacOS to exclude environment differences.
>>> from plexapi.server import PlexServer
>>> plex = PlexServer('http://x.x.x.x:32400', ...)
>>> album = plex.library.section("Music").searchAlbums(limit=1)[0]
>>> album.section()
<MusicSection:6:Music>
>>> album.reload()
<Album:110968>
>>> album.section()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/lib/python3.11/site-packages/plexapi/base.py", line 670, in section
return self._server.library.sectionByID(self.librarySectionID)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/plexapi/library.py", line 111, in sectionByID
raise NotFound(f'Invalid library sectionID: {sectionID}') from None
plexapi.exceptions.NotFound: Invalid library sectionID: None
>>> plex.version
'1.40.0.7998-c29d4c0c8'
>>> import plexapi
>>> plexapi.__version__
'4.15.10'
I honestly don't know.
But it looks like your album doesn't have a title <Album:110968>
. Maybe that's a clue?
No, it's not. It's one of Various Artists
albums with incorrect tags. Issue is still reproducible if I randomize search result with .searchAlbums(limit=1, sort='random')
and run multiple times.
Describe the Bug
For some reason explicitly calling reload() on PlexPartialObject causes this object to lose
librarySectionID
value which causes any data editing attempts to fail with exception "Invalid library sectionID: None".I have tried to compare Music Album genres for all albums to a local list, but
.search()
was loading only 2 genres for each album. To get the full list of genres, album has to be reloaded but after reloading it is not editable.Code Snippets
Expected Behavior
Reloading an object shouldn't cause it to lose the connection to the library section it was found in and should remain editable.
Additional Context
Example stack trace:
Operating System and Version
docker.io/jupyter/minimal-notebook@sha256:9aef9e53b7d8bdc7bdd9a2824fe6287081131bc02bf03edc1450ab9413646837
Plex Media Server Version
1.40.0.7998
Python Version
3.11.6
PlexAPI Version
4.15.10