From 9857368c958ca31a5250e9e6fc98e69888337a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 3 Aug 2018 07:21:46 -0400 Subject: [PATCH] Added dedicated minimum score settings for movie and episode #95 --- bazarr.py | 3 ++- get_general_settings.py | 6 ++++-- get_subtitle.py | 3 ++- update_db.py | 7 +++++++ views/settings.tpl | 24 ++++++++++++++++++++++-- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/bazarr.py b/bazarr.py index 63572993c..a75038752 100644 --- a/bazarr.py +++ b/bazarr.py @@ -758,6 +758,7 @@ def save_settings(): else: settings_general_embedded = 'True' settings_general_minimum_score = request.forms.get('settings_general_minimum_score') + settings_general_minimum_score_movies = request.forms.get('settings_general_minimum_score_movies') settings_general_use_postprocessing = request.forms.get('settings_general_use_postprocessing') if settings_general_use_postprocessing is None: settings_general_use_postprocessing = 'False' @@ -778,7 +779,7 @@ def save_settings(): before = c.execute("SELECT ip, port, base_url, log_level, path_mapping, use_sonarr, use_radarr, path_mapping_movie FROM table_settings_general").fetchone() after = (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_loglevel), unicode(settings_general_pathmapping), unicode(settings_general_use_sonarr), unicode(settings_general_use_radarr), unicode(settings_general_pathmapping_movie)) - c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?, single_language=?, minimum_score=?, use_scenename=?, use_postprocessing=?, postprocessing_cmd=?, use_sonarr=?, use_radarr=?, path_mapping_movie=?, page_size=?, use_embedded_subs=?", (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_pathmapping), unicode(settings_general_loglevel), unicode(settings_general_branch), unicode(settings_general_automatic), unicode(settings_general_single_language), unicode(settings_general_minimum_score), unicode(settings_general_scenename), unicode(settings_general_use_postprocessing), unicode(settings_general_postprocessing_cmd), unicode(settings_general_use_sonarr), unicode(settings_general_use_radarr), unicode(settings_general_pathmapping_movie), unicode(settings_page_size), unicode(settings_general_embedded))) + c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?, single_language=?, minimum_score=?, use_scenename=?, use_postprocessing=?, postprocessing_cmd=?, use_sonarr=?, use_radarr=?, path_mapping_movie=?, page_size=?, use_embedded_subs=?, minimum_score_movie=?", (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_pathmapping), unicode(settings_general_loglevel), unicode(settings_general_branch), unicode(settings_general_automatic), unicode(settings_general_single_language), unicode(settings_general_minimum_score), unicode(settings_general_scenename), unicode(settings_general_use_postprocessing), unicode(settings_general_postprocessing_cmd), unicode(settings_general_use_sonarr), unicode(settings_general_use_radarr), unicode(settings_general_pathmapping_movie), unicode(settings_page_size), unicode(settings_general_embedded), unicode(settings_general_minimum_score_movies))) conn.commit() if after != before: configured() diff --git a/get_general_settings.py b/get_general_settings.py index 9254f0d5a..3794c6d6f 100644 --- a/get_general_settings.py +++ b/get_general_settings.py @@ -51,8 +51,9 @@ def get_general_settings(): movie_default_hi = general_settings[22] page_size = general_settings[23] use_embedded_subs = general_settings[24] + minimum_score_movie = general_settings[25] - return [ip, port, base_url, path_mappings, log_level, branch, automatic, single_language, minimum_score, use_scenename, use_postprocessing, postprocessing_cmd, use_sonarr, use_radarr, path_mappings_movie, serie_default_enabled, serie_default_language, serie_default_hi, movie_default_enabled,movie_default_language, movie_default_hi, page_size, use_embedded_subs] + return [ip, port, base_url, path_mappings, log_level, branch, automatic, single_language, minimum_score, use_scenename, use_postprocessing, postprocessing_cmd, use_sonarr, use_radarr, path_mappings_movie, serie_default_enabled, serie_default_language, serie_default_hi, movie_default_enabled,movie_default_language, movie_default_hi, page_size, use_embedded_subs, minimum_score_movie] def path_replace(path): for path_mapping in path_mappings: @@ -131,4 +132,5 @@ movie_default_enabled = result[18] movie_default_language = result[19] movie_default_hi = result[20] page_size = result[21] -use_embedded_subs = result[22] \ No newline at end of file +use_embedded_subs = result[22] +minimum_score_movie = result[23] \ No newline at end of file diff --git a/get_subtitle.py b/get_subtitle.py index 6af3d98d1..6bca5a1af 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -18,9 +18,10 @@ region.configure('dogpile.cache.memory') def download_subtitle(path, language, hi, providers, providers_auth, sceneName, type): if type == 'series': type_of_score = 359 + minimum_score = float(get_general_settings()[8]) / 100 * type_of_score elif type == 'movies': type_of_score = 119 - minimum_score = float(get_general_settings()[8]) / 100 * type_of_score + minimum_score = float(get_general_settings()[23]) / 100 * type_of_score use_scenename = get_general_settings()[9] use_postprocessing = get_general_settings()[10] postprocessing_cmd = get_general_settings()[11] diff --git a/update_db.py b/update_db.py index 339f50034..0608a35c6 100644 --- a/update_db.py +++ b/update_db.py @@ -56,6 +56,13 @@ if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) else: c.execute('UPDATE table_settings_general SET minimum_score="0"') + try: + c.execute('alter table table_settings_general add column "minimum_score_movie" "text"') + except: + pass + else: + c.execute('UPDATE table_settings_general SET minimum_score_movie="0"') + try: c.execute('alter table table_settings_general add column "use_scenename" "text"') except: diff --git a/views/settings.tpl b/views/settings.tpl index f659502c6..e9d706e07 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -812,7 +812,7 @@