Skip to content

Fixed Kodi Media Browsing#165819

Merged
joostlek merged 4 commits into
home-assistant:devfrom
albaintor:fixed_media_browsing
Apr 20, 2026
Merged

Fixed Kodi Media Browsing#165819
joostlek merged 4 commits into
home-assistant:devfrom
albaintor:fixed_media_browsing

Conversation

@albaintor
Copy link
Copy Markdown
Contributor

Proposed change

This is a fix for Kodi media browsing : the can_play flag was evaluated as a string with the previous expression instead of a boolean.
Maybe other components with browsing support have copied/paste this bug : I have found another one -> Roku

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings March 17, 2026 17:00
@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @OnFreund, mind taking a look at this pull request as it has been labeled with an integration (kodi) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of kodi can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign kodi Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes media browsing behavior in the Kodi integration by ensuring the BrowseMedia.can_play field is evaluated as a proper boolean instead of sometimes becoming a string.

Changes:

  • Adjust can_play calculation in Kodi media browsing to always produce a boolean value.

media_content_type=search_type,
title=title,
can_play=search_type in PLAYABLE_MEDIA_TYPES and search_id,
can_play=search_type in PLAYABLE_MEDIA_TYPES and search_id is not None and search_id != "",
media_content_type=search_type,
title=title,
can_play=search_type in PLAYABLE_MEDIA_TYPES and search_id,
can_play=search_type in PLAYABLE_MEDIA_TYPES and search_id is not None and search_id != "",
Copy link
Copy Markdown
Member

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Please fix the CI and make sure it's passing

@home-assistant home-assistant Bot marked this pull request as draft April 9, 2026 17:29
@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented Apr 9, 2026

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@albaintor albaintor marked this pull request as ready for review April 20, 2026 08:15
Copilot AI review requested due to automatic review settings April 20, 2026 08:15
@home-assistant home-assistant Bot requested a review from edenhaus April 20, 2026 08:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Kodi media browsing by ensuring the BrowseMedia.can_play field is evaluated as a proper boolean (instead of potentially becoming a non-bool truthy value).

Changes:

  • Update Kodi browse-media response building to compute can_play as a boolean expression.

media_content_type=search_type,
title=title,
can_play=search_type in PLAYABLE_MEDIA_TYPES and search_id,
can_play=search_type in PLAYABLE_MEDIA_TYPES and search_id is not None and search_id != "",
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

Align the PR description/checklist with the actual diff (either include the mentioned Roku fix/tests, or update the description to only reference the Kodi change).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

The CI is still failing, can you take a look?

@home-assistant home-assistant Bot marked this pull request as draft April 20, 2026 08:38
@joostlek
Copy link
Copy Markdown
Member

Euh the CI wasn't complaining about bool, it was complaining about the line wrapping

@albaintor
Copy link
Copy Markdown
Contributor Author

Euh the CI wasn't complaining about bool, it was complaining about the line wrapping

Yes I know that but I prefered to reproduce the same code as other integrations (jelly for example)

Copilot AI review requested due to automatic review settings April 20, 2026 09:10
@albaintor albaintor marked this pull request as ready for review April 20, 2026 09:10
@home-assistant home-assistant Bot requested a review from joostlek April 20, 2026 09:10
@albaintor
Copy link
Copy Markdown
Contributor Author

The CI is still failing, can you take a look?

Finally I changed the code to stick to other media browsing implementations such as jellyfin

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines 72 to +73
title=title,
can_play=search_type in PLAYABLE_MEDIA_TYPES and search_id,
can_play=bool(search_type in PLAYABLE_MEDIA_TYPES and search_id),
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

Clarify whether this PR is intentionally Kodi-only, since the same can_play=... and search_id pattern (returning a str) still exists in homeassistant/components/roku/browse_media.py and may need a separate fix/PR.

Copilot uses AI. Check for mistakes.
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.

The origin of this PR : in some situations, can_play evaluates to a string instead of a boolean. This PR prevents this by forcing the type to boolean

@joostlek joostlek merged commit 0ebf4d8 into home-assistant:dev Apr 20, 2026
36 of 37 checks passed
@joostlek joostlek added this to the 2026.4.4 milestone Apr 20, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants