Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plexapi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def findItems(self, data, cls=None, initpath=None, rtag=None, **kwargs):
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:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_fetch_items.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from xml.etree.ElementTree import Element

from plexapi.audio import Track
from plexapi.base import MediaContainer

Expand Down Expand Up @@ -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)