From e0b98337b2e12dea3b6e2da6882895ff391a2256 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Wed, 26 Feb 2020 21:08:52 -0500
Subject: [PATCH] WIP
---
bazarr/main.py | 418 +-------
views/_main.html | 2 +-
views/settings.html | 216 ----
views/settings_general.html | 935 ------------------
views/settingsgeneral.html | 251 +++++
...ations.html => settingsnotifications.html} | 0
...ttings_radarr.html => settingsradarr.html} | 0
...ttings_sonarr.html => settingssonarr.html} | 0
..._subtitles.html => settingssubtitles.html} | 0
views/system.html | 564 -----------
10 files changed, 255 insertions(+), 2131 deletions(-)
delete mode 100644 views/settings.html
delete mode 100644 views/settings_general.html
create mode 100644 views/settingsgeneral.html
rename views/{settings_notifications.html => settingsnotifications.html} (100%)
rename views/{settings_radarr.html => settingsradarr.html} (100%)
rename views/{settings_sonarr.html => settingssonarr.html} (100%)
rename views/{settings_subtitles.html => settingssubtitles.html} (100%)
delete mode 100644 views/system.html
diff --git a/bazarr/main.py b/bazarr/main.py
index 753290d1d..2f827384f 100644
--- a/bazarr/main.py
+++ b/bazarr/main.py
@@ -586,422 +586,10 @@ def wantedmovies():
return render_template('wantedmovies.html')
-@app.route('/settings/')
+@app.route('/settingsgeneral/')
@login_required
-def _settings():
-
-
- settings_languages = database.execute("SELECT * FROM table_settings_languages ORDER BY name")
- settings_providers = sorted(provider_manager.names())
- settings_notifier = database.execute("SELECT * FROM table_settings_notifier ORDER BY name")
-
- return render_template('settings.html', bazarr_version=bazarr_version, settings=settings, settings_languages=settings_languages,
- settings_providers=settings_providers, settings_notifier=settings_notifier, base_url=base_url,
- current_port=settings.general.port, ast=ast, args=args, sys=sys)
-
-
-@app.route('/save_settings', methods=['POST'])
-@login_required
-def save_settings():
-
- ref = request.environ['HTTP_REFERER']
-
- settings_general_ip = request.form.get('settings_general_ip')
- settings_general_port = request.form.get('settings_general_port')
- settings_general_baseurl = request.form.get('settings_general_baseurl')
- if not settings_general_baseurl.endswith('/'):
- settings_general_baseurl += '/'
- settings_general_debug = request.form.get('settings_general_debug')
- if settings_general_debug is None:
- settings_general_debug = 'False'
- else:
- settings_general_debug = 'True'
- settings_general_chmod_enabled = request.form.get('settings_general_chmod_enabled')
- if settings_general_chmod_enabled is None:
- settings_general_chmod_enabled = 'False'
- else:
- settings_general_chmod_enabled = 'True'
- settings_general_chmod = request.form.get('settings_general_chmod')
- settings_general_sourcepath = request.form.getlist('settings_general_sourcepath')
- settings_general_destpath = request.form.getlist('settings_general_destpath')
- settings_general_pathmapping = []
- settings_general_pathmapping.extend([list(a) for a in zip(settings_general_sourcepath, settings_general_destpath)])
- settings_general_sourcepath_movie = request.form.getlist('settings_general_sourcepath_movie')
- settings_general_destpath_movie = request.form.getlist('settings_general_destpath_movie')
- settings_general_pathmapping_movie = []
- settings_general_pathmapping_movie.extend(
- [list(a) for a in zip(settings_general_sourcepath_movie, settings_general_destpath_movie)])
- settings_general_branch = request.form.get('settings_general_branch')
- settings_general_automatic = request.form.get('settings_general_automatic')
- if settings_general_automatic is None:
- settings_general_automatic = 'False'
- else:
- settings_general_automatic = 'True'
- settings_general_update_restart = request.form.get('settings_general_update_restart')
- if settings_general_update_restart is None:
- settings_general_update_restart = 'False'
- else:
- settings_general_update_restart = 'True'
- settings_analytics_enabled = request.form.get('settings_analytics_enabled')
- if settings_analytics_enabled is None:
- settings_analytics_enabled = 'False'
- else:
- settings_analytics_enabled = 'True'
- settings_general_single_language = request.form.get('settings_general_single_language')
- if settings_general_single_language is None:
- settings_general_single_language = 'False'
- else:
- settings_general_single_language = 'True'
- settings_general_wanted_search_frequency = request.form.get('settings_general_wanted_search_frequency')
- settings_general_scenename = request.form.get('settings_general_scenename')
- if settings_general_scenename is None:
- settings_general_scenename = 'False'
- else:
- settings_general_scenename = 'True'
- settings_general_embedded = request.form.get('settings_general_embedded')
- if settings_general_embedded is None:
- settings_general_embedded = 'False'
- else:
- settings_general_embedded = 'True'
- settings_general_utf8_encode = request.form.get('settings_general_utf8_encode')
- if settings_general_utf8_encode is None:
- settings_general_utf8_encode = 'False'
- else:
- settings_general_utf8_encode = 'True'
- settings_general_ignore_pgs = request.form.get('settings_general_ignore_pgs')
- if settings_general_ignore_pgs is None:
- settings_general_ignore_pgs = 'False'
- else:
- settings_general_ignore_pgs = 'True'
- settings_general_adaptive_searching = request.form.get('settings_general_adaptive_searching')
- if settings_general_adaptive_searching is None:
- settings_general_adaptive_searching = 'False'
- else:
- settings_general_adaptive_searching = 'True'
- settings_general_multithreading = request.form.get('settings_general_multithreading')
- if settings_general_multithreading is None:
- settings_general_multithreading = 'False'
- else:
- settings_general_multithreading = 'True'
- settings_general_minimum_score = request.form.get('settings_general_minimum_score')
- settings_general_minimum_score_movies = request.form.get('settings_general_minimum_score_movies')
- settings_general_use_postprocessing = request.form.get('settings_general_use_postprocessing')
- if settings_general_use_postprocessing is None:
- settings_general_use_postprocessing = 'False'
- else:
- settings_general_use_postprocessing = 'True'
- settings_general_postprocessing_cmd = request.form.get('settings_general_postprocessing_cmd')
- settings_general_use_sonarr = request.form.get('settings_general_use_sonarr')
- if settings_general_use_sonarr is None:
- settings_general_use_sonarr = 'False'
- else:
- settings_general_use_sonarr = 'True'
- settings_general_use_radarr = request.form.get('settings_general_use_radarr')
- if settings_general_use_radarr is None:
- settings_general_use_radarr = 'False'
- else:
- settings_general_use_radarr = 'True'
- settings_page_size = request.form.get('settings_page_size')
- settings_subfolder = request.form.get('settings_subfolder')
- settings_subfolder_custom = request.form.get('settings_subfolder_custom')
- settings_upgrade_subs = request.form.get('settings_upgrade_subs')
- if settings_upgrade_subs is None:
- settings_upgrade_subs = 'False'
- else:
- settings_upgrade_subs = 'True'
- settings_upgrade_subs_frequency = request.form.get('settings_upgrade_subs_frequency')
- settings_days_to_upgrade_subs = request.form.get('settings_days_to_upgrade_subs')
- settings_upgrade_manual = request.form.get('settings_upgrade_manual')
- if settings_upgrade_manual is None:
- settings_upgrade_manual = 'False'
- else:
- settings_upgrade_manual = 'True'
- settings_anti_captcha_provider = request.form.get('settings_anti_captcha_provider')
- settings_anti_captcha_key = request.form.get('settings_anti_captcha_key')
- settings_death_by_captcha_username = request.form.get('settings_death_by_captcha_username')
- settings_death_by_captcha_password = request.form.get('settings_death_by_captcha_password')
-
- before = (str(settings.general.ip), int(settings.general.port), str(settings.general.base_url),
- str(settings.general.path_mappings), str(settings.general.getboolean('use_sonarr')),
- str(settings.general.getboolean('use_radarr')), str(settings.general.path_mappings_movie))
- after = (str(settings_general_ip), int(settings_general_port), str(settings_general_baseurl),
- str(settings_general_pathmapping), str(settings_general_use_sonarr),
- str(settings_general_use_radarr), str(settings_general_pathmapping_movie))
-
- settings.general.ip = str(settings_general_ip)
- settings.general.port = str(settings_general_port)
- settings.general.base_url = str(settings_general_baseurl)
- settings.general.path_mappings = str(settings_general_pathmapping)
- settings.general.debug = str(settings_general_debug)
- settings.general.chmod_enabled = str(settings_general_chmod_enabled)
- settings.general.chmod = str(settings_general_chmod)
- settings.general.branch = str(settings_general_branch)
- settings.general.auto_update = str(settings_general_automatic)
- settings.general.update_restart = str(settings_general_update_restart)
- settings.analytics.enabled = str(settings_analytics_enabled)
- settings.general.single_language = str(settings_general_single_language)
- settings.general.minimum_score = str(settings_general_minimum_score)
- settings.general.wanted_search_frequency = str(settings_general_wanted_search_frequency)
- settings.general.use_scenename = str(settings_general_scenename)
- settings.general.use_postprocessing = str(settings_general_use_postprocessing)
- settings.general.postprocessing_cmd = str(settings_general_postprocessing_cmd)
- settings.general.use_sonarr = str(settings_general_use_sonarr)
- settings.general.use_radarr = str(settings_general_use_radarr)
- settings.general.path_mappings_movie = str(settings_general_pathmapping_movie)
- settings.general.page_size = str(settings_page_size)
- settings.general.subfolder = str(settings_subfolder)
- if settings.general.subfolder == 'current':
- settings.general.subfolder_custom = ''
- else:
- settings.general.subfolder_custom = str(settings_subfolder_custom)
- settings.general.upgrade_subs = str(settings_upgrade_subs)
- settings.general.upgrade_frequency = str(settings_upgrade_subs_frequency)
- settings.general.days_to_upgrade_subs = str(settings_days_to_upgrade_subs)
- settings.general.upgrade_manual = str(settings_upgrade_manual)
- settings.general.anti_captcha_provider = str(settings_anti_captcha_provider)
- settings.anticaptcha.anti_captcha_key = str(settings_anti_captcha_key)
- settings.deathbycaptcha.username = str(settings_death_by_captcha_username)
- settings.deathbycaptcha.password = str(settings_death_by_captcha_password)
-
- # set anti-captcha provider and key
- if settings.general.anti_captcha_provider == 'anti-captcha':
- 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':
- os.environ["ANTICAPTCHA_CLASS"] = 'DeathByCaptchaProxyLess'
- os.environ["ANTICAPTCHA_ACCOUNT_KEY"] = str(':'.join(
- {settings.deathbycaptcha.username, settings.deathbycaptcha.password}))
- else:
- os.environ["ANTICAPTCHA_CLASS"] = ''
-
- settings.general.minimum_score_movie = str(settings_general_minimum_score_movies)
- settings.general.use_embedded_subs = str(settings_general_embedded)
- settings.general.utf8_encode = str(settings_general_utf8_encode)
- settings.general.ignore_pgs_subs = str(settings_general_ignore_pgs)
- settings.general.adaptive_searching = str(settings_general_adaptive_searching)
- settings.general.multithreading = str(settings_general_multithreading)
-
- if after != before:
- configured()
-
- settings_proxy_type = request.form.get('settings_proxy_type')
- settings_proxy_url = request.form.get('settings_proxy_url')
- settings_proxy_port = request.form.get('settings_proxy_port')
- settings_proxy_username = request.form.get('settings_proxy_username')
- settings_proxy_password = request.form.get('settings_proxy_password')
- settings_proxy_exclude = request.form.get('settings_proxy_exclude')
-
- before_proxy_password = (str(settings.proxy.type), str(settings.proxy.exclude))
- if before_proxy_password[0] != settings_proxy_type:
- configured()
- if before_proxy_password[1] == settings_proxy_password:
- settings.proxy.type = str(settings_proxy_type)
- settings.proxy.url = str(settings_proxy_url)
- settings.proxy.port = str(settings_proxy_port)
- settings.proxy.username = str(settings_proxy_username)
- settings.proxy.exclude = str(settings_proxy_exclude)
- else:
- settings.proxy.type = str(settings_proxy_type)
- settings.proxy.url = str(settings_proxy_url)
- settings.proxy.port = str(settings_proxy_port)
- settings.proxy.username = str(settings_proxy_username)
- settings.proxy.password = str(settings_proxy_password)
- settings.proxy.exclude = str(settings_proxy_exclude)
-
- settings_auth_type = request.form.get('settings_auth_type')
- settings_auth_username = request.form.get('settings_auth_username')
- settings_auth_password = request.form.get('settings_auth_password')
-
- if settings.auth.type != settings_auth_type:
- configured()
- if settings.auth.password == settings_auth_password:
- settings.auth.type = str(settings_auth_type)
- settings.auth.username = str(settings_auth_username)
- else:
- settings.auth.type = str(settings_auth_type)
- settings.auth.username = str(settings_auth_username)
- settings.auth.password = hashlib.md5(settings_auth_password.encode('utf-8')).hexdigest()
- settings.auth.apikey = request.form.get('settings_auth_apikey')
-
- settings_sonarr_ip = request.form.get('settings_sonarr_ip')
- settings_sonarr_port = request.form.get('settings_sonarr_port')
- settings_sonarr_baseurl = request.form.get('settings_sonarr_baseurl')
- settings_sonarr_ssl = request.form.get('settings_sonarr_ssl')
- if settings_sonarr_ssl is None:
- settings_sonarr_ssl = 'False'
- else:
- settings_sonarr_ssl = 'True'
- settings_sonarr_apikey = request.form.get('settings_sonarr_apikey')
- settings_sonarr_only_monitored = request.form.get('settings_sonarr_only_monitored')
- if settings_sonarr_only_monitored is None:
- settings_sonarr_only_monitored = 'False'
- else:
- settings_sonarr_only_monitored = 'True'
- settings_sonarr_sync = request.form.get('settings_sonarr_sync')
- settings_sonarr_sync_day = request.form.get('settings_sonarr_sync_day')
- settings_sonarr_sync_hour = request.form.get('settings_sonarr_sync_hour')
-
- settings.sonarr.ip = str(settings_sonarr_ip)
- settings.sonarr.port = str(settings_sonarr_port)
- settings.sonarr.base_url = str(settings_sonarr_baseurl)
- settings.sonarr.ssl = str(settings_sonarr_ssl)
- settings.sonarr.apikey = str(settings_sonarr_apikey)
- settings.sonarr.only_monitored = str(settings_sonarr_only_monitored)
- settings.sonarr.full_update = str(settings_sonarr_sync)
- settings.sonarr.full_update_day = str(settings_sonarr_sync_day)
- settings.sonarr.full_update_hour = str(settings_sonarr_sync_hour)
-
- settings_radarr_ip = request.form.get('settings_radarr_ip')
- settings_radarr_port = request.form.get('settings_radarr_port')
- settings_radarr_baseurl = request.form.get('settings_radarr_baseurl')
- settings_radarr_ssl = request.form.get('settings_radarr_ssl')
- if settings_radarr_ssl is None:
- settings_radarr_ssl = 'False'
- else:
- settings_radarr_ssl = 'True'
- settings_radarr_apikey = request.form.get('settings_radarr_apikey')
- settings_radarr_only_monitored = request.form.get('settings_radarr_only_monitored')
- if settings_radarr_only_monitored is None:
- settings_radarr_only_monitored = 'False'
- else:
- settings_radarr_only_monitored = 'True'
- settings_radarr_sync = request.form.get('settings_radarr_sync')
- settings_radarr_sync_day = request.form.get('settings_radarr_sync_day')
- settings_radarr_sync_hour = request.form.get('settings_radarr_sync_hour')
-
- settings.radarr.ip = str(settings_radarr_ip)
- settings.radarr.port = str(settings_radarr_port)
- settings.radarr.base_url = str(settings_radarr_baseurl)
- settings.radarr.ssl = str(settings_radarr_ssl)
- settings.radarr.apikey = str(settings_radarr_apikey)
- settings.radarr.only_monitored = str(settings_radarr_only_monitored)
- settings.radarr.full_update = str(settings_radarr_sync)
- settings.radarr.full_update_day = str(settings_radarr_sync_day)
- settings.radarr.full_update_hour = str(settings_radarr_sync_hour)
-
- settings_subliminal_providers = request.form.getlist('settings_subliminal_providers')
- settings.general.enabled_providers = u'' if not settings_subliminal_providers else ','.join(
- settings_subliminal_providers)
-
- settings_addic7ed_random_agents = request.form.get('settings_addic7ed_random_agents')
- if settings_addic7ed_random_agents is None:
- settings_addic7ed_random_agents = 'False'
- else:
- settings_addic7ed_random_agents = 'True'
-
- settings_opensubtitles_vip = request.form.get('settings_opensubtitles_vip')
- if settings_opensubtitles_vip is None:
- settings_opensubtitles_vip = 'False'
- else:
- settings_opensubtitles_vip = 'True'
-
- settings_opensubtitles_ssl = request.form.get('settings_opensubtitles_ssl')
- if settings_opensubtitles_ssl is None:
- settings_opensubtitles_ssl = 'False'
- else:
- settings_opensubtitles_ssl = 'True'
-
- settings_opensubtitles_skip_wrong_fps = request.form.get('settings_opensubtitles_skip_wrong_fps')
- if settings_opensubtitles_skip_wrong_fps is None:
- settings_opensubtitles_skip_wrong_fps = 'False'
- else:
- settings_opensubtitles_skip_wrong_fps = 'True'
-
- settings.addic7ed.username = request.form.get('settings_addic7ed_username')
- settings.addic7ed.password = request.form.get('settings_addic7ed_password')
- settings.addic7ed.random_agents = str(settings_addic7ed_random_agents)
- settings.assrt.token = request.form.get('settings_assrt_token')
- settings.legendasdivx.username = request.form.get('settings_legendasdivx_username')
- settings.legendasdivx.password = request.form.get('settings_legendasdivx_password')
- settings.legendastv.username = request.form.get('settings_legendastv_username')
- settings.legendastv.password = request.form.get('settings_legendastv_password')
- settings.opensubtitles.username = request.form.get('settings_opensubtitles_username')
- settings.opensubtitles.password = request.form.get('settings_opensubtitles_password')
- settings.opensubtitles.vip = str(settings_opensubtitles_vip)
- settings.opensubtitles.ssl = str(settings_opensubtitles_ssl)
- settings.opensubtitles.skip_wrong_fps = str(settings_opensubtitles_skip_wrong_fps)
- settings.xsubs.username = request.form.get('settings_xsubs_username')
- settings.xsubs.password = request.form.get('settings_xsubs_password')
- settings.napisy24.username = request.form.get('settings_napisy24_username')
- settings.napisy24.password = request.form.get('settings_napisy24_password')
- settings.subscene.username = request.form.get('settings_subscene_username')
- settings.subscene.password = request.form.get('settings_subscene_password')
- settings.titlovi.username = request.form.get('settings_titlovi_username')
- settings.titlovi.password = request.form.get('settings_titlovi_password')
- settings.betaseries.token = request.form.get('settings_betaseries_token')
-
- settings_subliminal_languages = request.form.getlist('settings_subliminal_languages')
- database.execute("UPDATE table_settings_languages SET enabled=0")
- for item in settings_subliminal_languages:
- database.execute("UPDATE table_settings_languages SET enabled=1 WHERE code2=?", (item,))
-
- settings_serie_default_enabled = request.form.get('settings_serie_default_enabled')
- if settings_serie_default_enabled is None:
- settings_serie_default_enabled = 'False'
- else:
- settings_serie_default_enabled = 'True'
- settings.general.serie_default_enabled = str(settings_serie_default_enabled)
-
- settings_serie_default_languages = str(request.form.getlist('settings_serie_default_languages'))
- if settings_serie_default_languages == "['None']":
- settings_serie_default_languages = 'None'
- settings.general.serie_default_language = str(settings_serie_default_languages)
-
- settings_serie_default_hi = request.form.get('settings_serie_default_hi')
- if settings_serie_default_hi is None:
- settings_serie_default_hi = 'False'
- else:
- settings_serie_default_hi = 'True'
- settings.general.serie_default_hi = str(settings_serie_default_hi)
-
- settings_serie_default_forced = str(request.form.get('settings_serie_default_forced'))
- settings.general.serie_default_forced = str(settings_serie_default_forced)
-
- settings_movie_default_enabled = request.form.get('settings_movie_default_enabled')
- if settings_movie_default_enabled is None:
- settings_movie_default_enabled = 'False'
- else:
- settings_movie_default_enabled = 'True'
- settings.general.movie_default_enabled = str(settings_movie_default_enabled)
-
- settings_movie_default_languages = str(request.form.getlist('settings_movie_default_languages'))
- if settings_movie_default_languages == "['None']":
- settings_movie_default_languages = 'None'
- settings.general.movie_default_language = str(settings_movie_default_languages)
-
- settings_movie_default_hi = request.form.get('settings_movie_default_hi')
- if settings_movie_default_hi is None:
- settings_movie_default_hi = 'False'
- else:
- settings_movie_default_hi = 'True'
- settings.general.movie_default_hi = str(settings_movie_default_hi)
-
- settings_movie_default_forced = str(request.form.get('settings_movie_default_forced'))
- settings.general.movie_default_forced = str(settings_movie_default_forced)
-
- with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
- settings.write(handle)
-
- configure_logging(settings.general.getboolean('debug') or args.debug)
-
- notifiers = database.execute("SELECT * FROM table_settings_notifier ORDER BY name")
- for notifier in notifiers:
- enabled = request.form.get('settings_notifier_' + notifier['name'] + '_enabled')
- if enabled == 'on':
- enabled = 1
- else:
- enabled = 0
- notifier_url = request.form.get('settings_notifier_' + notifier['name'] + '_url')
- database.execute("UPDATE table_settings_notifier SET enabled=?, url=? WHERE name=?",
- (enabled,notifier_url,notifier['name']))
-
- scheduler.update_configurable_tasks()
- logging.info('BAZARR Settings saved succesfully.')
-
- if ref.find('saved=true') > 0:
- return redirect(ref)
- else:
- return redirect(ref + "?saved=true")
+def settingsgeneral():
+ return render_template('settingsgeneral.html')
@app.route('/check_update')
diff --git a/views/_main.html b/views/_main.html
index b6d7c20e5..847edb5b3 100644
--- a/views/_main.html
+++ b/views/_main.html
@@ -177,7 +177,7 @@