def __init__(self):
     self.handle = int(sys.argv[1])
     self.paramstring = try_decode(sys.argv[2][1:])
     self.params = parse_paramstring(self.paramstring)
     self.parent_params = self.params
     # self.container_path = u'{}?{}'.format(sys.argv[0], self.paramstring)
     self.update_listing = False
     self.plugin_category = ''
     self.container_content = ''
     self.container_update = None
     self.container_refresh = False
     self.item_type = None
     self.kodi_db = None
     self.kodi_db_tv = {}
     self.library = None
     self.tmdb_cache_only = True
     self.tmdb_api = TMDb()
     self.trakt_watchedindicators = ADDON.getSettingBool('trakt_watchedindicators')
     self.trakt_api = TraktAPI()
     self.is_widget = True if self.params.pop('widget', '').lower() == 'true' else False
     self.hide_watched = ADDON.getSettingBool('widgets_hidewatched') if self.is_widget else False
     self.flatten_seasons = ADDON.getSettingBool('flatten_seasons')
     self.ftv_forced_lookup = self.params.pop('fanarttv', '').lower()
     self.ftv_api = FanartTV(cache_only=self.ftv_is_cache_only())
     self.filter_key = self.params.pop('filter_key', None)
     self.filter_value = split_items(self.params.pop('filter_value', None))[0]
     self.exclude_key = self.params.pop('exclude_key', None)
     self.exclude_value = split_items(self.params.pop('exclude_value', None))[0]
     self.pagination = self.pagination_is_allowed()
     self.params = reconfigure_legacy_params(**self.params)
def _translate_discover_params(tmdb_type, params):
    lookup_keyword = None if params.get('with_id') and params.get('with_id') != 'False' else 'keyword'
    lookup_company = None if params.get('with_id') and params.get('with_id') != 'False' else 'company'
    lookup_person = None if params.get('with_id') and params.get('with_id') != 'False' else 'person'
    lookup_genre = None if params.get('with_id') and params.get('with_id') != 'False' else 'genre'
    with_separator = params.get('with_separator')

    if params.get('with_genres'):
        params['with_genres'] = TMDb().get_translated_list(
            split_items(params.get('with_genres')), lookup_genre, separator=with_separator)

    if params.get('without_genres'):
        params['without_genres'] = TMDb().get_translated_list(
            split_items(params.get('without_genres')), lookup_genre, separator=with_separator)

    if params.get('with_keywords'):
        params['with_keywords'] = TMDb().get_translated_list(
            split_items(params.get('with_keywords')), lookup_keyword, separator=with_separator)

    if params.get('without_keywords'):
        params['without_keywords'] = TMDb().get_translated_list(
            split_items(params.get('without_keywords')), lookup_keyword, separator=with_separator)

    if params.get('with_companies'):
        params['with_companies'] = TMDb().get_translated_list(
            split_items(params.get('with_companies')), lookup_company, separator='NONE')

    if params.get('with_people'):
        params['with_people'] = TMDb().get_translated_list(
            split_items(params.get('with_people')), lookup_person, separator=with_separator)

    if params.get('with_cast'):
        params['with_cast'] = TMDb().get_translated_list(
            split_items(params.get('with_cast')), lookup_person, separator=with_separator)

    if params.get('with_crew'):
        params['with_crew'] = TMDb().get_translated_list(
            split_items(params.get('with_crew')), lookup_person, separator=with_separator)

    if params.get('with_release_type'):
        params['with_release_type'] = TMDb().get_translated_list(
            split_items(params.get('with_release_type')), None, separator='OR')

    # Translate relative dates based upon today's date
    for i in RELATIVE_DATES:
        datecode = params.get(i, '')
        datecode = datecode.lower()
        if not datecode or all(x not in datecode for x in ['t-', 't+']):
            continue  # No value or not a relative date so skip
        elif 't-' in datecode:
            days = try_int(datecode.replace('t-', ''))
            date = get_datetime_now() - get_timedelta(days=days)
        elif 't+' in datecode:
            days = try_int(datecode.replace('t+', ''))
            date = get_datetime_now() + get_timedelta(days=days)
        params[i] = date.strftime("%Y-%m-%d")

    return params