Only update media icon when necessary (#24324)

* Only update media icon when necessary

* Lint

* Comment
pull/24334/head
jjlawren 2019-06-05 19:32:43 -05:00 committed by Andrew Sayre
parent 859ae2fbad
commit f5db7707bb
1 changed files with 8 additions and 0 deletions

View File

@ -167,6 +167,7 @@ class LgWebOSDevice(MediaPlayerDevice):
self._source_list = {}
self._app_list = {}
self._channel = None
self._last_icon = None
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
def update(self):
@ -271,6 +272,13 @@ class LgWebOSDevice(MediaPlayerDevice):
icon = self._app_list[self._current_source_id]['largeIcon']
if not icon.startswith('http'):
icon = self._app_list[self._current_source_id]['icon']
# 'icon' holds a URL with a transient key. Avoid unnecessary
# updates by returning the same URL until the image changes.
if self._last_icon and \
(icon.split('/')[-1] == self._last_icon.split('/')[-1]):
return self._last_icon
self._last_icon = icon
return icon
return None