pull/997/head
Louis Vézina 5 years ago
parent 106528977a
commit c1c7ba5dc3

@ -157,6 +157,12 @@ base_url = settings.general.base_url
def save_settings(settings_items):
from database import database
configure_debug = False
configure_captcha = False
update_schedule = False
configure_proxy = False
for key, value in settings_items:
# Intercept database stored settings
if key == 'enabled_languages':
@ -184,12 +190,40 @@ def save_settings(settings_items):
if key == 'settings-auth-password':
value = hashlib.md5(value.encode('utf-8')).hexdigest()
if key == 'settings-general-debug':
configure_debug = True
if key in ['settings-general-anti_captcha_provider', 'settings-anticaptcha-anti_captcha_key',
'settings-deathbycaptcha-username', 'settings-deathbycaptcha-password']:
configure_captcha = True
if key == 'update_schedule':
update_schedule = True
if key in ['settings-proxy-type', 'settings-proxy-url', 'settings-proxy-port', 'settings-proxy-username',
'settings-proxy-password']:
configure_proxy = True
if settings_keys[0] == 'settings':
settings[settings_keys[1]][settings_keys[2]] = str(value)
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle)
# Reconfigure Bazarr to reflect changes
if configure_debug:
from logger import configure_logging
configure_logging(settings.general.getboolean('debug') or args.debug)
if configure_captcha:
configure_captcha_func()
if update_schedule:
from scheduler import update_configurable_tasks
update_configurable_tasks()
if configure_proxy:
configure_proxy_func()
def url_sonarr():
@ -253,3 +287,28 @@ def url_radarr_short():
settings.radarr.base_url = settings.radarr.base_url[:-1]
return protocol_radarr + "://" + settings.radarr.ip + ":" + settings.radarr.port
def configure_captcha_func():
# set anti-captcha provider and key
if settings.general.anti_captcha_provider == 'anti-captcha' and settings.anticaptcha.anti_captcha_key != "":
os.environ["ANTICAPTCHA_CLASS"] = 'AntiCaptchaProxyLess'
os.environ["ANTICAPTCHA_ACCOUNT_KEY"] = str(settings.anticaptcha.anti_captcha_key)
elif settings.general.anti_captcha_provider == 'death-by-captcha' and settings.deathbycaptcha.username != "" and \
settings.deathbycaptcha.password != "":
os.environ["ANTICAPTCHA_CLASS"] = 'DeathByCaptchaProxyLess'
os.environ["ANTICAPTCHA_ACCOUNT_KEY"] = str(':'.join(
{settings.deathbycaptcha.username, settings.deathbycaptcha.password}))
else:
os.environ["ANTICAPTCHA_CLASS"] = ''
def configure_proxy_func():
if settings.proxy.type != 'None':
if settings.proxy.username != '' and settings.proxy.password != '':
proxy = settings.proxy.type + '://' + settings.proxy.username + ':' + settings.proxy.password + '@' + \
settings.proxy.url + ':' + settings.proxy.port
else:
proxy = settings.proxy.type + '://' + settings.proxy.url + ':' + settings.proxy.port
os.environ['HTTP_PROXY'] = str(proxy)
os.environ['HTTPS_PROXY'] = str(proxy)
os.environ['NO_PROXY'] = str(settings.proxy.exclude)

@ -5,7 +5,7 @@ import time
import rarfile
from cork import Cork
from config import settings
from config import settings, configure_captcha_func
from get_args import args
from logger import configure_logging
from helper import create_path_mapping_dict
@ -18,15 +18,7 @@ import datetime
os.environ["SZ_USER_AGENT"] = "Bazarr/1"
# set anti-captcha provider and key
if settings.general.anti_captcha_provider == 'anti-captcha' and settings.anticaptcha.anti_captcha_key != "":
os.environ["ANTICAPTCHA_CLASS"] = 'AntiCaptchaProxyLess'
os.environ["ANTICAPTCHA_ACCOUNT_KEY"] = str(settings.anticaptcha.anti_captcha_key)
elif settings.general.anti_captcha_provider == 'death-by-captcha' and settings.deathbycaptcha.username != "" and settings.deathbycaptcha.password != "":
os.environ["ANTICAPTCHA_CLASS"] = 'DeathByCaptchaProxyLess'
os.environ["ANTICAPTCHA_ACCOUNT_KEY"] = str(':'.join(
{settings.deathbycaptcha.username, settings.deathbycaptcha.password}))
else:
os.environ["ANTICAPTCHA_CLASS"] = ''
configure_captcha_func()
# Check if args.config_dir exist
if not os.path.exists(args.config_dir):

