def update_search_history(self, keyword): with self.get_storage('__history__.pcl') as storage: history = storage.get('history', []) keyword = py2_decode(keyword) i = 0 keyword_lower = keyword.lower() while i < len(history): item = history[i] if isinstance(item, dict): item_keyword = item['keyword'] # backward compatibility else: item_keyword = item item_keyword = py2_decode(item_keyword).lower() if item_keyword == keyword_lower: del history[i] else: i += 1 history.insert(0, keyword) history_length = self.get_setting('history_length') if len(history) > history_length: history[history_length - len(history):] = [] storage['history'] = history
def __init__(self, id_=''): """ Class constructor """ super(Addon, self).__init__(id_) self._reg_tempunit = py2_decode(xbmc.getRegion('tempunit')) self._reg_tempunit = py2_decode(xbmc.getRegion('tempunit')) self._reg_speedunit = xbmc.getRegion('speedunit') self._reg_dateshort = xbmc.getRegion('dateshort') self._reg_meridiem = xbmc.getRegion('meridiem')
def dialog_notification(self, heading, message="", icon="", time=0, sound=True): _message = message if message else heading addon_name = py2_decode(self.name) if heading \ and heading != _message: _heading = '{0}: {1}'.format(addon_name, heading) else: _heading = py2_decode(addon_name) xbmcgui.Dialog().notification(_heading, _message, icon, time, sound)
def weather_icon(self): """ Weather icon for curren KODI version :return: weather icon :rtype: str """ major_version = xbmc.getInfoLabel('System.BuildVersion')[:2] if major_version < '16': weather_icon = py2_decode( translate_path('special://temp/weather/%s.png')) else: weather_icon = py2_decode(translate_path('%s.png')) return weather_icon
def __init__(self, id_=''): """ Class constructor """ super(Weather, self).__init__(id_) self._url = 'plugin://{0}/'.format(self.id) self.actions = {} self._params = None self._window = xbmcgui.Window(12600) self._reg_tempunit = py2_decode(xbmc.getRegion('tempunit')) self._reg_speedunit = xbmc.getRegion('speedunit') self._reg_dateshort = xbmc.getRegion('dateshort') self._reg_meridiem = xbmc.getRegion('meridiem')