desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Flag media player features that are supported.'
@property def supported_features(self):
return SUPPORT_MPD
'Name of the current input source.'
@property def source(self):
return self._currentplaylist
'Return the list of available input sources.'
@property def source_list(self):
return self._playlists
'Choose a different available playlist and play it.'
def select_source(self, source):
self.play_media(MEDIA_TYPE_PLAYLIST, source)
'Update available MPD playlists.'
@Throttle(PLAYLIST_UPDATE_INTERVAL) def _update_playlists(self, **kwargs):
self._playlists = [] for playlist_data in self._client.listplaylists(): self._playlists.append(playlist_data['playlist'])
'Set volume of media player.'
def set_volume_level(self, volume):
self._client.setvol(int((volume * 100)))
'Service to send the MPD the command for volume up.'
def volume_up(self):
current_volume = int(self._status['volume']) if (current_volume <= 100): self._client.setvol((current_volume + 5))
'Service to send the MPD the command for volume down.'
def volume_down(self):
current_volume = int(self._status['volume']) if (current_volume >= 0): self._client.setvol((current_volume - 5))
'Service to send the MPD the command for play/pause.'
def media_play(self):
self._client.pause(0)
'Service to send the MPD the command for play/pause.'
def media_pause(self):
self._client.pause(1)
'Service to send the MPD the command for stop.'
def media_stop(self):
self._client.stop()
'Service to send the MPD the command for next track.'
def media_next_track(self):
self._client.next()
'Service to send the MPD the command for previous track.'
def media_previous_track(self):
self._client.previous()
'Send the media player the command for playing a playlist.'
def play_media(self, media_type, media_id, **kwargs):
_LOGGER.debug(str.format('Playing playlist: {0}', media_id)) if (media_type == MEDIA_TYPE_PLAYLIST): if (media_id in self._playlists): self._currentplaylist = media_id else: self._currentplaylist = None _LOGGER.warning(str.format('Unknown playlist ...
'Boolean if shuffle is enabled.'
@property def shuffle(self):
return bool(self._status['random'])
'Enable/disable shuffle mode.'
def set_shuffle(self, shuffle):
self._client.random(int(shuffle))
'Clear players playlist.'
def clear_playlist(self):
self._client.clear()
'Send seek command.'
def media_seek(self, position):
self._client.seekcur(position)
'Initialize the Philips TV.'
def __init__(self, tv, name):
self._tv = tv self._name = name self._state = STATE_UNKNOWN self._min_volume = None self._max_volume = None self._volume = None self._muted = False self._program_name = None self._channel_name = None self._source = None self._source_list = [] self._connfail = 0 self._...
'Return the device name.'
@property def name(self):
return self._name
'Device should be polled.'
@property def should_poll(self):
return True
'Flag media player features that are supported.'
@property def supported_features(self):
if self._watching_tv: return SUPPORT_PHILIPS_JS_TV return SUPPORT_PHILIPS_JS
'Get the device state. An exception means OFF state.'
@property def state(self):
return self._state
'Return the current input source.'
@property def source(self):
return self._source
'List of available input sources.'
@property def source_list(self):
return self._source_list
'Set the input source.'
def select_source(self, source):
if (source in self._source_mapping): self._tv.setSource(self._source_mapping.get(source)) self._source = source if (not self._tv.on): self._state = STATE_OFF self._watching_tv = bool((self._tv.source_id == 'tv'))
'Volume level of the media player (0..1).'
@property def volume_level(self):
return self._volume
'Boolean if volume is currently muted.'
@property def is_volume_muted(self):
return self._muted
'Turn off the device.'
def turn_off(self):
self._tv.sendKey('Standby') if (not self._tv.on): self._state = STATE_OFF
'Send volume up command.'
def volume_up(self):
self._tv.sendKey('VolumeUp') if (not self._tv.on): self._state = STATE_OFF
'Send volume down command.'
def volume_down(self):
self._tv.sendKey('VolumeDown') if (not self._tv.on): self._state = STATE_OFF
'Send mute command.'
def mute_volume(self, mute):
self._tv.sendKey('Mute') if (not self._tv.on): self._state = STATE_OFF
'Send rewind commmand.'
def media_previous_track(self):
self._tv.sendKey('Previous')
'Send fast forward commmand.'
def media_next_track(self):
self._tv.sendKey('Next')
'Title of current playing media.'
@property def media_title(self):
if (self._watching_tv and self._channel_name): return '{} - {}'.format(self._source, self._channel_name) return self._source
'Get the latest data and update device state.'
@Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self):
self._tv.update() self._min_volume = self._tv.min_volume self._max_volume = self._tv.max_volume self._volume = self._tv.volume self._muted = self._tv.muted if self._tv.source_id: src = self._tv.sources.get(self._tv.source_id, None) if src: self._source = src.get('name...
'Initialize the Livebox Play TV device.'
def __init__(self, host, port, name):
from liveboxplaytv import LiveboxPlayTv self._client = LiveboxPlayTv(host, port) self._muted = False self._name = name self._current_source = None self._state = STATE_UNKNOWN self._channel_list = {} self._current_channel = None self._current_program = None self._media_image_url =...
'Retrieve the latest data.'
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS) def update(self):
try: self._state = self.refresh_state() channel = self._client.get_current_channel() if (channel is not None): self._current_program = self._client.program self._current_channel = channel.get('name', None) self._media_image_url = self._client.get_current_c...
'Return the name of the device.'
@property def name(self):
return self._name
'Return the state of the device.'
@property def state(self):
return self._state
'Boolean if volume is currently muted.'
@property def is_volume_muted(self):
return self._muted
'Return the current input source.'
@property def source(self):
return self._current_channel
'List of available input sources.'
@property def source_list(self):
return [self._channel_list[c] for c in sorted(self._channel_list.keys())]
'Content type of current playing media.'
@property def media_content_type(self):
return MEDIA_TYPE_CHANNEL
'Image url of current playing media.'
@property def media_image_url(self):
return self._media_image_url
'Title of current playing media.'
@property def media_title(self):
if self._current_channel: return '{}: {}'.format(self._current_channel, self._current_program)
'Flag media player features that are supported.'
@property def supported_features(self):
return SUPPORT_LIVEBOXPLAYTV
'Refresh the list of available channels.'
def refresh_channel_list(self):
new_channel_list = {} for channel in self._client.get_channels(): new_channel_list[int(channel['index'])] = channel['name'] self._channel_list = new_channel_list
'Refresh the current media state.'
def refresh_state(self):
state = self._client.media_state if (state == 'PLAY'): return STATE_PLAYING elif (state == 'PAUSE'): return STATE_PAUSED return (STATE_ON if self._client.is_on else STATE_OFF)
'Turn off media player.'
def turn_off(self):
self._state = STATE_OFF self._client.turn_off()
'Turn on the media player.'
def turn_on(self):
self._state = STATE_ON self._client.turn_on()
'Volume up the media player.'
def volume_up(self):
self._client.volume_up()
'Volume down media player.'
def volume_down(self):
self._client.volume_down()
'Send mute command.'
def mute_volume(self, mute):
self._muted = mute self._client.mute()
'Simulate play pause media player.'
def media_play_pause(self):
self._client.play_pause()
'Select input source.'
def select_source(self, source):
self._current_source = source self._client.set_channel(source)
'Send play command.'
def media_play(self):
self._state = STATE_PLAYING self._client.play()
'Send media pause command to media player.'
def media_pause(self):
self._state = STATE_PAUSED self._client.pause()
'Send next track command.'
def media_next_track(self):
self._client.channel_up()
'Send the previous track command.'
def media_previous_track(self):
self._client.channel_down()
'Initialize the MPC-HC device.'
def __init__(self, name, url):
self._name = name self._url = url self._player_variables = dict()
'Get the latest details.'
def update(self):
try: response = requests.get('{}/variables.html'.format(self._url), data=None, timeout=3) mpchc_variables = re.findall('<p id="(.+?)">(.+?)</p>', response.text) for var in mpchc_variables: self._player_variables[var[0]] = var[1].lower() except requests.exceptions.RequestEx...
'Send a command to MPC-HC via its window message ID.'
def _send_command(self, command_id):
try: params = {'wm_command': command_id} requests.get('{}/command.html'.format(self._url), params=params, timeout=3) except requests.exceptions.RequestException: _LOGGER.error('Could not send command %d to MPC-HC at: %s', command_id, self._url)
'Return the name of the device.'
@property def name(self):
return self._name
'Return the state of the device.'
@property def state(self):
state = self._player_variables.get('statestring', None) if (state is None): return STATE_OFF if (state == 'playing'): return STATE_PLAYING elif (state == 'paused'): return STATE_PAUSED return STATE_IDLE
'Return the title of current playing media.'
@property def media_title(self):
return self._player_variables.get('file', None)
'Return the volume level of the media player (0..1).'
@property def volume_level(self):
return (int(self._player_variables.get('volumelevel', 0)) / 100.0)
'Return boolean if volume is currently muted.'
@property def is_volume_muted(self):
return (self._player_variables.get('muted', '0') == '1')
'Return the duration of the current playing media in seconds.'
@property def media_duration(self):
duration = self._player_variables.get('durationstring', '00:00:00').split(':') return (((int(duration[0]) * 3600) + (int(duration[1]) * 60)) + int(duration[2]))
'Flag media player features that are supported.'
@property def supported_features(self):
return SUPPORT_MPCHC
'Volume up the media player.'
def volume_up(self):
self._send_command(907)
'Volume down media player.'
def volume_down(self):
self._send_command(908)
'Mute the volume.'
def mute_volume(self, mute):
self._send_command(909)
'Send play command.'
def media_play(self):
self._send_command(887)
'Send pause command.'
def media_pause(self):
self._send_command(888)
'Send stop command.'
def media_stop(self):
self._send_command(890)
'Send next track command.'
def media_next_track(self):
self._send_command(921)
'Send previous track command.'
def media_previous_track(self):
self._send_command(920)
'Initialize the Cast device.'
def __init__(self, chromecast):
self.cast = chromecast self.cast.socket_client.receiver_controller.register_status_listener(self) self.cast.socket_client.media_controller.register_status_listener(self) self.cast_status = self.cast.status self.media_status = self.cast.media_controller.status self.media_status_received = None
'No polling needed.'
@property def should_poll(self):
return False
'Return the name of the device.'
@property def name(self):
return self.cast.device.friendly_name
'Return the state of the player.'
@property def state(self):
if (self.media_status is None): return STATE_UNKNOWN elif self.media_status.player_is_playing: return STATE_PLAYING elif self.media_status.player_is_paused: return STATE_PAUSED elif self.media_status.player_is_idle: return STATE_IDLE elif self.cast.is_idle: re...
'Volume level of the media player (0..1).'
@property def volume_level(self):
return (self.cast_status.volume_level if self.cast_status else None)
'Boolean if volume is currently muted.'
@property def is_volume_muted(self):
return (self.cast_status.volume_muted if self.cast_status else None)
'Content ID of current playing media.'
@property def media_content_id(self):
return (self.media_status.content_id if self.media_status else None)
'Content type of current playing media.'
@property def media_content_type(self):
if (self.media_status is None): return None elif self.media_status.media_is_tvshow: return MEDIA_TYPE_TVSHOW elif self.media_status.media_is_movie: return MEDIA_TYPE_VIDEO elif self.media_status.media_is_musictrack: return MEDIA_TYPE_MUSIC return None
'Duration of current playing media in seconds.'
@property def media_duration(self):
return (self.media_status.duration if self.media_status else None)
'Image url of current playing media.'
@property def media_image_url(self):
if (self.media_status is None): return None images = self.media_status.images return (images[0].url if images else None)
'Title of current playing media.'
@property def media_title(self):
return (self.media_status.title if self.media_status else None)
'Artist of current playing media (Music track only).'
@property def media_artist(self):
return (self.media_status.artist if self.media_status else None)
'Album of current playing media (Music track only).'
@property def media_album(self):
return (self.media_status.album_name if self.media_status else None)
'Album arist of current playing media (Music track only).'
@property def media_album_artist(self):
return (self.media_status.album_artist if self.media_status else None)
'Track number of current playing media (Music track only).'
@property def media_track(self):
return (self.media_status.track if self.media_status else None)
'Return the title of the series of current playing media.'
@property def media_series_title(self):
return (self.media_status.series_title if self.media_status else None)
'Season of current playing media (TV Show only).'
@property def media_season(self):
return (self.media_status.season if self.media_status else None)
'Episode of current playing media (TV Show only).'
@property def media_episode(self):
return (self.media_status.episode if self.media_status else None)
'Return the ID of the current running app.'
@property def app_id(self):
return self.cast.app_id
'Name of the current running app.'
@property def app_name(self):
return self.cast.app_display_name
'Flag media player features that are supported.'
@property def supported_features(self):
return SUPPORT_CAST
'Position of current playing media in seconds.'
@property def media_position(self):
if ((self.media_status is None) or (not (self.media_status.player_is_playing or self.media_status.player_is_paused or self.media_status.player_is_idle))): return None return self.media_status.current_time