Skip to content
Merged
Changes from 4 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
14 changes: 7 additions & 7 deletions homeassistant/components/plex/media_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ def build_item_response(payload):
try:
children_media_class = ITEM_TYPE_MEDIA_CLASS[library_or_section.TYPE]
except KeyError as err:
raise BrowseError(
f"Media not found: {media_content_type} / {media_content_id}"
) from err
_LOGGER.debug("Unknown type received: %s", library_or_section.TYPE)
raise UnknownMediaType from err

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still raise BrowseError as that's what we're catch when calling this function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, ran through this too quickly. Luckily we should never receive this error unless Plex changes their API payloads.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's an impossible case we can remove it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll dig a bit more first and open a separate PR if it makes sense.

else:
raise BrowseError(
f"Media not found: {media_content_type} / {media_content_id}"
Expand Down Expand Up @@ -180,18 +179,19 @@ def item_payload(item):
def library_section_payload(section):
"""Create response payload for a single library section."""
try:
children_media_class = ITEM_TYPE_MEDIA_CLASS[section.TYPE]
media_class = ITEM_TYPE_MEDIA_CLASS[section.TYPE]
except KeyError as err:
_LOGGER.debug("Unknown type received: %s", section.TYPE)
raise UnknownMediaType from err

return BrowseMedia(
title=section.title,
media_class=MEDIA_CLASS_DIRECTORY,
media_class=media_class,
Comment thread
jjlawren marked this conversation as resolved.
Outdated
media_content_id=section.key,
media_content_type="library",
can_play=False,
can_expand=True,
children_media_class=children_media_class,
children_media_class=media_class,
)


Expand All @@ -218,9 +218,9 @@ def server_payload(plex_server):
media_content_type="server",
can_play=False,
can_expand=True,
children_media_class=MEDIA_CLASS_DIRECTORY,
)
server_info.children = []
server_info.children_media_class = MEDIA_CLASS_DIRECTORY
server_info.children.append(special_library_payload(server_info, "On Deck"))
server_info.children.append(special_library_payload(server_info, "Recently Added"))
for library in plex_server.library.sections():
Expand Down