def _change_volume(self, context: ExecutionContext): volume = context.get_slot_value('volume') if volume == '?': return EglantineServiceResult(None) volume = int(volume) if volume not in range(0, 101): return Sentences.VOLUME_RANGE multiroom = self._is_multiroom( context) and context.get_slot_id('room') is None room = self._get_room(context) if multiroom: for room in self.__yamaha_remote_factory.get_room_ids(): remote = self._remote(room) remote.turn_on() logging.info('CHANGE VOLUME TO %s (%s)' % (volume, room)) remote.set_volume(volume) return Sentences.VOLUME_MODIFICATION % volume else: remote = self._remote(room) remote.turn_on() logging.info('CHANGE VOLUME TO %s (%s)' % (volume, room)) remote.set_volume(volume) return Sentences.VOLUME_MODIFICATION_WITH_LOCATION % ( volume, self._get_room_name(room))
def __listen_album(self, context: ExecutionContext): room = self._get_room(context) query_album = context.get_slot_value('queryAlbum') query_artist = context.get_slot_value('queryArtist') if query_artist is None: query = query_album else: query = query_album + " " + query_artist logging.info('LISTEN ALBUM %s in %s' % (query, room)) self._process_rooms(context) result_search = self._remote(room).search_play(query, 'albums', 'deezer') if result_search is not None: return Sentences.ALBUM_FOUND % ( result_search['album'], result_search['artist'], self.__get_music_location(context)) else: return Sentences.ALBUM_NOT_FOUND % query_album
def __listen_track(self, context: ExecutionContext): room = self._get_room(context) query_track = context.get_slot_value('queryTrack') query_artist = context.get_slot_value('queryArtist') if query_artist is None: query = query_track else: query = query_track + " " + query_artist logging.info('LISTEN TRACK %s in %s' % (query, room)) self._process_rooms(context) result_search = self._remote(room).search_play(query, 'tracks', 'deezer') if result_search is not None: return Sentences.TRACK_FOUND % ( result_search['track'], result_search['artist'], self.__get_music_location(context)) else: return Sentences.TRACK_NOT_FOUND % query_track
def __listen_artist(self, context: ExecutionContext): room = self._get_room(context) query = context.get_slot_value('queryArtist') logging.info('LISTEN ARTIST %s in %s' % (query, room)) self._process_rooms(context) result_search = self._remote(room).search_play(query, 'artists', 'deezer') if result_search is not None: return Sentences.ARTIST_FOUND % (result_search['artist'], self.__get_music_location(context)) else: return Sentences.ARTIST_NOT_FOUND % query
def __listen_radio(self, context: ExecutionContext): room = self._get_room(context) query = simplify_accronym(context.get_slot_value('queryRadio')) logging.info('LISTEN RADIO %s in %s' % (query, room)) self._process_rooms(context) result_search = self._remote(room).play_radio(query) if result_search is not None: return Sentences.RADIO_FOUND % (result_search, self.__get_music_location(context)) else: return Sentences.RADIO_NOT_FOUND % (query, self.__get_music_location(context))
def __epg_current_channel(self, context: ExecutionContext): channel_number = context.get_slot_id('channel') channel_name = context.get_slot_value('channel') program = self.epg_service.get_current_programs_by_channel(channel_number) if program is None: return Sentences.NO_EPG_CHANNEL % channel_name program_result = program.title if program.sub_title is not None: program_result += "," + program.sub_title if program.description is not None: program_result += ",," + program.description return Sentences.EPG_CHANNEL % (channel_name, program_result)
def __watch_movie(self, context: ExecutionContext): queryMovie = context.get_slot_value('queryMovie') movie = self.__find_movie(queryMovie) if movie is None: return Sentences.MOVIE_NOT_FOUND % (queryMovie) room = context.get_slot_id('room', self._get_default_room()) self._remote(room).set_input(self._kodi_input) response = self._kodi.Player.Open( {"item": { "movieid": movie['movieid'] }}) if self.__check_result(response): return Sentences.MOVIE_FOUND % (movie['label']) else: return Sentences.MOVIE_ERROR_STARTED % (movie['label'])