Support for complete Chromecasts status
This commit is contained in:
parent
dc2a686d23
commit
9add8890cd
2 changed files with 24 additions and 2 deletions
|
@ -134,7 +134,7 @@ class MediaPlugin(Plugin):
|
||||||
|
|
||||||
if resource.startswith('youtube:') \
|
if resource.startswith('youtube:') \
|
||||||
or resource.startswith('https://www.youtube.com/watch?v='):
|
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
|
# The Chromecast has already its way to handle YouTube
|
||||||
return resource
|
return resource
|
||||||
|
|
||||||
|
|
|
@ -266,6 +266,11 @@ class MediaChromecastPlugin(MediaPlugin):
|
||||||
return self.get_chromecast(chromecast or self.chromecast).media_controller.is_paused
|
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
|
@action
|
||||||
def enable_subtitle(self, chromecast=None):
|
def enable_subtitle(self, chromecast=None):
|
||||||
return self.get_chromecast(chromecast or self.chromecast).media_controller.enable_subtitle()
|
return self.get_chromecast(chromecast or self.chromecast).media_controller.enable_subtitle()
|
||||||
|
@ -278,7 +283,24 @@ class MediaChromecastPlugin(MediaPlugin):
|
||||||
|
|
||||||
@action
|
@action
|
||||||
def status(self, chromecast=None):
|
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
|
@action
|
||||||
|
|
Loading…
Reference in a new issue