@ -11,11 +11,9 @@ import sys
import libs
import io
import pretty
import ast
import hashlib
import warnings
import queueconfig
import apprise
import requests
import calendar
@ -23,7 +21,7 @@ import calendar
from get_args import args
from logger import empty_log
from config import settings, url_sonarr, url_radarr, url_radarr_short, url_sonarr_short, base_url
from config import settings, url_sonarr, url_radarr, url_radarr_short, url_sonarr_short, base_url, configure_proxy_func
from init import *
import logging
@ -62,15 +60,7 @@ scheduler = Scheduler()
if args.release_update:
check_and_apply_update()
if settings.proxy.type != 'None':
if settings.proxy.username != '' and settings.proxy.password != '':
proxy = settings.proxy.type + '://' + settings.proxy.username + ':' + settings.proxy.password + '@' + \
settings.proxy.url + ':' + settings.proxy.port
else:
proxy = settings.proxy.type + '://' + settings.proxy.url + ':' + settings.proxy.port
os.environ['HTTP_PROXY'] = str(proxy)
os.environ['HTTPS_PROXY'] = str(proxy)
os.environ['NO_PROXY'] = str(settings.proxy.exclude)
configure_proxy_func()
# Reset restart required warning on start
database.execute("UPDATE system SET configured='0', updated='0'")

@ -47,14 +47,14 @@ class Scheduler:
self.aps_scheduler.add_listener(task_listener_remove, EVENT_JOB_EXECUTED | EVENT_JOB_ERROR)
# configure all tasks
self.__sonarr_update_task()
self.__radarr_update_task()
self.__cache_cleanup_task()
self.update_configurable_tasks()
self.aps_scheduler.start()
def update_configurable_tasks(self):
self.__sonarr_update_task()
self.__radarr_update_task()
self.__sonarr_full_update_task()
self.__radarr_full_update_task()
self.__update_bazarr_task()
@ -142,17 +142,20 @@ class Scheduler:
def __sonarr_update_task(self):
if settings.general.getboolean('use_sonarr'):
self.aps_scheduler.add_job(
update_series, IntervalTrigger(minutes=1), max_instances=1, coalesce=True, misfire_grace_time=15,
id='update_series', name='Update Series list from Sonarr')
update_series, IntervalTrigger(minutes=int(settings.sonarr.series_sync)), max_instances=1,
coalesce=True, misfire_grace_time=15, id='update_series', name='Update Series list from Sonarr',
replace_existing=True)
self.aps_scheduler.add_job(
sync_episodes, IntervalTrigger(minutes=5), max_instances=1, coalesce=True, misfire_grace_time=15,
id='sync_episodes', name='Sync episodes with Sonarr')
sync_episodes, IntervalTrigger(minutes=int(settings.sonarr.episodes_sync)), max_instances=1,
coalesce=True, misfire_grace_time=15, id='sync_episodes', name='Sync episodes with Sonarr',
replace_existing=True)
def __radarr_update_task(self):
if settings.general.getboolean('use_radarr'):
self.aps_scheduler.add_job(
update_movies, IntervalTrigger(minutes=5), max_instances=1, coalesce=True, misfire_grace_time=15,
id='update_movies', name='Update Movie list from Radarr')
update_movies, IntervalTrigger(minutes=int(settings.radarr.movies_sync)), max_instances=1,
coalesce=True, misfire_grace_time=15, id='update_movies', name='Update Movie list from Radarr',
replace_existing=True)
def __cache_cleanup_task(self):
self.aps_scheduler.add_job(cache_maintenance, IntervalTrigger(hours=24), max_instances=1, coalesce=True,
@ -228,7 +231,7 @@ class Scheduler:
name='Search for wanted Series Subtitles', replace_existing=True)
if settings.general.getboolean('use_radarr'):
self.aps_scheduler.add_job(
wanted_search_missing_subtitles_movies, IntervalTrigger(hours=int(settings.general.wanted_search_frequency)),
wanted_search_missing_subtitles_movies, IntervalTrigger(hours=int(settings.general.wanted_search_frequency_movie)),
max_instances=1, coalesce=True, misfire_grace_time=15, id='wanted_search_missing_subtitles_movies',
name='Search for wanted Movies Subtitles', replace_existing=True)

@ -79,7 +79,6 @@
<option value="form">Form</option>
</select>
<label for="settings-auth-type">Require Username and Password to access Bazarr</label><br>
{# <label class="restart">Requires restart to take effect</label>#}
</div>
</div>
<div id="authentication_div">
@ -128,7 +127,6 @@
<option value="socks4">Socks4</option>
<option value="socks5">Socks5</option>
</select><br>
<label class="restart">Requires restart to take effect</label>
</div>
</div>
<div id="proxy_div">

@ -246,12 +246,13 @@
$('#settings-radarr-full_update_day').val('{{settings.radarr.full_update_day}}').trigger('change');
$('#settings-radarr-full_update_hour').val('{{settings.radarr.full_update_hour}}').trigger('change');
$('#settings-general-wanted_search_frequency').val('{{settings.general.wanted_search_frequency}}').trigger('change');
$('#settings-general-wanted_search_frequency_movie').val('{{settings.general.wanted_search_frequency}}').trigger('change');
$('#settings-general-wanted_search_frequency_movie').val('{{settings.general.wanted_search_frequency_movie}}').trigger('change');
$('#settings-general-upgrade_frequency').val('{{settings.general.upgrade_frequency}}').trigger('change');
$('.selectpicker').selectpicker('refresh')
$('#save_button').on('click', function() {
var formdata = new FormData(document.getElementById("settings_form"));
formdata.append('update_schedule', 'true');
// Make sure all checkbox input are sent with true/false value
$('input[type=checkbox]').each(function () {

Loading…
Cancel
Save