External app name + icon metadata#60
Conversation
… use the new app names if not found in override, adding google_play_scraper to requirements.txt
… cache to work each time
…storing correctly but not able to use it in tv.py yet
5d6bb15 to
35a4f0d
Compare
…more logic update to tv.py
|
@zehnm Finished the feature off (updating title metadata). All working as expected. Can you take a look? Maybe we can push this to prod first before the app icons? |
zehnm
left a comment
There was a problem hiding this comment.
Image fetching doesn't work, likely because the PIL package is missing.
Interesting indeed, which app were you using ? The media artwork is a new feature from the last PR.
So basically you should make a dynamic media_artwork property and do like media_title algorithm : send the new value only when it is different from the old value. |
|
This simple logic might work, but I couldn't find an app yet that provides Cast media images. Diff against 61d412a
diff --git a/intg-androidtv/tv.py b/intg-androidtv/tv.py
index a55315a..af818ac 100644
--- a/intg-androidtv/tv.py
+++ b/intg-androidtv/tv.py
@@ -237,6 +237,8 @@ class AndroidTv(CastStatusListener, MediaStatusListener, ConnectionStatusListene
self._last_update_position_time: float = 0
self._media_type = METADATA_TYPE_MOVIE
self._media_image_url: str | None = None
+ self._app_image_url: str = ""
+ self._use_app_url = not device_config.use_chromecast
self._player_state = media_player.States.ON
self._muted = False
@@ -651,7 +653,9 @@ class AndroidTv(CastStatusListener, MediaStatusListener, ConnectionStatusListene
update[MediaAttr.SOURCE] = metadata.get("name")
if metadata.get("icon"):
- update["media_image_url"] = metadata.get("icon")
+ self._app_image_url = metadata.get("icon")
+ if self._use_app_url:
+ update[MediaAttr.MEDIA_IMAGE_URL] = self._app_image_url
except Exception as e:
_LOG.warning("[%s] Failed to get external metadata: %s", self.log_id, e)
@@ -887,11 +891,17 @@ class AndroidTv(CastStatusListener, MediaStatusListener, ConnectionStatusListene
and len(status.images) > 0
and status.images[0] != self._media_image_url
):
- self._media_image_url = status.images[0]
+ self._media_image_url = status.images[0].url
update[MediaAttr.MEDIA_IMAGE_URL] = self._media_image_url
+ # prevent media image being overwritten with app icon
+ self._use_app_url = False
elif self._media_image_url:
self._media_image_url = None
- update[MediaAttr.MEDIA_IMAGE_URL] = ""
+
+ if not self._media_image_url:
+ # safe to use media image for app icon
+ self._use_app_url = True
+ update[MediaAttr.MEDIA_IMAGE_URL] = self._app_image_url
if update:
_LOG.debug( |
|
One more fix required in the Cast implementation: |
Avoid spamming the log with base64 data.
Correctly set the media_image_url from Cast. Needs to be reverted for PR #60
Correctly set the media_image_url from Cast. Needs to be reverted for PR #60
zehnm
left a comment
There was a problem hiding this comment.
Looks good 👍
Thanks again for your contribution, this is a really nice enhancement!
We'll fine-tune the metadata handling with Chromecast after the next release. There are also a few UI related improvements planned.
@zehnm first draft, I need support in understanding how to setup the use_external_metadata flag. I have setup_flow working and "use_external_metadata" is being stored correctly. But I don't know how to consume the values from config yet in tv.py. Challenge for another time.