Fix: Bug introduced in #1373 list has not attr tag (#1396)

* regression test for https://github.com/Taxel/PlexTraktSync/discussions/1901

* bugfix https://github.com/Taxel/PlexTraktSync/discussions/1901
This commit is contained in:
Dr.Blank 2024-04-19 15:42:16 -04:00 committed by GitHub
parent 0108c95bd8
commit 25fa930c61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -347,7 +347,7 @@ class PlexObject:
kwargs['type'] = cls.TYPE
# rtag to iter on a specific root tag using breadth-first search
if rtag:
data = next(utils.iterXMLBFS(data, rtag), [])
data = next(utils.iterXMLBFS(data, rtag), Element('Empty'))
# loop through all data elements to find matches
items = MediaContainer[cls](self._server, data, initpath=initpath) if data.tag == 'MediaContainer' else []
for elem in data:

View file

@ -1,3 +1,5 @@
from xml.etree.ElementTree import Element
from plexapi.audio import Track
from plexapi.base import MediaContainer
@ -30,3 +32,10 @@ def test_fetch_items_with_media_container(show):
assert some_episodes.size == 2
assert some_episodes.offset == 0
assert some_episodes.totalSize == len(all_episodes)
def test_find_items_empty_data(plex):
result = plex.findItems(Element(""), rtag="foo")
assert len(result) == 0
result = plex.findItems(Element("MediaContainer"))
assert isinstance(result, MediaContainer)