Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b865dd48a0 | |||
| d32c891611 |
@@ -70,7 +70,7 @@ def Start():
|
||||
ValidatePrefs()
|
||||
Log.Debug(config.full_version)
|
||||
|
||||
if config.initialized and not config.permissions_ok:
|
||||
if not config.permissions_ok:
|
||||
Log.Error("Insufficient permissions on library folders:")
|
||||
for title, path in config.missing_permissions:
|
||||
Log.Error("Insufficient permissions on library %s, folder: %s" % (title, path))
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# coding=utf-8
|
||||
|
||||
import time
|
||||
|
||||
from subzero.constants import PREFIX, TITLE, ART, START_DELAY
|
||||
from subzero.constants import PREFIX, TITLE, ART
|
||||
from support.config import config
|
||||
from support.helpers import pad_title, timestamp, df, display_language
|
||||
from support.scheduler import scheduler
|
||||
@@ -29,56 +27,45 @@ def fatality(randomize=None, force_title=None, header=None, message=None, only_r
|
||||
no_history=no_history,
|
||||
replace_parent=replace_parent, no_cache=True)
|
||||
|
||||
if config.initialized:
|
||||
# always re-check permissions
|
||||
config.refresh_permissions_status()
|
||||
# always re-check permissions
|
||||
config.refresh_permissions_status()
|
||||
|
||||
# always re-check enabled sections
|
||||
config.refresh_enabled_sections()
|
||||
# always re-check enabled sections
|
||||
config.refresh_enabled_sections()
|
||||
|
||||
if config.lock_menu and not config.pin_correct:
|
||||
if config.lock_menu and not config.pin_correct:
|
||||
oc.add(DirectoryObject(
|
||||
key=Callback(PinMenu, randomize=timestamp()),
|
||||
title=pad_title(_("Enter PIN")),
|
||||
summary=_("The owner has restricted the access to this menu. Please enter the correct pin"),
|
||||
))
|
||||
return oc
|
||||
|
||||
if not config.permissions_ok and config.missing_permissions:
|
||||
if not isinstance(config.missing_permissions, list):
|
||||
oc.add(DirectoryObject(
|
||||
key=Callback(PinMenu, randomize=timestamp()),
|
||||
title=pad_title(_("Enter PIN")),
|
||||
summary=_("The owner has restricted the access to this menu. Please enter the correct pin"),
|
||||
key=Callback(fatality, randomize=timestamp()),
|
||||
title=pad_title(_("Insufficient permissions")),
|
||||
summary=config.missing_permissions,
|
||||
))
|
||||
return oc
|
||||
|
||||
if not config.permissions_ok and config.missing_permissions:
|
||||
if not isinstance(config.missing_permissions, list):
|
||||
else:
|
||||
for title, path in config.missing_permissions:
|
||||
oc.add(DirectoryObject(
|
||||
key=Callback(fatality, randomize=timestamp()),
|
||||
title=pad_title(_("Insufficient permissions")),
|
||||
summary=config.missing_permissions,
|
||||
summary=_("Insufficient permissions on library %(title)s, folder: %(path)s",
|
||||
title=title,
|
||||
path=path),
|
||||
))
|
||||
else:
|
||||
for title, path in config.missing_permissions:
|
||||
oc.add(DirectoryObject(
|
||||
key=Callback(fatality, randomize=timestamp()),
|
||||
title=pad_title(_("Insufficient permissions")),
|
||||
summary=_("Insufficient permissions on library %(title)s, folder: %(path)s",
|
||||
title=title,
|
||||
path=path),
|
||||
))
|
||||
return oc
|
||||
return oc
|
||||
|
||||
if not config.enabled_sections:
|
||||
oc.add(DirectoryObject(
|
||||
key=Callback(fatality, randomize=timestamp()),
|
||||
title=pad_title(_("I'm not enabled!")),
|
||||
summary=_("Please enable me for some of your libraries in your server settings; currently I do nothing"),
|
||||
))
|
||||
return oc
|
||||
else:
|
||||
if config.delay_system_queries:
|
||||
elapsed = int(START_DELAY - (time.time() - config.start_delay_elapsed))
|
||||
oc.add(DirectoryObject(
|
||||
key=Callback(fatality, randomize=timestamp()),
|
||||
title=pad_title(_("Finalizing ..."
|
||||
if elapsed <= 0 else "Initializing, please wait %s seconds ..." % elapsed)),
|
||||
summary=_("Start is delayed by %s seconds to cope with a slow PMS" % int(START_DELAY)),
|
||||
))
|
||||
return oc
|
||||
if not config.enabled_sections:
|
||||
oc.add(DirectoryObject(
|
||||
key=Callback(fatality, randomize=timestamp()),
|
||||
title=pad_title(_("I'm not enabled!")),
|
||||
summary=_("Please enable me for some of your libraries in your server settings; currently I do nothing"),
|
||||
))
|
||||
return oc
|
||||
|
||||
if not only_refresh:
|
||||
if Dict["current_refresh_state"]:
|
||||
|
||||
@@ -7,7 +7,6 @@ import sys
|
||||
import rarfile
|
||||
import jstyleson
|
||||
import datetime
|
||||
import time
|
||||
|
||||
import subliminal
|
||||
import subliminal_patch
|
||||
@@ -23,7 +22,7 @@ from subliminal.cli import MutexLock
|
||||
from subzero.lib.io import FileIO, get_viable_encoding
|
||||
from subzero.lib.dict import Dicked
|
||||
from subzero.util import get_root_path
|
||||
from subzero.constants import PLUGIN_NAME, PLUGIN_IDENTIFIER, MOVIE, SHOW, MEDIA_TYPE_TO_STRING, START_DELAY
|
||||
from subzero.constants import PLUGIN_NAME, PLUGIN_IDENTIFIER, MOVIE, SHOW, MEDIA_TYPE_TO_STRING
|
||||
from subzero.prefs import get_user_prefs, update_user_prefs
|
||||
from dogpile.cache.region import register_backend as register_cache_backend
|
||||
from lib import Plex
|
||||
@@ -149,15 +148,10 @@ class Config(object):
|
||||
unrar = None
|
||||
adv_cfg_path = None
|
||||
use_custom_dns = False
|
||||
delay_system_queries = False
|
||||
|
||||
store_recently_played_amount = 40
|
||||
|
||||
initialized = False
|
||||
system_queries_done = False
|
||||
base_init_done = False
|
||||
system_queries_timer = None
|
||||
start_delay_elapsed = None
|
||||
|
||||
def initialize(self):
|
||||
self.libraries_root = os.path.abspath(os.path.join(get_root_path(), ".."))
|
||||
@@ -175,7 +169,6 @@ class Config(object):
|
||||
self.set_log_paths()
|
||||
self.app_support_path = Core.app_support_path
|
||||
self.data_path = getattr(Data, "_core").storage.data_path
|
||||
self.delay_system_queries = os.path.isfile(os.path.join(self.data_path, "delayed_start"))
|
||||
self.data_items_path = os.path.join(self.data_path, "DataItems")
|
||||
self.universal_plex_token = self.get_universal_plex_token()
|
||||
self.plex_token = os.environ.get("PLEXTOKEN", self.universal_plex_token)
|
||||
@@ -212,25 +205,8 @@ class Config(object):
|
||||
self.missing_permissions = []
|
||||
self.include_exclude_sz_files = cast_bool(Prefs["subtitles.include_exclude_fs"])
|
||||
self.include_exclude_paths = self.parse_include_exclude_paths()
|
||||
|
||||
self.system_queries_done = False
|
||||
|
||||
def system_queries():
|
||||
self.enabled_sections = self.check_enabled_sections()
|
||||
self.permissions_ok = self.check_permissions()
|
||||
self.system_queries_done = True
|
||||
self.system_queries_timer = None
|
||||
if self.base_init_done:
|
||||
self.initialized = True
|
||||
|
||||
if self.delay_system_queries:
|
||||
if not self.system_queries_timer or not self.system_queries_timer.is_alive():
|
||||
Log.Info("Waiting %s seconds until querying the system endpoints of your PMS" % START_DELAY)
|
||||
Thread.CreateTimer(START_DELAY, system_queries)
|
||||
self.start_delay_elapsed = time.time()
|
||||
else:
|
||||
system_queries()
|
||||
|
||||
self.enabled_sections = self.check_enabled_sections()
|
||||
self.permissions_ok = self.check_permissions()
|
||||
self.notify_executable = self.check_notify_executable()
|
||||
self.remove_hi = cast_bool(Prefs['subtitles.remove_hi'])
|
||||
self.remove_tags = cast_bool(Prefs['subtitles.remove_tags'])
|
||||
@@ -252,11 +228,7 @@ class Config(object):
|
||||
self.embedded_auto_extract = cast_bool(Prefs["subtitles.embedded.autoextract"])
|
||||
self.ietf_as_alpha3 = cast_bool(Prefs["subtitles.language.ietf_normalize"])
|
||||
self.use_custom_dns = cast_bool(Prefs['use_custom_dns'])
|
||||
|
||||
self.base_init_done = True
|
||||
|
||||
if self.system_queries_done:
|
||||
self.initialized = True
|
||||
self.initialized = True
|
||||
|
||||
def migrate_prefs(self):
|
||||
config_version = 0 if "config_version" not in Dict else Dict["config_version"]
|
||||
|
||||
@@ -286,6 +286,7 @@ def notify_executable(exe_info, videos, subtitles, storage):
|
||||
"subtitle_language", "subtitle_path", "subtitle_filename", "provider", "score", "storage", "series_id",
|
||||
"series", "title", "section", "filename", "path", "folder", "season_id", "type", "id", "season"
|
||||
)
|
||||
to_clean = ("PYTHONPATH", "PYTHONHOME")
|
||||
exe, arguments = exe_info
|
||||
for video, video_subtitles in subtitles.items():
|
||||
for subtitle in video_subtitles:
|
||||
@@ -321,14 +322,18 @@ def notify_executable(exe_info, videos, subtitles, storage):
|
||||
env = dict(os.environ)
|
||||
|
||||
# clean out any Plex-PYTHONPATH that may bleed through the spawned process
|
||||
if "PYTHONPATH" in env and "plex" in env["PYTHONPATH"].lower():
|
||||
del env["PYTHONPATH"]
|
||||
for v in to_clean:
|
||||
if v in env and "plex" in env[v].lower():
|
||||
del env[v]
|
||||
|
||||
try:
|
||||
proc = subprocess.Popen(quote_args([exe] + prepared_arguments), stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True, env=env, cwd=os.path.dirname(exe))
|
||||
output, errors = proc.communicate()
|
||||
|
||||
Log.Info("Executable: %s, Env: %s, Exe_info: %s, Output: %s, Errors: %s"
|
||||
% (quote_args([exe] + prepared_arguments), env, exe_info, output, errors))
|
||||
|
||||
if proc.returncode == 1:
|
||||
Log.Error(u"Calling %s with args %s failed: output:\n%s, error:\n%s", exe, prepared_arguments,
|
||||
output, errors)
|
||||
|
||||
@@ -15,7 +15,6 @@ ICON = 'icon-default.jpg'
|
||||
ICON_SUB = 'icon-sub.jpg'
|
||||
|
||||
DEFAULT_TIMEOUT = 15
|
||||
START_DELAY = 30.0
|
||||
|
||||
|
||||
# media types as on https://github.com/Arcanemagus/plex-api/wiki/MediaTypes
|
||||
|
||||
Reference in New Issue
Block a user