Radioh / ha_twitch_helix

Home Assistant custom component to integrate with Twitch helix api.
MIT License
21 stars 2 forks source link

Live preview image url #7

Closed Endag closed 2 years ago

Endag commented 2 years ago

It would be nice if attributes when channel is online also contained "thumbnail_url" from twitch response. So you can then use it to embed not only channel icon but also actual image in for example notify events.

Sure i can format such url manually via node-red flow, but it seems to be a small effort improvement on the integration's side

Radioh commented 2 years ago

Hi! Yeah, I think the original Core component gets the Thumbnail Url when the channel is streaming and replaces the channel icon with that. I have to look into it, but I think it's possible with the Helix version of the API too.

I don't think the replacement is a good idea though, so a new attribute 'Thumbnail url' which would get a value when the channel is streaming sounds like a better approach.

Radioh commented 2 years ago

I've updated the component to return the thumbnail_url in release v.0.3.2 - https://github.com/Radioh/ha_twitch_helix/releases/tag/v.0.3.2

Radioh commented 2 years ago

I'm closing this issue. If there's any bugs with the new release a new issue can be created. :)

Endag commented 2 years ago

not a bug, but a just a minor further enhancement 300x300 image aspect makes most common 16:9 images squashed beyond any good it would be better something like 320x180, and event better to have option to configure it

Radioh commented 2 years ago

Yea, I can see the general issue. with squashed images. I'm not really sure how to approach this right now, since you would have to be able to configure it dynamically. The thumbnail might change from stream to stream. Right now it's hardcoded for all thumbnails to 300x300, which I agree might not be the best approach. I can also directly return the URL as a parameter which contains {width} {height} leaving the replacing for these parameters up to the home assistant user through some other script.

Endag commented 2 years ago

I'm not totally sure which level of template substitutions is available in yaml automations as I'm not using them. but at least hardcoding into something much common 16:9'ish would be much better, or make option in config to define custom dimensions or bypass template if nothing defined

Radioh commented 2 years ago

I had a few minutes to do a slight change. I've created a new release v0.3.3 with a new config parameter:, which can be set like so: "thumbnail_dimensions: 320x180" I've also updated the readme to illustrate it. If the parameter is not set in the config, then it will just default to the url we receive from the twitch API which contains "{width}x{height}"

NicciZar commented 9 months ago

@Radioh you could add a Blueprint to HA and your Service will use its settings as a replacement (variable) for the yaml script Using automation blueprints Creating an automation blueprint