def _fill_in_default_filler_list_settings(self, settings_dict: dict, handle_errors: bool = False ) -> dict: """ Set some dynamic default values, such as filler list name :param settings_dict: Dictionary of new settings for filler list :type settings_dict: dict :param handle_errors: Whether to handle internal errors :type handle_errors: bool, optional :return: Dictionary of settings with defaults filled in :rtype: dict """ if not settings_dict.get('content'): # empty or doesn't exist if handle_errors: settings_dict['content'] = [{ "duration": 600000, "isOffline": True }] else: raise ChannelCreationError( "You must include at least one program when creating a filler list." ) if 'name' not in settings_dict.keys(): settings_dict['name'] = f"New List {len(self.filler_lists) + 1}" return helpers._combine_settings( new_settings_dict=settings_dict, template_dict=CHANNEL_SETTINGS_DEFAULT)
def update_hdhr_settings(self, **kwargs) -> bool: """ Edit dizqueTV's HDHomeRun settings :param kwargs: keyword arguments of setting names and values :return: True if successful, False if unsuccessful :rtype: bool """ new_settings = helpers._combine_settings( new_settings_dict=kwargs, template_dict=self.hdhr_settings._data) if self._put(endpoint='/hdhr-settings', data=new_settings): return True return False
def update_plex_server(self, server_name: str, **kwargs) -> bool: """ Edit a Plex Media Server on dizqueTV :param server_name: name of Plex Media Server to update :type server_name: str :param kwargs: keyword arguments of setting names and values :return: True if successful, False if unsuccessful :rtype: bool """ server = self.get_plex_server(server_name=server_name) if server: new_settings = helpers._combine_settings( new_settings_dict=kwargs, template_dict=server._data) if self._post(endpoint='/plex-servers', data=new_settings): return True return False
def update_filler_list(self, filler_list_id: str, **kwargs) -> bool: """ Edit a dizqueTV FillerList :param filler_list_id: ID of FillerList to update :type filler_list_id: str :param kwargs: keyword arguments of setting names and values :return: True if successful, False if unsuccessful :rtype: bool """ filler_list = self.get_filler_list(filler_list_id=filler_list_id) if filler_list: new_settings = helpers._combine_settings( new_settings_dict=kwargs, template_dict=filler_list._data) if self._post(endpoint=f"/filler/{filler_list_id}", data=new_settings): return True return False
def update_filler(self, filler: FillerItem, **kwargs) -> bool: """ Update a filler item on this filler list :param filler: FillerItem object to update :type filler: FillerItem :param kwargs: Keyword arguments of new FillerItem settings names and values :return: True if successful, False if unsuccessful (FillerList reloads in-place) :rtype: bool """ filler_list_data = self._data for a_filler in filler_list_data['content']: if a_filler['title'] == filler.title: if kwargs.get('duration'): filler_list_data['duration'] -= a_filler['duration'] filler_list_data['duration'] += kwargs['duration'] new_data = helpers._combine_settings(new_settings_dict=kwargs, default_dict=a_filler) a_filler.update(new_data) return self.update(**filler_list_data) return False