Support for complete Chromecasts status

This commit is contained in:
Fabio Manganiello 2019-02-05 09:49:50 +01:00
parent dc2a686d23
commit 9add8890cd
2 changed files with 24 additions and 2 deletions

View file

@ -134,7 +134,7 @@ class MediaPlugin(Plugin):
if resource.startswith('youtube:') \
or resource.startswith('https://www.youtube.com/watch?v='):
if self.__class.__.__name__ != 'MediaChromecastPlugin':
if self.__class__.__name__ == 'MediaChromecastPlugin':
# The Chromecast has already its way to handle YouTube
return resource

View file

@ -266,6 +266,11 @@ class MediaChromecastPlugin(MediaPlugin):
return self.get_chromecast(chromecast or self.chromecast).media_controller.is_paused
@action
def is_idle(self, chromecast=None):
return self.get_chromecast(chromecast or self.chromecast).media_controller.is_idle
@action
def enable_subtitle(self, chromecast=None):
return self.get_chromecast(chromecast or self.chromecast).media_controller.enable_subtitle()
@ -278,7 +283,24 @@ class MediaChromecastPlugin(MediaPlugin):
@action
def status(self, chromecast=None):
return self.get_chromecast(chromecast or self.chromecast).media_controller.status
status = self.get_chromecast(chromecast or self.chromecast) \
.media_controller.status
attrs = [a for a in dir(status) if not a.startswith('_')
and not callable(getattr(status, a))]
renamed_attrs = {
'player_state': 'state',
'volume_level': 'volume',
'volume_muted': 'muted',
}
ret = {}
for attr in attrs:
if attr in renamed_attrs:
ret[renamed_attrs[attr]] = getattr(status, attr)
else:
ret[attr] = getattr(status, attr)
return ret
@action