2019-12-27 23:05:37 +03:00
|
|
|
import copy
|
2019-12-13 13:31:07 +03:00
|
|
|
import json
|
2020-01-02 15:47:48 +03:00
|
|
|
import locale
|
2019-12-13 13:31:07 +03:00
|
|
|
import os
|
2020-03-22 14:13:01 +03:00
|
|
|
import sys
|
2019-12-22 20:42:29 +03:00
|
|
|
from enum import Enum, IntEnum
|
2019-12-13 13:31:07 +03:00
|
|
|
from pathlib import Path
|
2019-12-27 23:05:37 +03:00
|
|
|
from pprint import pformat
|
|
|
|
|
from textwrap import dedent
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2020-02-12 13:51:40 +03:00
|
|
|
HOME_PATH = str(Path.home())
|
|
|
|
|
CONFIG_PATH = HOME_PATH + "/.config/demon-editor/"
|
2019-12-13 13:31:07 +03:00
|
|
|
CONFIG_FILE = CONFIG_PATH + "config.json"
|
2020-02-12 13:51:40 +03:00
|
|
|
DATA_PATH = HOME_PATH + "/DemonEditor/data/"
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2020-03-22 14:13:01 +03:00
|
|
|
IS_DARWIN = sys.platform == "darwin"
|
|
|
|
|
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2019-12-22 20:42:29 +03:00
|
|
|
class Defaults(Enum):
|
|
|
|
|
""" Default program settings """
|
|
|
|
|
DEFAULT_PROFILE = "default"
|
|
|
|
|
BACKUP_BEFORE_DOWNLOADING = True
|
|
|
|
|
BACKUP_BEFORE_SAVE = True
|
|
|
|
|
V5_SUPPORT = False
|
|
|
|
|
HTTP_API_SUPPORT = False
|
|
|
|
|
ENABLE_YT_DL = False
|
|
|
|
|
ENABLE_SEND_TO = False
|
|
|
|
|
USE_COLORS = True
|
|
|
|
|
NEW_COLOR = "rgb(255,230,204)"
|
|
|
|
|
EXTRA_COLOR = "rgb(179,230,204)"
|
|
|
|
|
FAV_CLICK_MODE = 0
|
2020-03-22 14:13:01 +03:00
|
|
|
PLAY_STREAMS_MODE = 1 if IS_DARWIN else 0
|
2020-03-06 11:55:34 +03:00
|
|
|
PROFILE_FOLDER_DEFAULT = False
|
|
|
|
|
RECORDS_PATH = DATA_PATH + "records/"
|
2020-03-09 14:53:03 +03:00
|
|
|
ACTIVATE_TRANSCODING = False
|
|
|
|
|
ACTIVE_TRANSCODING_PRESET = "720p TV/device"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_settings():
|
|
|
|
|
os.makedirs(os.path.dirname(CONFIG_PATH), exist_ok=True)
|
|
|
|
|
|
|
|
|
|
if not os.path.isfile(CONFIG_FILE) or os.stat(CONFIG_FILE).st_size == 0:
|
|
|
|
|
write_settings(get_default_settings())
|
|
|
|
|
|
|
|
|
|
with open(CONFIG_FILE, "r") as config_file:
|
|
|
|
|
return json.load(config_file)
|
2019-12-22 20:42:29 +03:00
|
|
|
|
|
|
|
|
|
2019-12-27 23:05:37 +03:00
|
|
|
def get_default_settings(profile_name="default"):
|
|
|
|
|
def_settings = SettingsType.ENIGMA_2.get_default_settings()
|
|
|
|
|
set_local_paths(def_settings, profile_name)
|
|
|
|
|
|
2019-12-22 20:42:29 +03:00
|
|
|
return {
|
|
|
|
|
"version": 1,
|
|
|
|
|
"default_profile": Defaults.DEFAULT_PROFILE.value,
|
2019-12-27 23:05:37 +03:00
|
|
|
"profiles": {profile_name: def_settings},
|
2019-12-22 20:42:29 +03:00
|
|
|
"v5_support": Defaults.V5_SUPPORT.value,
|
|
|
|
|
"http_api_support": Defaults.HTTP_API_SUPPORT.value,
|
|
|
|
|
"enable_yt_dl": Defaults.ENABLE_YT_DL.value,
|
|
|
|
|
"enable_send_to": Defaults.ENABLE_SEND_TO.value,
|
|
|
|
|
"use_colors": Defaults.USE_COLORS.value,
|
|
|
|
|
"new_color": Defaults.NEW_COLOR.value,
|
|
|
|
|
"extra_color": Defaults.EXTRA_COLOR.value,
|
2020-03-06 11:55:34 +03:00
|
|
|
"fav_click_mode": Defaults.FAV_CLICK_MODE.value,
|
|
|
|
|
"profile_folder_is_default": Defaults.PROFILE_FOLDER_DEFAULT.value,
|
|
|
|
|
"records_path": Defaults.RECORDS_PATH.value
|
2019-12-22 20:42:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-03-09 14:53:03 +03:00
|
|
|
def get_default_transcoding_presets():
|
|
|
|
|
return {"720p TV/device": {"vcodec": "h264", "vb": "1500", "width": "1280", "height": "720", "acodec": "mp3",
|
|
|
|
|
"ab": "192", "channels": "2", "samplerate": "44100", "scodec": "none"},
|
|
|
|
|
"1080p TV/device": {"vcodec": "h264", "vb": "3500", "width": "1920", "height": "1080", "acodec": "mp3",
|
|
|
|
|
"ab": "192", "channels": "2", "samplerate": "44100", "scodec": "none"}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_settings(config):
|
|
|
|
|
with open(CONFIG_FILE, "w") as config_file:
|
|
|
|
|
json.dump(config, config_file, indent=" ")
|
|
|
|
|
|
|
|
|
|
|
2020-03-06 11:55:34 +03:00
|
|
|
def set_local_paths(settings, profile_name, data_path=DATA_PATH, use_profile_folder=False):
|
|
|
|
|
settings["data_local_path"] = "{}{}/".format(data_path, profile_name)
|
|
|
|
|
if use_profile_folder:
|
|
|
|
|
settings["picons_local_path"] = "{}{}/{}/".format(data_path, profile_name, "picons")
|
|
|
|
|
settings["backup_local_path"] = "{}{}/{}/".format(data_path, profile_name, "backup")
|
|
|
|
|
else:
|
|
|
|
|
settings["picons_local_path"] = "{}{}/{}/".format(data_path, "picons", profile_name)
|
|
|
|
|
settings["backup_local_path"] = "{}{}/{}/".format(data_path, "backup", profile_name)
|
2019-12-27 23:05:37 +03:00
|
|
|
|
|
|
|
|
|
2019-12-22 20:42:29 +03:00
|
|
|
class SettingsType(IntEnum):
|
2019-12-13 13:31:07 +03:00
|
|
|
""" Profiles for settings """
|
2019-12-22 20:42:29 +03:00
|
|
|
ENIGMA_2 = 0
|
|
|
|
|
NEUTRINO_MP = 1
|
|
|
|
|
|
|
|
|
|
def get_default_settings(self):
|
|
|
|
|
""" Returns default settings for current type """
|
|
|
|
|
if self is self.ENIGMA_2:
|
2019-12-27 23:05:37 +03:00
|
|
|
return {"setting_type": self.value,
|
2019-12-22 20:42:29 +03:00
|
|
|
"host": "127.0.0.1", "port": "21", "user": "root", "password": "root", "timeout": 5,
|
2020-01-03 23:26:55 +03:00
|
|
|
"http_user": "root", "http_password": "", "http_port": "80",
|
|
|
|
|
"http_timeout": 5, "http_use_ssl": False,
|
2019-12-22 20:42:29 +03:00
|
|
|
"telnet_user": "root", "telnet_password": "", "telnet_port": "23", "telnet_timeout": 5,
|
|
|
|
|
"services_path": "/etc/enigma2/", "user_bouquet_path": "/etc/enigma2/",
|
|
|
|
|
"satellites_xml_path": "/etc/tuxbox/", "data_local_path": DATA_PATH + "enigma2/",
|
2019-12-27 23:05:37 +03:00
|
|
|
"picons_path": "/usr/share/enigma2/picon/",
|
2019-12-22 20:42:29 +03:00
|
|
|
"picons_local_path": DATA_PATH + "enigma2/picons/",
|
|
|
|
|
"backup_local_path": DATA_PATH + "enigma2/backup/"}
|
|
|
|
|
elif self is self.NEUTRINO_MP:
|
|
|
|
|
return {"setting_type": self,
|
|
|
|
|
"host": "127.0.0.1", "port": "21", "user": "root", "password": "root", "timeout": 5,
|
2020-01-03 23:26:55 +03:00
|
|
|
"http_user": "", "http_password": "", "http_port": "80", "http_timeout": 2, "http_use_ssl": False,
|
2019-12-22 20:42:29 +03:00
|
|
|
"telnet_user": "root", "telnet_password": "", "telnet_port": "23", "telnet_timeout": 1,
|
|
|
|
|
"services_path": "/var/tuxbox/config/zapit/", "user_bouquet_path": "/var/tuxbox/config/zapit/",
|
|
|
|
|
"satellites_xml_path": "/var/tuxbox/config/", "data_local_path": DATA_PATH + "neutrino/",
|
|
|
|
|
"picons_path": "/usr/share/tuxbox/neutrino/icons/logo/",
|
|
|
|
|
"picons_local_path": DATA_PATH + "neutrino/picons/",
|
|
|
|
|
"backup_local_path": DATA_PATH + "neutrino/backup/"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsException(Exception):
|
|
|
|
|
pass
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
|
2020-03-22 14:13:01 +03:00
|
|
|
class PlayStreamsMode(IntEnum):
|
|
|
|
|
""" Behavior mode when opening streams. """
|
|
|
|
|
BUILT_IN = 0
|
|
|
|
|
VLC = 1
|
|
|
|
|
M3U = 2
|
|
|
|
|
|
|
|
|
|
|
2019-12-13 13:31:07 +03:00
|
|
|
class Settings:
|
|
|
|
|
__INSTANCE = None
|
2019-12-22 20:42:29 +03:00
|
|
|
__VERSION = 1
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2019-12-27 23:05:37 +03:00
|
|
|
def __init__(self, ext_settings=None):
|
|
|
|
|
settings = ext_settings or get_settings()
|
2019-12-22 20:42:29 +03:00
|
|
|
|
|
|
|
|
if self.__VERSION > settings.get("version", 0):
|
|
|
|
|
raise SettingsException("Outdated version of the settings format!")
|
|
|
|
|
|
|
|
|
|
self._settings = settings
|
|
|
|
|
self._current_profile = self._settings.get("default_profile", "default")
|
|
|
|
|
self._profiles = self._settings.get("profiles", {"default": SettingsType.ENIGMA_2.get_default_settings()})
|
2020-02-10 14:45:05 +03:00
|
|
|
self._cp_settings = self._profiles.get(self._current_profile, None) # Current profile settings
|
|
|
|
|
if not self._cp_settings:
|
|
|
|
|
raise SettingsException("Error reading settings [current profile].")
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return dedent(""" Current profile: {}
|
|
|
|
|
Current profile options:
|
|
|
|
|
{}
|
|
|
|
|
Full config:
|
|
|
|
|
{}
|
|
|
|
|
""").format(self._current_profile,
|
2019-12-22 20:42:29 +03:00
|
|
|
pformat(self._cp_settings),
|
|
|
|
|
pformat(self._settings))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def get_instance(cls):
|
|
|
|
|
if not cls.__INSTANCE:
|
|
|
|
|
cls.__INSTANCE = Settings()
|
|
|
|
|
return cls.__INSTANCE
|
|
|
|
|
|
|
|
|
|
def save(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
write_settings(self._settings)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
def reset(self, force_write=False):
|
2019-12-22 20:42:29 +03:00
|
|
|
for k, v in self.setting_type.get_default_settings().items():
|
|
|
|
|
self._cp_settings[k] = v
|
2020-03-06 11:55:34 +03:00
|
|
|
|
|
|
|
|
def_path = self.default_data_path
|
|
|
|
|
def_path += "enigma2/" if self.setting_type is SettingsType.ENIGMA_2 else "neutrino/"
|
|
|
|
|
set_local_paths(self._cp_settings, self._current_profile, def_path, self.profile_folder_is_default)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
if force_write:
|
2019-12-22 20:42:29 +03:00
|
|
|
self.save()
|
|
|
|
|
|
2020-01-02 15:47:48 +03:00
|
|
|
@staticmethod
|
|
|
|
|
def reset_to_default():
|
|
|
|
|
write_settings(get_default_settings())
|
|
|
|
|
|
2019-12-22 20:42:29 +03:00
|
|
|
def get_default(self, p_name):
|
|
|
|
|
""" Returns default value for current settings type """
|
|
|
|
|
return self.setting_type.get_default_settings().get(p_name)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
def add(self, name, value):
|
|
|
|
|
""" Adds extra options """
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings[name] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
def get(self, name):
|
2019-12-22 20:42:29 +03:00
|
|
|
""" Returns extra options or None """
|
|
|
|
|
return self._settings.get(name, None)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2019-12-27 23:05:37 +03:00
|
|
|
@property
|
|
|
|
|
def settings(self):
|
|
|
|
|
""" Returns copy of the current settings! """
|
|
|
|
|
return copy.deepcopy(self._settings)
|
|
|
|
|
|
|
|
|
|
@settings.setter
|
|
|
|
|
def settings(self, value):
|
|
|
|
|
""" Sets copy of the settings! """
|
|
|
|
|
self._settings = copy.deepcopy(value)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def current_profile(self):
|
|
|
|
|
return self._current_profile
|
|
|
|
|
|
|
|
|
|
@current_profile.setter
|
|
|
|
|
def current_profile(self, value):
|
|
|
|
|
self._current_profile = value
|
|
|
|
|
self._cp_settings = self._profiles.get(self._current_profile)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def default_profile(self):
|
|
|
|
|
return self._settings.get("default_profile", "default")
|
|
|
|
|
|
|
|
|
|
@default_profile.setter
|
|
|
|
|
def default_profile(self, value):
|
|
|
|
|
self._settings["default_profile"] = value
|
|
|
|
|
|
2019-12-13 13:31:07 +03:00
|
|
|
@property
|
2019-12-22 20:42:29 +03:00
|
|
|
def profiles(self):
|
|
|
|
|
return self._profiles
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2019-12-22 20:42:29 +03:00
|
|
|
@profiles.setter
|
|
|
|
|
def profiles(self, ps):
|
|
|
|
|
self._profiles = ps
|
|
|
|
|
self._settings["profiles"] = self._profiles
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
2019-12-22 20:42:29 +03:00
|
|
|
def setting_type(self):
|
|
|
|
|
return SettingsType(self._cp_settings.get("setting_type", SettingsType.ENIGMA_2.value))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2019-12-22 20:42:29 +03:00
|
|
|
@setting_type.setter
|
|
|
|
|
def setting_type(self, s_type):
|
2020-01-08 14:50:04 +03:00
|
|
|
self._cp_settings["setting_type"] = s_type.value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2020-04-02 16:50:58 +03:00
|
|
|
# ******* Network ******** #
|
2020-01-09 13:14:49 +03:00
|
|
|
|
2019-12-13 13:31:07 +03:00
|
|
|
@property
|
|
|
|
|
def host(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("host", self.get_default("host"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@host.setter
|
|
|
|
|
def host(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["host"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def port(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("port", self.get_default("port"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@port.setter
|
|
|
|
|
def port(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["port"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def user(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("user", self.get_default("user"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@user.setter
|
|
|
|
|
def user(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["user"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def password(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("password", self.get_default("password"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@password.setter
|
|
|
|
|
def password(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["password"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def http_user(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("http_user", self.get_default("http_user"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@http_user.setter
|
|
|
|
|
def http_user(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["http_user"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def http_password(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("http_password", self.get_default("http_password"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@http_password.setter
|
|
|
|
|
def http_password(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["http_password"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def http_port(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("http_port", self.get_default("http_port"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@http_port.setter
|
|
|
|
|
def http_port(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["http_port"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def http_timeout(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("http_timeout", self.get_default("http_timeout"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@http_timeout.setter
|
|
|
|
|
def http_timeout(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["http_timeout"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2020-01-03 23:26:55 +03:00
|
|
|
@property
|
|
|
|
|
def http_use_ssl(self):
|
|
|
|
|
return self._cp_settings.get("http_use_ssl", self.get_default("http_use_ssl"))
|
|
|
|
|
|
|
|
|
|
@http_use_ssl.setter
|
|
|
|
|
def http_use_ssl(self, value):
|
|
|
|
|
self._cp_settings["http_use_ssl"] = value
|
|
|
|
|
|
2019-12-13 13:31:07 +03:00
|
|
|
@property
|
|
|
|
|
def telnet_user(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("telnet_user", self.get_default("telnet_user"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@telnet_user.setter
|
|
|
|
|
def telnet_user(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["telnet_user"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def telnet_password(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("telnet_password", self.get_default("telnet_password"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@telnet_password.setter
|
|
|
|
|
def telnet_password(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["telnet_password"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def telnet_port(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("telnet_port", self.get_default("telnet_port"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@telnet_port.setter
|
|
|
|
|
def telnet_port(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["telnet_port"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def telnet_timeout(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("telnet_timeout", self.get_default("telnet_timeout"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@telnet_timeout.setter
|
|
|
|
|
def telnet_timeout(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["telnet_timeout"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def services_path(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("services_path", self.get_default("services_path"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@services_path.setter
|
|
|
|
|
def services_path(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["services_path"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def user_bouquet_path(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("user_bouquet_path", self.get_default("user_bouquet_path"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@user_bouquet_path.setter
|
|
|
|
|
def user_bouquet_path(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["user_bouquet_path"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def satellites_xml_path(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("satellites_xml_path", self.get_default("satellites_xml_path"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@satellites_xml_path.setter
|
|
|
|
|
def satellites_xml_path(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["satellites_xml_path"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def picons_path(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._cp_settings.get("picons_path", self.get_default("picons_path"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@picons_path.setter
|
|
|
|
|
def picons_path(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._cp_settings["picons_path"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2020-03-06 11:55:34 +03:00
|
|
|
# ***** Local paths ***** #
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def profile_folder_is_default(self):
|
|
|
|
|
return self._settings.get("profile_folder_is_default", Defaults.PROFILE_FOLDER_DEFAULT.value)
|
|
|
|
|
|
|
|
|
|
@profile_folder_is_default.setter
|
|
|
|
|
def profile_folder_is_default(self, value):
|
|
|
|
|
self._settings["profile_folder_is_default"] = value
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def default_data_path(self):
|
|
|
|
|
return self._settings.get("default_data_path", DATA_PATH)
|
|
|
|
|
|
|
|
|
|
@default_data_path.setter
|
|
|
|
|
def default_data_path(self, value):
|
|
|
|
|
self._settings["default_data_path"] = value
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def data_local_path(self):
|
|
|
|
|
return self._cp_settings.get("data_local_path", self.get_default("data_local_path"))
|
|
|
|
|
|
|
|
|
|
@data_local_path.setter
|
|
|
|
|
def data_local_path(self, value):
|
|
|
|
|
self._cp_settings["data_local_path"] = value
|
|
|
|
|
|
2019-12-13 13:31:07 +03:00
|
|
|
@property
|
2019-12-22 20:42:29 +03:00
|
|
|
def picons_local_path(self):
|
|
|
|
|
return self._cp_settings.get("picons_local_path", self.get_default("picons_local_path"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2019-12-22 20:42:29 +03:00
|
|
|
@picons_local_path.setter
|
|
|
|
|
def picons_local_path(self, value):
|
|
|
|
|
self._cp_settings["picons_local_path"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
2019-12-22 20:42:29 +03:00
|
|
|
def backup_local_path(self):
|
|
|
|
|
return self._cp_settings.get("backup_local_path", self.get_default("backup_local_path"))
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2019-12-22 20:42:29 +03:00
|
|
|
@backup_local_path.setter
|
|
|
|
|
def backup_local_path(self, value):
|
|
|
|
|
self._cp_settings["backup_local_path"] = value
|
|
|
|
|
|
2020-03-06 11:55:34 +03:00
|
|
|
@property
|
|
|
|
|
def records_path(self):
|
|
|
|
|
return self._settings.get("records_path", Defaults.RECORDS_PATH.value)
|
|
|
|
|
|
|
|
|
|
@records_path.setter
|
|
|
|
|
def records_path(self, value):
|
|
|
|
|
self._settings["records_path"] = value
|
|
|
|
|
|
2020-03-09 14:53:03 +03:00
|
|
|
# ******** Streaming ********* #
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def activate_transcoding(self):
|
|
|
|
|
return self._settings.get("activate_transcoding", Defaults.ACTIVATE_TRANSCODING.value)
|
|
|
|
|
|
|
|
|
|
@activate_transcoding.setter
|
|
|
|
|
def activate_transcoding(self, value):
|
|
|
|
|
self._settings["activate_transcoding"] = value
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def active_preset(self):
|
|
|
|
|
return self._settings.get("active_preset", Defaults.ACTIVE_TRANSCODING_PRESET.value)
|
|
|
|
|
|
|
|
|
|
@active_preset.setter
|
|
|
|
|
def active_preset(self, value):
|
|
|
|
|
self._settings["active_preset"] = value
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def transcoding_presets(self):
|
|
|
|
|
return self._settings.get("transcoding_presets", get_default_transcoding_presets())
|
|
|
|
|
|
|
|
|
|
@transcoding_presets.setter
|
|
|
|
|
def transcoding_presets(self, value):
|
|
|
|
|
self._settings["transcoding_presets"] = value
|
|
|
|
|
|
2020-03-22 14:13:01 +03:00
|
|
|
@property
|
|
|
|
|
def play_streams_mode(self):
|
|
|
|
|
return PlayStreamsMode(self._settings.get("play_streams_mode", Defaults.PLAY_STREAMS_MODE.value))
|
|
|
|
|
|
|
|
|
|
@play_streams_mode.setter
|
|
|
|
|
def play_streams_mode(self, value):
|
|
|
|
|
self._settings["play_streams_mode"] = value
|
|
|
|
|
|
2020-04-02 16:50:58 +03:00
|
|
|
# *********** EPG ************ #
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def epg_options(self):
|
|
|
|
|
""" Options used by the EPG dialog. """
|
|
|
|
|
return self._cp_settings.get("epg_options", None)
|
|
|
|
|
|
|
|
|
|
@epg_options.setter
|
|
|
|
|
def epg_options(self, value):
|
|
|
|
|
self._cp_settings["epg_options"] = value
|
|
|
|
|
|
2020-03-09 14:53:03 +03:00
|
|
|
# ***** Program settings ***** #
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def backup_before_save(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("backup_before_save", Defaults.BACKUP_BEFORE_SAVE.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@backup_before_save.setter
|
|
|
|
|
def backup_before_save(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["backup_before_save"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def backup_before_downloading(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("backup_before_downloading", Defaults.BACKUP_BEFORE_DOWNLOADING.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@backup_before_downloading.setter
|
|
|
|
|
def backup_before_downloading(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["backup_before_downloading"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def v5_support(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("v5_support", Defaults.V5_SUPPORT.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@v5_support.setter
|
|
|
|
|
def v5_support(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["v5_support"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def http_api_support(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("http_api_support", Defaults.HTTP_API_SUPPORT.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@http_api_support.setter
|
|
|
|
|
def http_api_support(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["http_api_support"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def enable_yt_dl(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("enable_yt_dl", Defaults.ENABLE_YT_DL.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@enable_yt_dl.setter
|
|
|
|
|
def enable_yt_dl(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["enable_yt_dl"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def enable_send_to(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("enable_send_to", Defaults.ENABLE_SEND_TO.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@enable_send_to.setter
|
|
|
|
|
def enable_send_to(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["enable_send_to"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def use_colors(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("use_colors", Defaults.USE_COLORS.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@use_colors.setter
|
|
|
|
|
def use_colors(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["use_colors"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def new_color(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("new_color", Defaults.NEW_COLOR.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@new_color.setter
|
|
|
|
|
def new_color(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["new_color"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def extra_color(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("extra_color", Defaults.EXTRA_COLOR.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@extra_color.setter
|
|
|
|
|
def extra_color(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["extra_color"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def fav_click_mode(self):
|
2019-12-22 20:42:29 +03:00
|
|
|
return self._settings.get("fav_click_mode", Defaults.FAV_CLICK_MODE.value)
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
@fav_click_mode.setter
|
|
|
|
|
def fav_click_mode(self, value):
|
2019-12-22 20:42:29 +03:00
|
|
|
self._settings["fav_click_mode"] = value
|
2019-12-13 13:31:07 +03:00
|
|
|
|
2020-04-02 16:50:58 +03:00
|
|
|
@property
|
|
|
|
|
def language(self):
|
|
|
|
|
return self._settings.get("language", locale.getlocale()[0] or "en_US")
|
|
|
|
|
|
|
|
|
|
@language.setter
|
|
|
|
|
def language(self, value):
|
|
|
|
|
self._settings["language"] = value
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def load_last_config(self):
|
|
|
|
|
return self._settings.get("load_last_config", False)
|
|
|
|
|
|
|
|
|
|
@load_last_config.setter
|
|
|
|
|
def load_last_config(self, value):
|
|
|
|
|
self._settings["load_last_config"] = value
|
|
|
|
|
|
2020-03-22 14:13:01 +03:00
|
|
|
@property
|
|
|
|
|
def is_darwin(self):
|
|
|
|
|
return IS_DARWIN
|
|
|
|
|
|
2019-12-13 13:31:07 +03:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
pass
|