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

Add config flow to media extractor #32590

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Changes from 3 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
65 changes: 16 additions & 49 deletions source/_integrations/media_extractor.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,15 @@ related:
title: Configuration file
---

The `media_extractor` {% term integration %} gets a stream URL and sends it to a media player entity. This integration can extract entity specific streams if configured accordingly.
The Media extractor {% term integration %} gets a stream URL and sends it to a media player entity. This integration can extract entity specific streams if configured accordingly.

<div class='note'>
Media extractor doesn't transcode streams, it just tries to find a stream that matches the requested query.
</div>

To use the media extractor service in your installation, add the following to your {% term "`configuration.yaml`" %} file.
{% include integrations/restart_ha_after_config_inclusion.md %}

```yaml
# Example configuration.yaml entry
media_extractor:
```

{% configuration %}
default_query:
description: Set default stream query for all devices.
required: false
default: best
type: string
customize:
description: Set entity specific values.
required: false
type: list
{% endconfiguration %}

```yaml
# Example configuration.yaml entry
media_extractor:
default_query: worst
customize:
media_player.my_sonos:
video: bestvideo
music: bestaudio[ext=mp3]
```

This configuration sets query for all service calls like to 'bestaudio' with the mp3 extension:

```yaml
entity_id: media_player.my_sonos
media_content_id: https://soundcloud.com/bruttoband/brutto-11
media_content_type: music
```
{% include integrations/config_flow.md %}

Query examples with explanations:

- **bestvideo**: Best video only stream
- **best**: Best video + audio stream
- **bestaudio[ext=m4a]**: Best audio stream with m4a extension
- **worst**: Worst video + audio stream
- **bestaudio[ext=m4a]/bestaudio[ext=ogg]/bestaudio**: Best m4a audio, otherwise best ogg audio and only then any best audio

More info about queries can be found [here](https://github.com/ytdl-org/youtube-dl#format-selection).

### Use the service
### Play media service

Navigate to the **Services** tab inside **Developer Tools**. From the "Service" dropdown menu select `media_extractor.play_media` and then press the "Fill Example Data" button at the bottom of the page. Use the "Entity ID" dropdown to select your media player and then press the **Call Service** button.

Expand All @@ -90,6 +44,19 @@ There is also a service that will directly return the URL in the response of the
| `url` | no | The URL of the media to extract. |
| `format_query` | yes | The query that will be used to select the right media. |

### Format query

The query can be used to select the right media.
Query examples with explanations:

- **bestvideo**: Best video-only stream
- **best**: Best video + audio stream
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by best? High resolution?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so yes

Copy link
Contributor

Choose a reason for hiding this comment

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

out of scope for this PR I guess.

- **bestaudio[ext=m4a]**: Best audio stream with m4a extension
- **worst**: Worst video + audio stream
- **bestaudio[ext=m4a]/bestaudio[ext=ogg]/bestaudio**: Best m4a audio, otherwise best ogg audio and only then any best audio
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean OGG file format?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so yes


More info about queries can be found [here](https://github.com/ytdl-org/youtube-dl#format-selection).

### Cookies

Some supported video services provide a better experience when you are logged in. For example, if you use Twitch Turbo or are subscribed to a Twitch streamer, logging in prevents the video stream from showing an "An ad is currently playing. Come back after the break." message until the ad is over. Other examples are private or purchased YouTube videos which you can only watch while logged in.
Expand Down