diff --git a/platypush/plugins/media/__init__.py b/platypush/plugins/media/__init__.py index 77ce7fedef..617baca502 100644 --- a/platypush/plugins/media/__init__.py +++ b/platypush/plugins/media/__init__.py @@ -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 diff --git a/platypush/plugins/media/chromecast.py b/platypush/plugins/media/chromecast.py index f30be42f06..bd38b87823 100644 --- a/platypush/plugins/media/chromecast.py +++ b/platypush/plugins/media/chromecast.py @@ -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