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

Media Source implementation for Chromecast #39305

Merged
merged 19 commits into from
Sep 4, 2020

Conversation

hunterjm
Copy link
Member

@hunterjm hunterjm commented Aug 27, 2020

Proposed change

This PR implements a relatively simple new integration that exposes media files found in allowlist_external_dirs with a media browser compatible API through a new /media view behind auth. It also creates a new websocket for media_finder/browse_media which along with auth/sign_path will allow for a lovelace card to be developed to play local media files in the browser. The name for the integration is still up in the air, so feel free to vote for one.

Here I also implement Media Browser for the cast integration since Chromecast allows playing of arbitrary URLs. To pass auth, we sign the path with the Home Assistant Cast user with a 5 minute expiration.

cast_local_media

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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

media_finder:

or

default_config:

Additional information

Checklist

  • 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
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@balloob balloob changed the title Media Browser implementation for Chromecast Media Source implementation for Chromecast Aug 29, 2020
@hunterjm hunterjm force-pushed the cast-media-browser branch from a44dcca to 47fb16e Compare August 30, 2020 00:44
hass_url = get_url(self.hass, prefer_external=True)
media_id = f"{hass_url}{media_id}"

await self.hass.async_add_job(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
await self.hass.async_add_job(
await self.hass.async_add_executor_job(

Copy link
Member

Choose a reason for hiding this comment

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

This wasn't addressed.

Copy link
Member Author

@hunterjm hunterjm Sep 5, 2020

Choose a reason for hiding this comment

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

Sorry, I thought Paulus addressed it in his followup commits. Either way, this is exactly what the parent does.
https://github.com/home-assistant/core/blob/dev/homeassistant/components/media_player/__init__.py#L600-L604

I can add a follow-up PR to change it there and simply call super in this class if you would like.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please. 👍

@hunterjm hunterjm marked this pull request as ready for review September 4, 2020 05:00
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
@hunterjm hunterjm merged commit f2b3e63 into home-assistant:dev Sep 4, 2020
@hunterjm hunterjm deleted the cast-media-browser branch September 4, 2020 15:16
@hunterjm hunterjm added the WTH Issues & PRs generated from the "Month of What the Heck?" label Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants