diff --git a/core/channeltools.py b/core/channeltools.py index 5d350b16..4f08767a 100644 --- a/core/channeltools.py +++ b/core/channeltools.py @@ -170,46 +170,64 @@ def get_channel_controls_settings(channel_name): def get_default_settings(channel_name): import filetools, inspect - from core import support, scrapertoolsV2 - channel = __import__('channels.%s' % channel_name, fromlist=["channels.%s" % channel_name]) - if hasattr(channel, 'list_language'): - list_language = channel.list_language - list_language.insert(0, config.get_localized_string(70522)) - else: - list_language = [] - if 'episodios' in dir(channel): - episodios = getattr(__import__('channels.%s' % channel_name, fromlist=['episodios']), 'episodios') - anime = scrapertoolsV2.find_single_match(inspect.getsource(support.extract_wrapped(episodios)), r'(anime\s*=\s*True)') + # Check if it is a real channel + try: + channel = __import__('channels.%s' % channel_name, fromlist=["channels.%s" % channel_name]) + except: + return get_channel_json(channel_name).get('settings', list()) + + list_language = [config.get_localized_string(70522)] + sub = False + langs = [] + language = get_channel_json(channel_name).get('language', list()) + for lang in language: + if 'vos' not in lang: + langs.append(lang.upper()) + else: + sub = True + if sub == True: + for lang in langs: + list_language.append(lang) + list_language.append('Sub-' + lang) + + # Check if the automatic renumbering function exists + if 'episodios' in dir(channel): + from core import scrapertoolsV2 + if scrapertoolsV2.find_single_match(inspect.getsource(channel), r'(anime\s*=\s*True)') \ + or scrapertoolsV2.find_single_match(inspect.getsource(channel), r'(autorenumber\()'): + renumber = True + else: renumber = False + + # Collects configurations channel_controls = get_channel_json(channel_name).get('settings', list()) default_path = filetools.join(config.get_runtime_path(), 'default_channel_settings' + '.json') default_controls = jsontools.load(filetools.read(default_path)).get('settings', list()) - default_controls_anime = jsontools.load(filetools.read(default_path)).get('anime', list()) + default_controls_renumber = jsontools.load(filetools.read(default_path)).get('renumber', list()) categories = get_channel_json(channel_name).get('categories', list()) + + # Apply default configurations if they do not exist for control in default_controls: if control['id'] not in str(channel_controls): if 'include_in_newest' in control['id']: label = control['id'].split('_') label = label[-1] if label == 'peliculas': - if 'movie' not in categories: - pass - else: + if 'movie' in categories: control['label'] = config.get_localized_string(70727) + ' - ' + config.get_localized_string(30122) channel_controls.append(control) - logger.info(control) + else: pass elif label == 'series': - if 'tvshow' not in categories: - pass - else: + if 'tvshow' in categories: control['label'] = config.get_localized_string(70727) + ' - ' + config.get_localized_string(30123) channel_controls.append(control) + else: pass elif label == 'anime': - if 'anime' not in categories: - pass - else: + if 'anime' in categories: control['label'] = config.get_localized_string(70727) + ' - ' + config.get_localized_string(30124) channel_controls.append(control) + else: pass + else: control['label'] = config.get_localized_string(70727) + ' - ' + label.capitalize() channel_controls.append(control) @@ -218,12 +236,13 @@ def get_default_settings(channel_name): if len(list_language) > 1: control['lvalues'] = list_language channel_controls.append(control) - else: - pass + else: pass + else: channel_controls.append(control) - if anime: - for control in default_controls_anime: + + if renumber: + for control in default_controls_renumber: if control['id'] not in str(channel_controls): channel_controls.append(control) else: pass diff --git a/default_channel_settings.json b/default_channel_settings.json index 914d5730..f24134ae 100644 --- a/default_channel_settings.json +++ b/default_channel_settings.json @@ -68,7 +68,7 @@ } ], - "anime": [ + "renumber": [ { "id": "autorenumber", "type": "bool", diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index 8e783f14..5d8f2456 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -1783,7 +1783,7 @@ msgid " and quality %s" msgstr "" msgctxt "#60432" -msgid "[COLOR %s]No results in this language '%s'%s, click to show without filter[/COLOR]" +msgid "[B]No results in this language '%s'%s, click to show without filter[/B]" msgstr "" msgctxt "#60433" diff --git a/resources/language/Italian/strings.po b/resources/language/Italian/strings.po index f6373247..61d7566f 100644 --- a/resources/language/Italian/strings.po +++ b/resources/language/Italian/strings.po @@ -1782,8 +1782,8 @@ msgid " and quality %s" msgstr " e qualità %s" msgctxt "#60432" -msgid "[COLOR %s]No results in this language '%s'%s, click to show without filter[/COLOR]" -msgstr "[COLOR %s]Nessun risultato in questa lingua '%s'%s, clicca per mostrare senza filtro[/COLOR]" +msgid "[B]No results in this language '%s'%s, click to show without filter[/B]" +msgstr "[B]Nessun risultato in questa lingua '%s'%s, clicca per mostrare senza filtro[/B]" msgctxt "#60433" msgid " (disabled)" diff --git a/specials/filtertools.py b/specials/filtertools.py index 931e9b06..f434bce8 100644 --- a/specials/filtertools.py +++ b/specials/filtertools.py @@ -302,7 +302,7 @@ def get_links(list_item, item, list_language, list_quality=None, global_filter_l for i in list_item: list_item_all.append(i.tourl()) - _context = [{"title": "FILTRO: Borrar '%s'" % _filter.language, "action": "delete_from_context", + _context = [{"title": config.get_localized_string(60430) % _filter.language, "action": "delete_from_context", "channel": "filtertools", "to_channel": "seriesdanko"}] if _filter.quality_allowed: @@ -312,9 +312,7 @@ def get_links(list_item, item, list_language, list_quality=None, global_filter_l new_itemlist.append(Item(channel=__channel__, action="no_filter", list_item_all=list_item_all, show=item.show, - title="[COLOR %s]No hay elementos con idioma '%s'%s, pulsa para mostrar " - "sin filtro[/COLOR]" - % (COLOR.get("error", "auto"), _filter.language, msg_quality_allowed), + title=config.get_localized_string(60432) % (_filter.language, msg_quality_allowed), context=_context)) else: