[MerlinSkinThemes] - add support for layouts
[enigma2-plugins.git] / skipintro / src / __init__.py
1 from Components.config import config, ConfigSubsection, ConfigYesNo, ConfigSelectionNumber, ConfigSelection
2 import json
3 import os.path
4
5 #######################################################
6 # Initialize Configuration
7 config.plugins.skipintro = ConfigSubsection()
8
9 default_title_pattern = "(.*?)\s-\s(S\d+)E(.+)\s-\s(.*)"
10 pattern_config_file_path = "/etc/enigma2/SkipIntro.pattern.json"
11
12 if not os.path.exists(pattern_config_file_path):
13         without_title_pattern = "(.*?)\s-\s(S\d+)E(.+)"
14         title_pattern_choices = [
15                         ("Off", _("Disabled")),
16                         (default_title_pattern, "Series - S01E01 - Title"),
17                         (without_title_pattern, "Series - S01E01")
18                 ]
19
20         with open(pattern_config_file_path, "w") as write_file:
21                 json.dump(dict(title_pattern_choices), write_file, ensure_ascii=False, indent=4)
22
23 with open(pattern_config_file_path, "r") as read_file:
24     data = json.load(read_file)
25 title_pattern_choices = list(data.items())
26
27 config.plugins.skipintro.show_skipmsg = ConfigYesNo(default = True)
28 config.plugins.skipintro.show_videostartmsg = ConfigYesNo(default = False)
29 config.plugins.skipintro.skiptime_decrease = ConfigSelectionNumber(0, 5, 1, default = 0)
30 config.plugins.skipintro.title_pattern = ConfigSelection(choices = title_pattern_choices, default = default_title_pattern)
31 #config.plugins.skipintro.save_season = ConfigYesNo(default = False)