def __init__(self, plugin=None): """ Default constructor for a new content provider. You can provide an alternative implementation of a plugin. If the given plugin is None we try to get a implementation the good way :) :param plugin: :return: """ # if no plugin is given (should be default) we create our own implementation if plugin is None: from . import Plugin self._plugin = Plugin() else: self._plugin = plugin pass # initialize class for caching results of functions from helper import FunctionCache, SearchHistory, FavoriteList, WatchLaterList import constants # initialize cache cache_path = os.path.join(self.get_plugin().get_data_path(), u'kodimon') max_cache_size_mb = self.get_plugin().get_settings().get_int( constants.SETTING_CACHE_SIZE, 5) self._cache = FunctionCache(os.path.join(cache_path, u'cache'), max_file_size_kb=max_cache_size_mb * 1024) # initialize search history max_search_history_items = self.get_plugin().get_settings().get_int( constants.SETTING_SEARCH_SIZE, 50, lambda x: x * 10) self._search = SearchHistory(os.path.join(cache_path, u'search'), max_search_history_items) self._favorites = FavoriteList(os.path.join(cache_path, u'favorites')) self._watch_later = WatchLaterList( os.path.join(cache_path, u'watch_later')) # map for regular expression (path) to method (names) self._dict_path = {} # map for localization: (string)<ID> => (int)<ID> self._dict_localization = {} # register some default paths self.register_path('^/$', '_internal_root') self.register_path( '^/' + self.PATH_WATCH_LATER + '/(?P<command>add|remove|list)/?$', '_internal_watch_later') self.register_path( '^/' + self.PATH_FAVORITES + '/(?P<command>add|remove|list)/?$', '_internal_favorite') self.register_path( '^/' + self.PATH_SEARCH + '/(?P<command>new|query|list|remove)/?$', '_internal_search') """ Test each method of this class for the appended attribute '_re_match' by the decorator (RegisterPath). The '_re_match' attributes describes the path which must match for the decorated method. """ for method_name in dir(self): method = getattr(self, method_name) if hasattr(method, 'kodimon_re_path'): self.register_path(method.kodimon_re_path, method_name) pass pass self.set_localization({ self.LOCAL_FAVORITES: 30100, self.LOCAL_FAVORITES_ADD: 30101, self.LOCAL_FAVORITES_REMOVE: 30108, self.LOCAL_SEARCH: 30102, self.LOCAL_SEARCH_TITLE: 30102, self.LOCAL_SEARCH_NEW: 30110, self.LOCAL_SEARCH_REMOVE: 30108, self.LOCAL_LIBRARY: 30103, self.LOCAL_HIGHLIGHTS: 30104, self.LOCAL_ARCHIVE: 30105, self.LOCAL_NEXT_PAGE: 30106, self.LOCAL_WATCH_LATER: 30107, self.LOCAL_WATCH_LATER_ADD: 30107, self.LOCAL_WATCH_LATER_REMOVE: 30108, self.LOCAL_LATEST_VIDEOS: 30109 }) pass