Add config flow to media extractor (#32590)

* Add config flow to media extractor

* Update source/_integrations/media_extractor.markdown

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>

* Update source/_integrations/media_extractor.markdown

* Update source/_integrations/media_extractor.markdown

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
Joost Lekkerkerker 2024-06-04 06:01:54 +02:00 committed by Franck Nijhof
parent 7b92fb539d
commit 2b3161535b
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -16,61 +16,15 @@ related:
ha_config_flow: true
---
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 %}
{% include integrations/config_flow.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
```
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.
@ -91,6 +45,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
- **bestaudio[ext=m4a]**: Best audio stream in M4A format
- **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).
### 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.