From 7bcea720536cc625bfe32cdda189e32bc8ebba0d Mon Sep 17 00:00:00 2001 From: Flaxee Date: Sat, 28 Dec 2019 09:27:32 +0100 Subject: Update unix.py --- libs/tzlocal/unix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/tzlocal/unix.py b/libs/tzlocal/unix.py index 388273c27..8574965a5 100644 --- a/libs/tzlocal/unix.py +++ b/libs/tzlocal/unix.py @@ -138,7 +138,7 @@ def _get_localzone(_root='/'): if os.path.exists(tzpath) and os.path.islink(tzpath): tzpath = os.path.realpath(tzpath) start = tzpath.find("/")+1 - while start is not 0: + while start != 0: tzpath = tzpath[start:] try: return pytz.timezone(tzpath) -- cgit v1.2.3 From 1c6967d68fd7e2201bd87a3be4b8f0b2ae288d7b Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Sat, 28 Dec 2019 23:30:45 -0500 Subject: Fixed issue when series got updated in Sonarr and not reflected in Bazarr. --- bazarr/get_series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr/get_series.py b/bazarr/get_series.py index c909dda09..1cd46b2ef 100644 --- a/bazarr/get_series.py +++ b/bazarr/get_series.py @@ -84,7 +84,7 @@ def update_series(): # Add shows in Sonarr to current shows list current_shows_sonarr.append(show['id']) - if show['tvdbId'] in current_shows_db_list: + if show['id'] in current_shows_db_list: series_to_update.append({'title': six.text_type(show["title"]), 'path': six.text_type(show["path"]), 'tvdbId': int(show["tvdbId"]), -- cgit v1.2.3 From b708828587378722da9c735049ff703fc476df24 Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 3 Jan 2020 14:09:53 -0500 Subject: Version bump. --- bazarr/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr/main.py b/bazarr/main.py index 696bc6f68..369bbb28b 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1,6 +1,6 @@ # coding=utf-8 -bazarr_version = '0.8.4' +bazarr_version = '0.8.4.1' import os os.environ["SZ_USER_AGENT"] = "Bazarr/1" -- cgit v1.2.3 From 48a899b66b37fc694cfa7ff8aa6b09205544dd04 Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 3 Jan 2020 14:10:32 -0500 Subject: Fix for #730. --- bazarr/main.py | 434 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 217 insertions(+), 217 deletions(-) diff --git a/bazarr/main.py b/bazarr/main.py index 369bbb28b..6df97f9b6 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -259,9 +259,9 @@ def wizard(): def save_wizard(): authorize() - settings_general_ip = request.forms.get('settings_general_ip') - settings_general_port = request.forms.get('settings_general_port') - settings_general_baseurl = request.forms.get('settings_general_baseurl') + settings_general_ip = request.forms.settings_general_ip + settings_general_port = request.forms.settings_general_port + settings_general_baseurl = request.forms.settings_general_baseurl if not settings_general_baseurl.endswith('/'): settings_general_baseurl += '/' settings_general_sourcepath = request.forms.getall('settings_general_sourcepath') @@ -273,35 +273,35 @@ def save_wizard(): 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_single_language = request.forms.get('settings_general_single_language') + settings_general_single_language = request.forms.settings_general_single_language if settings_general_single_language is None: settings_general_single_language = 'False' else: settings_general_single_language = 'True' - settings_general_use_sonarr = request.forms.get('settings_general_use_sonarr') + settings_general_use_sonarr = request.forms.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.forms.get('settings_general_use_radarr') + settings_general_use_radarr = request.forms.settings_general_use_radarr if settings_general_use_radarr is None: settings_general_use_radarr = 'False' else: settings_general_use_radarr = 'True' - settings_general_embedded = request.forms.get('settings_general_embedded') + settings_general_embedded = request.forms.settings_general_embedded if settings_general_embedded is None: settings_general_embedded = 'False' else: settings_general_embedded = 'True' - settings_subfolder = request.forms.get('settings_subfolder') - settings_subfolder_custom = request.forms.get('settings_subfolder_custom') - settings_upgrade_subs = request.forms.get('settings_upgrade_subs') + settings_subfolder = request.forms.settings_subfolder + settings_subfolder_custom = request.forms.settings_subfolder_custom + settings_upgrade_subs = request.forms.settings_upgrade_subs if settings_upgrade_subs is None: settings_upgrade_subs = 'False' else: settings_upgrade_subs = 'True' - settings_days_to_upgrade_subs = request.forms.get('settings_days_to_upgrade_subs') - settings_upgrade_manual = request.forms.get('settings_upgrade_manual') + settings_days_to_upgrade_subs = request.forms.settings_days_to_upgrade_subs + settings_upgrade_manual = request.forms.settings_upgrade_manual if settings_upgrade_manual is None: settings_upgrade_manual = 'False' else: @@ -322,16 +322,16 @@ def save_wizard(): settings.general.days_to_upgrade_subs = text_type(settings_days_to_upgrade_subs) settings.general.upgrade_manual = text_type(settings_upgrade_manual) - settings_sonarr_ip = request.forms.get('settings_sonarr_ip') - settings_sonarr_port = request.forms.get('settings_sonarr_port') - settings_sonarr_baseurl = request.forms.get('settings_sonarr_baseurl') - settings_sonarr_ssl = request.forms.get('settings_sonarr_ssl') + settings_sonarr_ip = request.forms.settings_sonarr_ip + settings_sonarr_port = request.forms.settings_sonarr_port + settings_sonarr_baseurl = request.forms.settings_sonarr_baseurl + settings_sonarr_ssl = request.forms.settings_sonarr_ssl if settings_sonarr_ssl is None: settings_sonarr_ssl = 'False' else: settings_sonarr_ssl = 'True' - settings_sonarr_apikey = request.forms.get('settings_sonarr_apikey') - settings_sonarr_only_monitored = request.forms.get('settings_sonarr_only_monitored') + settings_sonarr_apikey = request.forms.settings_sonarr_apikey + settings_sonarr_only_monitored = request.forms.settings_sonarr_only_monitored if settings_sonarr_only_monitored is None: settings_sonarr_only_monitored = 'False' else: @@ -344,16 +344,16 @@ def save_wizard(): settings.sonarr.apikey = text_type(settings_sonarr_apikey) settings.sonarr.only_monitored = text_type(settings_sonarr_only_monitored) - settings_radarr_ip = request.forms.get('settings_radarr_ip') - settings_radarr_port = request.forms.get('settings_radarr_port') - settings_radarr_baseurl = request.forms.get('settings_radarr_baseurl') - settings_radarr_ssl = request.forms.get('settings_radarr_ssl') + settings_radarr_ip = request.forms.settings_radarr_ip + settings_radarr_port = request.forms.settings_radarr_port + settings_radarr_baseurl = request.forms.settings_radarr_baseurl + settings_radarr_ssl = request.forms.settings_radarr_ssl if settings_radarr_ssl is None: settings_radarr_ssl = 'False' else: settings_radarr_ssl = 'True' - settings_radarr_apikey = request.forms.get('settings_radarr_apikey') - settings_radarr_only_monitored = request.forms.get('settings_radarr_only_monitored') + settings_radarr_apikey = request.forms.settings_radarr_apikey + settings_radarr_only_monitored = request.forms.settings_radarr_only_monitored if settings_radarr_only_monitored is None: settings_radarr_only_monitored = 'False' else: @@ -370,50 +370,50 @@ def save_wizard(): settings.general.enabled_providers = u'' if not settings_subliminal_providers else ','.join( settings_subliminal_providers) - settings_addic7ed_random_agents = request.forms.get('settings_addic7ed_random_agents') + settings_addic7ed_random_agents = request.forms.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.forms.get('settings_opensubtitles_vip') + settings_opensubtitles_vip = request.forms.settings_opensubtitles_vip if settings_opensubtitles_vip is None: settings_opensubtitles_vip = 'False' else: settings_opensubtitles_vip = 'True' - settings_opensubtitles_ssl = request.forms.get('settings_opensubtitles_ssl') + settings_opensubtitles_ssl = request.forms.settings_opensubtitles_ssl if settings_opensubtitles_ssl is None: settings_opensubtitles_ssl = 'False' else: settings_opensubtitles_ssl = 'True' - settings_opensubtitles_skip_wrong_fps = request.forms.get('settings_opensubtitles_skip_wrong_fps') + settings_opensubtitles_skip_wrong_fps = request.forms.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.forms.get('settings_addic7ed_username') - settings.addic7ed.password = request.forms.get('settings_addic7ed_password') - settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agents) - settings.assrt.token = request.forms.get('settings_assrt_token') - settings.legendastv.username = request.forms.get('settings_legendastv_username') - settings.legendastv.password = request.forms.get('settings_legendastv_password') - settings.opensubtitles.username = request.forms.get('settings_opensubtitles_username') - settings.opensubtitles.password = request.forms.get('settings_opensubtitles_password') + settings.addic7ed.username = request.forms.settings_addic7ed_username + settings.addic7ed.password = request.forms.settings_addic7ed_password + settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agent) + settings.assrt.token = request.forms.settings_assrt_token + settings.legendastv.username = request.forms.settings_legendastv_username + settings.legendastv.password = request.forms.settings_legendastv_password + settings.opensubtitles.username = request.forms.settings_opensubtitles_username + settings.opensubtitles.password = request.forms.settings_opensubtitles_password settings.opensubtitles.vip = text_type(settings_opensubtitles_vip) settings.opensubtitles.ssl = text_type(settings_opensubtitles_ssl) settings.opensubtitles.skip_wrong_fps = text_type(settings_opensubtitles_skip_wrong_fps) - settings.xsubs.username = request.forms.get('settings_xsubs_username') - settings.xsubs.password = request.forms.get('settings_xsubs_password') - settings.napisy24.username = request.forms.get('settings_napisy24_username') - settings.napisy24.password = request.forms.get('settings_napisy24_password') - settings.subscene.username = request.forms.get('settings_subscene_username') - settings.subscene.password = request.forms.get('settings_subscene_password') - settings.titlovi.username = request.forms.get('settings_titlovi_username') - settings.titlovi.password = request.forms.get('settings_titlovi_password') - settings.betaseries.token = request.forms.get('settings_betaseries_token') + settings.xsubs.username = request.forms.settings_xsubs_username + settings.xsubs.password = request.forms.settings_xsubs_password + settings.napisy24.username = request.forms.settings_napisy24_username + settings.napisy24.password = request.forms.settings_napisy24_password + settings.subscene.username = request.forms.settings_subscene_username + settings.subscene.password = request.forms.settings_subscene_password + settings.titlovi.username = request.forms.settings_titlovi_username + settings.titlovi.password = request.forms.settings_titlovi_password + settings.betaseries.token = request.forms.settings_betaseries_token settings_subliminal_languages = request.forms.getall('settings_subliminal_languages') # Disable all languages in DB @@ -422,7 +422,7 @@ def save_wizard(): # Enable each desired language in DB database.execute("UPDATE table_settings_languages SET enabled=1 WHERE code2=?", (item,)) - settings_serie_default_enabled = request.forms.get('settings_serie_default_enabled') + settings_serie_default_enabled = request.forms.settings_serie_default_enabled if settings_serie_default_enabled is None: settings_serie_default_enabled = 'False' else: @@ -434,14 +434,14 @@ def save_wizard(): settings_serie_default_languages = 'None' settings.general.serie_default_language = text_type(settings_serie_default_languages) - settings_serie_default_hi = request.forms.get('settings_serie_default_hi') + settings_serie_default_hi = request.forms.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 = text_type(settings_serie_default_hi) - settings_movie_default_enabled = request.forms.get('settings_movie_default_enabled') + settings_movie_default_enabled = request.forms.settings_movie_default_enabled if settings_movie_default_enabled is None: settings_movie_default_enabled = 'False' else: @@ -453,14 +453,14 @@ def save_wizard(): settings_movie_default_languages = 'None' settings.general.movie_default_language = text_type(settings_movie_default_languages) - settings_movie_default_hi = request.forms.get('settings_movie_default_hi') + settings_movie_default_hi = request.forms.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 = text_type(settings_movie_default_hi) - settings_movie_default_forced = str(request.forms.get('settings_movie_default_forced')) + settings_movie_default_forced = str(request.forms.settings_movie_default_forced) settings.general.movie_default_forced = text_type(settings_movie_default_forced) with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: @@ -676,8 +676,8 @@ def edit_series(no): if str(lang) == "['']": lang = '[]' - hi = request.forms.get('hearing_impaired') - forced = request.forms.get('forced') + hi = request.forms.hearing_impaired + forced = request.forms.forced if hi == "on": hi = "True" @@ -698,11 +698,11 @@ def edit_serieseditor(): authorize() ref = request.environ['HTTP_REFERER'] - series = request.forms.get('series') + series = request.forms.series series = ast.literal_eval(str('[' + series + ']')) lang = request.forms.getall('languages') - hi = request.forms.get('hearing_impaired') - forced = request.forms.get('forced') + hi = request.forms.hearing_impaired + forced = request.forms.forced for serie in series: if str(lang) != "[]" and str(lang) != "['']": @@ -806,11 +806,11 @@ def edit_movieseditor(): authorize() ref = request.environ['HTTP_REFERER'] - movies = request.forms.get('movies') + movies = request.forms.movies movies = ast.literal_eval(str('[' + movies + ']')) lang = request.forms.getall('languages') - hi = request.forms.get('hearing_impaired') - forced = request.forms.get('forced') + hi = request.forms.hearing_impaired + forced = request.forms.forced for movie in movies: if str(lang) != "[]" and str(lang) != "['']": @@ -852,8 +852,8 @@ def edit_movie(no): if str(lang) == "['']": lang = '[]' - hi = request.forms.get('hearing_impaired') - forced = request.forms.get('forced') + hi = request.forms.hearing_impaired + forced = request.forms.forced if hi == "on": hi = "True" @@ -1199,22 +1199,22 @@ def save_settings(): authorize() ref = request.environ['HTTP_REFERER'] - settings_general_ip = request.forms.get('settings_general_ip') - settings_general_port = request.forms.get('settings_general_port') - settings_general_baseurl = request.forms.get('settings_general_baseurl') + settings_general_ip = request.forms.settings_general_ip + settings_general_port = request.forms.settings_general_port + settings_general_baseurl = request.forms.settings_general_baseurl if not settings_general_baseurl.endswith('/'): settings_general_baseurl += '/' - settings_general_debug = request.forms.get('settings_general_debug') + settings_general_debug = request.forms.settings_general_debug if settings_general_debug is None: settings_general_debug = 'False' else: settings_general_debug = 'True' - settings_general_chmod_enabled = request.forms.get('settings_general_chmod_enabled') + settings_general_chmod_enabled = request.forms.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.forms.get('settings_general_chmod') + settings_general_chmod = request.forms.settings_general_chmod settings_general_sourcepath = request.forms.getall('settings_general_sourcepath') settings_general_destpath = request.forms.getall('settings_general_destpath') settings_general_pathmapping = [] @@ -1224,95 +1224,95 @@ def save_settings(): 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.forms.get('settings_general_branch') - settings_general_automatic = request.forms.get('settings_general_automatic') + settings_general_branch = request.forms.settings_general_branch + settings_general_automatic = request.forms.settings_general_automatic if settings_general_automatic is None: settings_general_automatic = 'False' else: settings_general_automatic = 'True' - settings_general_update_restart = request.forms.get('settings_general_update_restart') + settings_general_update_restart = request.forms.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.forms.get('settings_analytics_enabled') + settings_analytics_enabled = request.forms.settings_analytics_enabled if settings_analytics_enabled is None: settings_analytics_enabled = 'False' else: settings_analytics_enabled = 'True' - settings_general_single_language = request.forms.get('settings_general_single_language') + settings_general_single_language = request.forms.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.forms.get('settings_general_wanted_search_frequency') - settings_general_scenename = request.forms.get('settings_general_scenename') + settings_general_wanted_search_frequency = request.forms.settings_general_wanted_search_frequency + settings_general_scenename = request.forms.settings_general_scenename if settings_general_scenename is None: settings_general_scenename = 'False' else: settings_general_scenename = 'True' - settings_general_embedded = request.forms.get('settings_general_embedded') + settings_general_embedded = request.forms.settings_general_embedded if settings_general_embedded is None: settings_general_embedded = 'False' else: settings_general_embedded = 'True' - settings_general_utf8_encode = request.forms.get('settings_general_utf8_encode') + settings_general_utf8_encode = request.forms.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.forms.get('settings_general_ignore_pgs') + settings_general_ignore_pgs = request.forms.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.forms.get('settings_general_adaptive_searching') + settings_general_adaptive_searching = request.forms.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.forms.get('settings_general_multithreading') + settings_general_multithreading = request.forms.settings_general_multithreading if settings_general_multithreading is None: settings_general_multithreading = 'False' else: settings_general_multithreading = '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') + settings_general_minimum_score = request.forms.settings_general_minimum_score + settings_general_minimum_score_movies = request.forms.settings_general_minimum_score_movies + settings_general_use_postprocessing = request.forms.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.forms.get('settings_general_postprocessing_cmd') - settings_general_use_sonarr = request.forms.get('settings_general_use_sonarr') + settings_general_postprocessing_cmd = request.forms.settings_general_postprocessing_cmd + settings_general_use_sonarr = request.forms.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.forms.get('settings_general_use_radarr') + settings_general_use_radarr = request.forms.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.forms.get('settings_page_size') - settings_subfolder = request.forms.get('settings_subfolder') - settings_subfolder_custom = request.forms.get('settings_subfolder_custom') - settings_upgrade_subs = request.forms.get('settings_upgrade_subs') + settings_page_size = request.forms.settings_page_size + settings_subfolder = request.forms.settings_subfolder + settings_subfolder_custom = request.forms.settings_subfolder_custom + settings_upgrade_subs = request.forms.settings_upgrade_subs if settings_upgrade_subs is None: settings_upgrade_subs = 'False' else: settings_upgrade_subs = 'True' - settings_upgrade_subs_frequency = request.forms.get('settings_upgrade_subs_frequency') - settings_days_to_upgrade_subs = request.forms.get('settings_days_to_upgrade_subs') - settings_upgrade_manual = request.forms.get('settings_upgrade_manual') + settings_upgrade_subs_frequency = request.forms.settings_upgrade_subs_frequency + settings_days_to_upgrade_subs = request.forms.settings_days_to_upgrade_subs + settings_upgrade_manual = request.forms.settings_upgrade_manual if settings_upgrade_manual is None: settings_upgrade_manual = 'False' else: settings_upgrade_manual = 'True' - settings_anti_captcha_provider = request.forms.get('settings_anti_captcha_provider') - settings_anti_captcha_key = request.forms.get('settings_anti_captcha_key') - settings_death_by_captcha_username = request.forms.get('settings_death_by_captcha_username') - settings_death_by_captcha_password = request.forms.get('settings_death_by_captcha_password') + settings_anti_captcha_provider = request.forms.settings_anti_captcha_provider + settings_anti_captcha_key = request.forms.settings_anti_captcha_key + settings_death_by_captcha_username = request.forms.settings_death_by_captcha_username + settings_death_by_captcha_password = request.forms.settings_death_by_captcha_password before = (six.text_type(settings.general.ip), int(settings.general.port), six.text_type(settings.general.base_url), six.text_type(settings.general.path_mappings), six.text_type(settings.general.getboolean('use_sonarr')), @@ -1377,12 +1377,12 @@ def save_settings(): if after != before: configured() - settings_proxy_type = request.forms.get('settings_proxy_type') - settings_proxy_url = request.forms.get('settings_proxy_url') - settings_proxy_port = request.forms.get('settings_proxy_port') - settings_proxy_username = request.forms.get('settings_proxy_username') - settings_proxy_password = request.forms.get('settings_proxy_password') - settings_proxy_exclude = request.forms.get('settings_proxy_exclude') + settings_proxy_type = request.forms.settings_proxy_type + settings_proxy_url = request.forms.settings_proxy_url + settings_proxy_port = request.forms.settings_proxy_port + settings_proxy_username = request.forms.settings_proxy_username + settings_proxy_password = request.forms.settings_proxy_password + settings_proxy_exclude = request.forms.settings_proxy_exclude before_proxy_password = (six.text_type(settings.proxy.type), six.text_type(settings.proxy.exclude)) if before_proxy_password[0] != settings_proxy_type: @@ -1401,9 +1401,9 @@ def save_settings(): settings.proxy.password = text_type(settings_proxy_password) settings.proxy.exclude = text_type(settings_proxy_exclude) - settings_auth_type = request.forms.get('settings_auth_type') - settings_auth_username = request.forms.get('settings_auth_username') - settings_auth_password = request.forms.get('settings_auth_password') + settings_auth_type = request.forms.settings_auth_type + settings_auth_username = request.forms.settings_auth_username + settings_auth_password = request.forms.settings_auth_password if settings.auth.type != settings_auth_type: configured() @@ -1437,25 +1437,25 @@ def save_settings(): pass else: aaa._beaker_session.delete() - settings.auth.apikey = request.forms.get('settings_auth_apikey') + settings.auth.apikey = request.forms.settings_auth_apikey - settings_sonarr_ip = request.forms.get('settings_sonarr_ip') - settings_sonarr_port = request.forms.get('settings_sonarr_port') - settings_sonarr_baseurl = request.forms.get('settings_sonarr_baseurl') - settings_sonarr_ssl = request.forms.get('settings_sonarr_ssl') + settings_sonarr_ip = request.forms.settings_sonarr_ip + settings_sonarr_port = request.forms.settings_sonarr_port + settings_sonarr_baseurl = request.forms.settings_sonarr_baseurl + settings_sonarr_ssl = request.forms.settings_sonarr_ssl if settings_sonarr_ssl is None: settings_sonarr_ssl = 'False' else: settings_sonarr_ssl = 'True' - settings_sonarr_apikey = request.forms.get('settings_sonarr_apikey') - settings_sonarr_only_monitored = request.forms.get('settings_sonarr_only_monitored') + settings_sonarr_apikey = request.forms.settings_sonarr_apikey + settings_sonarr_only_monitored = request.forms.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.forms.get('settings_sonarr_sync') - settings_sonarr_sync_day = request.forms.get('settings_sonarr_sync_day') - settings_sonarr_sync_hour = request.forms.get('settings_sonarr_sync_hour') + settings_sonarr_sync = request.forms.settings_sonarr_sync + settings_sonarr_sync_day = request.forms.settings_sonarr_sync_day + settings_sonarr_sync_hour = request.forms.settings_sonarr_sync_hour settings.sonarr.ip = text_type(settings_sonarr_ip) settings.sonarr.port = text_type(settings_sonarr_port) @@ -1467,23 +1467,23 @@ def save_settings(): settings.sonarr.full_update_day = text_type(settings_sonarr_sync_day) settings.sonarr.full_update_hour = text_type(settings_sonarr_sync_hour) - settings_radarr_ip = request.forms.get('settings_radarr_ip') - settings_radarr_port = request.forms.get('settings_radarr_port') - settings_radarr_baseurl = request.forms.get('settings_radarr_baseurl') - settings_radarr_ssl = request.forms.get('settings_radarr_ssl') + settings_radarr_ip = request.forms.settings_radarr_ip + settings_radarr_port = request.forms.settings_radarr_port + settings_radarr_baseurl = request.forms.settings_radarr_baseurl + settings_radarr_ssl = request.forms.settings_radarr_ssl if settings_radarr_ssl is None: settings_radarr_ssl = 'False' else: settings_radarr_ssl = 'True' - settings_radarr_apikey = request.forms.get('settings_radarr_apikey') - settings_radarr_only_monitored = request.forms.get('settings_radarr_only_monitored') + settings_radarr_apikey = request.forms.settings_radarr_apikey + settings_radarr_only_monitored = request.forms.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.forms.get('settings_radarr_sync') - settings_radarr_sync_day = request.forms.get('settings_radarr_sync_day') - settings_radarr_sync_hour = request.forms.get('settings_radarr_sync_hour') + settings_radarr_sync = request.forms.settings_radarr_sync + settings_radarr_sync_day = request.forms.settings_radarr_sync_day + settings_radarr_sync_hour = request.forms.settings_radarr_sync_hour settings.radarr.ip = text_type(settings_radarr_ip) settings.radarr.port = text_type(settings_radarr_port) @@ -1499,57 +1499,57 @@ def save_settings(): settings.general.enabled_providers = u'' if not settings_subliminal_providers else ','.join( settings_subliminal_providers) - settings_addic7ed_random_agents = request.forms.get('settings_addic7ed_random_agents') + settings_addic7ed_random_agents = request.forms.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.forms.get('settings_opensubtitles_vip') + settings_opensubtitles_vip = request.forms.settings_opensubtitles_vip if settings_opensubtitles_vip is None: settings_opensubtitles_vip = 'False' else: settings_opensubtitles_vip = 'True' - settings_opensubtitles_ssl = request.forms.get('settings_opensubtitles_ssl') + settings_opensubtitles_ssl = request.forms.settings_opensubtitles_ssl if settings_opensubtitles_ssl is None: settings_opensubtitles_ssl = 'False' else: settings_opensubtitles_ssl = 'True' - settings_opensubtitles_skip_wrong_fps = request.forms.get('settings_opensubtitles_skip_wrong_fps') + settings_opensubtitles_skip_wrong_fps = request.forms.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.forms.get('settings_addic7ed_username') - settings.addic7ed.password = request.forms.get('settings_addic7ed_password') + settings.addic7ed.username = request.forms.settings_addic7ed_username + settings.addic7ed.password = request.forms.settings_addic7ed_password settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agents) - settings.assrt.token = request.forms.get('settings_assrt_token') - settings.legendastv.username = request.forms.get('settings_legendastv_username') - settings.legendastv.password = request.forms.get('settings_legendastv_password') - settings.opensubtitles.username = request.forms.get('settings_opensubtitles_username') - settings.opensubtitles.password = request.forms.get('settings_opensubtitles_password') + settings.assrt.token = request.forms.settings_assrt_token + settings.legendastv.username = request.forms.settings_legendastv_username + settings.legendastv.password = request.forms.settings_legendastv_password + settings.opensubtitles.username = request.forms.settings_opensubtitles_username + settings.opensubtitles.password = request.forms.settings_opensubtitles_password settings.opensubtitles.vip = text_type(settings_opensubtitles_vip) settings.opensubtitles.ssl = text_type(settings_opensubtitles_ssl) settings.opensubtitles.skip_wrong_fps = text_type(settings_opensubtitles_skip_wrong_fps) - settings.xsubs.username = request.forms.get('settings_xsubs_username') - settings.xsubs.password = request.forms.get('settings_xsubs_password') - settings.napisy24.username = request.forms.get('settings_napisy24_username') - settings.napisy24.password = request.forms.get('settings_napisy24_password') - settings.subscene.username = request.forms.get('settings_subscene_username') - settings.subscene.password = request.forms.get('settings_subscene_password') - settings.titlovi.username = request.forms.get('settings_titlovi_username') - settings.titlovi.password = request.forms.get('settings_titlovi_password') - settings.betaseries.token = request.forms.get('settings_betaseries_token') + settings.xsubs.username = request.forms.settings_xsubs_username + settings.xsubs.password = request.forms.settings_xsubs_password + settings.napisy24.username = request.forms.settings_napisy24_username + settings.napisy24.password = request.forms.settings_napisy24_password + settings.subscene.username = request.forms.settings_subscene_username + settings.subscene.password = request.forms.settings_subscene_password + settings.titlovi.username = request.forms.settings_titlovi_username + settings.titlovi.password = request.forms.settings_titlovi_password + settings.betaseries.token = request.forms.settings_betaseries_token settings_subliminal_languages = request.forms.getall('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.forms.get('settings_serie_default_enabled') + settings_serie_default_enabled = request.forms.settings_serie_default_enabled if settings_serie_default_enabled is None: settings_serie_default_enabled = 'False' else: @@ -1561,17 +1561,17 @@ def save_settings(): settings_serie_default_languages = 'None' settings.general.serie_default_language = text_type(settings_serie_default_languages) - settings_serie_default_hi = request.forms.get('settings_serie_default_hi') + settings_serie_default_hi = request.forms.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 = text_type(settings_serie_default_hi) - settings_serie_default_forced = str(request.forms.get('settings_serie_default_forced')) + settings_serie_default_forced = str(request.forms.settings_serie_default_forced) settings.general.serie_default_forced = text_type(settings_serie_default_forced) - settings_movie_default_enabled = request.forms.get('settings_movie_default_enabled') + settings_movie_default_enabled = request.forms.settings_movie_default_enabled if settings_movie_default_enabled is None: settings_movie_default_enabled = 'False' else: @@ -1583,14 +1583,14 @@ def save_settings(): settings_movie_default_languages = 'None' settings.general.movie_default_language = text_type(settings_movie_default_languages) - settings_movie_default_hi = request.forms.get('settings_movie_default_hi') + settings_movie_default_hi = request.forms.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 = text_type(settings_movie_default_hi) - settings_movie_default_forced = str(request.forms.get('settings_movie_default_forced')) + settings_movie_default_forced = str(request.forms.settings_movie_default_forced) settings.general.movie_default_forced = text_type(settings_movie_default_forced) with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: @@ -1749,11 +1749,11 @@ def execute_task(taskid): @custom_auth_basic(check_credentials) def remove_subtitles(): authorize() - episodePath = request.forms.get('episodePath') - language = request.forms.get('language') - subtitlesPath = request.forms.get('subtitlesPath') - sonarrSeriesId = request.forms.get('sonarrSeriesId') - sonarrEpisodeId = request.forms.get('sonarrEpisodeId') + episodePath = request.forms.episodePath + language = request.forms.language + subtitlesPath = request.forms.subtitlesPath + sonarrSeriesId = request.forms.sonarrSeriesId + sonarrEpisodeId = request.forms.sonarrEpisodeId try: os.remove(subtitlesPath) @@ -1768,10 +1768,10 @@ def remove_subtitles(): @custom_auth_basic(check_credentials) def remove_subtitles_movie(): authorize() - moviePath = request.forms.get('moviePath') - language = request.forms.get('language') - subtitlesPath = request.forms.get('subtitlesPath') - radarrId = request.forms.get('radarrId') + moviePath = request.forms.moviePath + language = request.forms.language + subtitlesPath = request.forms.subtitlesPath + radarrId = request.forms.radarrId try: os.remove(subtitlesPath) @@ -1788,14 +1788,14 @@ def get_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.get('episodePath') - sceneName = request.forms.get('sceneName') - language = request.forms.get('language') - hi = request.forms.get('hi') - forced = request.forms.get('forced') - sonarrSeriesId = request.forms.get('sonarrSeriesId') - sonarrEpisodeId = request.forms.get('sonarrEpisodeId') - title = request.forms.get('title') + episodePath = request.forms.episodePath + sceneName = request.forms.sceneName + language = request.forms.language + hi = request.forms.hi + forced = request.forms.forced + sonarrSeriesId = request.forms.sonarrSeriesId + sonarrEpisodeId = request.forms.sonarrEpisodeId + title = request.forms.title providers_list = get_providers() providers_auth = get_providers_auth() @@ -1823,12 +1823,12 @@ def get_subtitle(): def manual_search_json(): authorize() - episodePath = request.forms.get('episodePath') - sceneName = request.forms.get('sceneName') - language = request.forms.get('language') - hi = request.forms.get('hi') - forced = request.forms.get('forced') - title = request.forms.get('title') + episodePath = request.forms.episodePath + sceneName = request.forms.sceneName + language = request.forms.language + hi = request.forms.hi + forced = request.forms.forced + title = request.forms.title providers_list = get_providers() providers_auth = get_providers_auth() @@ -1843,16 +1843,16 @@ def manual_get_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.get('episodePath') - sceneName = request.forms.get('sceneName') - language = request.forms.get('language') - hi = request.forms.get('hi') - forced = request.forms.get('forced') - selected_provider = request.forms.get('provider') - subtitle = request.forms.get('subtitle') - sonarrSeriesId = request.forms.get('sonarrSeriesId') - sonarrEpisodeId = request.forms.get('sonarrEpisodeId') - title = request.forms.get('title') + episodePath = request.forms.episodePath + sceneName = request.forms.sceneName + language = request.forms.language + hi = request.forms.hi + forced = request.forms.forced + selected_provider = request.forms.provider + subtitle = request.forms.subtitle + sonarrSeriesId = request.forms.sonarrSeriesId + sonarrEpisodeId = request.forms.sonarrEpisodeId + title = request.forms.title providers_auth = get_providers_auth() @@ -1881,14 +1881,14 @@ def perform_manual_upload_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.get('episodePath') - sceneName = request.forms.get('sceneName') - language = request.forms.get('language') - forced = True if request.forms.get('forced') == '1' else False + episodePath = request.forms.episodePath + sceneName = request.forms.sceneName + language = request.forms.language + forced = True if request.forms.forced == '1' else False upload = request.files.get('upload') - sonarrSeriesId = request.forms.get('sonarrSeriesId') - sonarrEpisodeId = request.forms.get('sonarrEpisodeId') - title = request.forms.get('title') + sonarrSeriesId = request.forms.sonarrSeriesId + sonarrEpisodeId = request.forms.sonarrEpisodeId + title = request.forms.title _, ext = os.path.splitext(upload.filename) @@ -1925,13 +1925,13 @@ def get_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.get('moviePath') - sceneName = request.forms.get('sceneName') - language = request.forms.get('language') - hi = request.forms.get('hi') - forced = request.forms.get('forced') - radarrId = request.forms.get('radarrId') - title = request.forms.get('title') + moviePath = request.forms.moviePat + sceneName = request.forms.sceneName + language = request.forms.language + hi = request.forms.hi + forced = request.forms.forced + radarrId = request.forms.radarrId + title = request.forms.title providers_list = get_providers() providers_auth = get_providers_auth() @@ -1959,12 +1959,12 @@ def get_subtitle_movie(): def manual_search_movie_json(): authorize() - moviePath = request.forms.get('moviePath') - sceneName = request.forms.get('sceneName') - language = request.forms.get('language') - hi = request.forms.get('hi') - forced = request.forms.get('forced') - title = request.forms.get('title') + moviePath = request.forms.moviePath + sceneName = request.forms.sceneName + language = request.forms.language + hi = request.forms.hi + forced = request.forms.forced + title = request.forms.title providers_list = get_providers() providers_auth = get_providers_auth() @@ -1979,15 +1979,15 @@ def manual_get_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.get('moviePath') - sceneName = request.forms.get('sceneName') - language = request.forms.get('language') - hi = request.forms.get('hi') - forced = request.forms.get('forced') - selected_provider = request.forms.get('provider') - subtitle = request.forms.get('subtitle') - radarrId = request.forms.get('radarrId') - title = request.forms.get('title') + moviePath = request.forms.moviePath + sceneName = request.forms.sceneName + language = request.forms.language + hi = request.forms.hi + forced = request.forms.forced + selected_provider = request.forms.provider + subtitle = request.forms.subtitle + radarrId = request.forms.radarrId + title = request.forms.title providers_auth = get_providers_auth() @@ -2015,13 +2015,13 @@ def perform_manual_upload_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.get('moviePath') - sceneName = request.forms.get('sceneName') - language = request.forms.get('language') - forced = True if request.forms.get('forced') == '1' else False + moviePath = request.forms.moviePath + sceneName = request.forms.sceneName + language = request.forms.language + forced = True if request.forms.forced == '1' else False upload = request.files.get('upload') - radarrId = request.forms.get('radarrId') - title = request.forms.get('title') + radarrId = request.forms.radarrId + title = request.forms.title _, ext = os.path.splitext(upload.filename) -- cgit v1.2.3 From 9fe4d6a1a1750c69a96e5a8e43b16811fff86536 Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 3 Jan 2020 22:27:27 -0500 Subject: Another fix for #730. --- bazarr/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bazarr/main.py b/bazarr/main.py index 6df97f9b6..9672d22ba 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -396,7 +396,7 @@ def save_wizard(): settings.addic7ed.username = request.forms.settings_addic7ed_username settings.addic7ed.password = request.forms.settings_addic7ed_password - settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agent) + settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agents) settings.assrt.token = request.forms.settings_assrt_token settings.legendastv.username = request.forms.settings_legendastv_username settings.legendastv.password = request.forms.settings_legendastv_password @@ -1925,7 +1925,7 @@ def get_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.moviePat + moviePath = request.forms.moviePath sceneName = request.forms.sceneName language = request.forms.language hi = request.forms.hi -- cgit v1.2.3 From 487abdd9f213019849201cd7952fccf0f137079a Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 4 Jan 2020 01:04:16 -0500 Subject: Revert "Another fix for #730." This reverts commit 9fe4d6a1 --- bazarr/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bazarr/main.py b/bazarr/main.py index 9672d22ba..6df97f9b6 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -396,7 +396,7 @@ def save_wizard(): settings.addic7ed.username = request.forms.settings_addic7ed_username settings.addic7ed.password = request.forms.settings_addic7ed_password - settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agents) + settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agent) settings.assrt.token = request.forms.settings_assrt_token settings.legendastv.username = request.forms.settings_legendastv_username settings.legendastv.password = request.forms.settings_legendastv_password @@ -1925,7 +1925,7 @@ def get_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.moviePath + moviePath = request.forms.moviePat sceneName = request.forms.sceneName language = request.forms.language hi = request.forms.hi -- cgit v1.2.3 From 2743870a4d87416b5c743d2f3f585cd43dbb23d4 Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 4 Jan 2020 01:04:45 -0500 Subject: Revert "Fix for #730." This reverts commit 48a899b6 --- bazarr/main.py | 434 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 217 insertions(+), 217 deletions(-) diff --git a/bazarr/main.py b/bazarr/main.py index 6df97f9b6..369bbb28b 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -259,9 +259,9 @@ def wizard(): def save_wizard(): authorize() - settings_general_ip = request.forms.settings_general_ip - settings_general_port = request.forms.settings_general_port - settings_general_baseurl = request.forms.settings_general_baseurl + settings_general_ip = request.forms.get('settings_general_ip') + settings_general_port = request.forms.get('settings_general_port') + settings_general_baseurl = request.forms.get('settings_general_baseurl') if not settings_general_baseurl.endswith('/'): settings_general_baseurl += '/' settings_general_sourcepath = request.forms.getall('settings_general_sourcepath') @@ -273,35 +273,35 @@ def save_wizard(): 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_single_language = request.forms.settings_general_single_language + settings_general_single_language = request.forms.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_use_sonarr = request.forms.settings_general_use_sonarr + settings_general_use_sonarr = request.forms.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.forms.settings_general_use_radarr + settings_general_use_radarr = request.forms.get('settings_general_use_radarr') if settings_general_use_radarr is None: settings_general_use_radarr = 'False' else: settings_general_use_radarr = 'True' - settings_general_embedded = request.forms.settings_general_embedded + settings_general_embedded = request.forms.get('settings_general_embedded') if settings_general_embedded is None: settings_general_embedded = 'False' else: settings_general_embedded = 'True' - settings_subfolder = request.forms.settings_subfolder - settings_subfolder_custom = request.forms.settings_subfolder_custom - settings_upgrade_subs = request.forms.settings_upgrade_subs + settings_subfolder = request.forms.get('settings_subfolder') + settings_subfolder_custom = request.forms.get('settings_subfolder_custom') + settings_upgrade_subs = request.forms.get('settings_upgrade_subs') if settings_upgrade_subs is None: settings_upgrade_subs = 'False' else: settings_upgrade_subs = 'True' - settings_days_to_upgrade_subs = request.forms.settings_days_to_upgrade_subs - settings_upgrade_manual = request.forms.settings_upgrade_manual + settings_days_to_upgrade_subs = request.forms.get('settings_days_to_upgrade_subs') + settings_upgrade_manual = request.forms.get('settings_upgrade_manual') if settings_upgrade_manual is None: settings_upgrade_manual = 'False' else: @@ -322,16 +322,16 @@ def save_wizard(): settings.general.days_to_upgrade_subs = text_type(settings_days_to_upgrade_subs) settings.general.upgrade_manual = text_type(settings_upgrade_manual) - settings_sonarr_ip = request.forms.settings_sonarr_ip - settings_sonarr_port = request.forms.settings_sonarr_port - settings_sonarr_baseurl = request.forms.settings_sonarr_baseurl - settings_sonarr_ssl = request.forms.settings_sonarr_ssl + settings_sonarr_ip = request.forms.get('settings_sonarr_ip') + settings_sonarr_port = request.forms.get('settings_sonarr_port') + settings_sonarr_baseurl = request.forms.get('settings_sonarr_baseurl') + settings_sonarr_ssl = request.forms.get('settings_sonarr_ssl') if settings_sonarr_ssl is None: settings_sonarr_ssl = 'False' else: settings_sonarr_ssl = 'True' - settings_sonarr_apikey = request.forms.settings_sonarr_apikey - settings_sonarr_only_monitored = request.forms.settings_sonarr_only_monitored + settings_sonarr_apikey = request.forms.get('settings_sonarr_apikey') + settings_sonarr_only_monitored = request.forms.get('settings_sonarr_only_monitored') if settings_sonarr_only_monitored is None: settings_sonarr_only_monitored = 'False' else: @@ -344,16 +344,16 @@ def save_wizard(): settings.sonarr.apikey = text_type(settings_sonarr_apikey) settings.sonarr.only_monitored = text_type(settings_sonarr_only_monitored) - settings_radarr_ip = request.forms.settings_radarr_ip - settings_radarr_port = request.forms.settings_radarr_port - settings_radarr_baseurl = request.forms.settings_radarr_baseurl - settings_radarr_ssl = request.forms.settings_radarr_ssl + settings_radarr_ip = request.forms.get('settings_radarr_ip') + settings_radarr_port = request.forms.get('settings_radarr_port') + settings_radarr_baseurl = request.forms.get('settings_radarr_baseurl') + settings_radarr_ssl = request.forms.get('settings_radarr_ssl') if settings_radarr_ssl is None: settings_radarr_ssl = 'False' else: settings_radarr_ssl = 'True' - settings_radarr_apikey = request.forms.settings_radarr_apikey - settings_radarr_only_monitored = request.forms.settings_radarr_only_monitored + settings_radarr_apikey = request.forms.get('settings_radarr_apikey') + settings_radarr_only_monitored = request.forms.get('settings_radarr_only_monitored') if settings_radarr_only_monitored is None: settings_radarr_only_monitored = 'False' else: @@ -370,50 +370,50 @@ def save_wizard(): settings.general.enabled_providers = u'' if not settings_subliminal_providers else ','.join( settings_subliminal_providers) - settings_addic7ed_random_agents = request.forms.settings_addic7ed_random_agents + settings_addic7ed_random_agents = request.forms.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.forms.settings_opensubtitles_vip + settings_opensubtitles_vip = request.forms.get('settings_opensubtitles_vip') if settings_opensubtitles_vip is None: settings_opensubtitles_vip = 'False' else: settings_opensubtitles_vip = 'True' - settings_opensubtitles_ssl = request.forms.settings_opensubtitles_ssl + settings_opensubtitles_ssl = request.forms.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.forms.settings_opensubtitles_skip_wrong_fps + settings_opensubtitles_skip_wrong_fps = request.forms.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.forms.settings_addic7ed_username - settings.addic7ed.password = request.forms.settings_addic7ed_password - settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agent) - settings.assrt.token = request.forms.settings_assrt_token - settings.legendastv.username = request.forms.settings_legendastv_username - settings.legendastv.password = request.forms.settings_legendastv_password - settings.opensubtitles.username = request.forms.settings_opensubtitles_username - settings.opensubtitles.password = request.forms.settings_opensubtitles_password + settings.addic7ed.username = request.forms.get('settings_addic7ed_username') + settings.addic7ed.password = request.forms.get('settings_addic7ed_password') + settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agents) + settings.assrt.token = request.forms.get('settings_assrt_token') + settings.legendastv.username = request.forms.get('settings_legendastv_username') + settings.legendastv.password = request.forms.get('settings_legendastv_password') + settings.opensubtitles.username = request.forms.get('settings_opensubtitles_username') + settings.opensubtitles.password = request.forms.get('settings_opensubtitles_password') settings.opensubtitles.vip = text_type(settings_opensubtitles_vip) settings.opensubtitles.ssl = text_type(settings_opensubtitles_ssl) settings.opensubtitles.skip_wrong_fps = text_type(settings_opensubtitles_skip_wrong_fps) - settings.xsubs.username = request.forms.settings_xsubs_username - settings.xsubs.password = request.forms.settings_xsubs_password - settings.napisy24.username = request.forms.settings_napisy24_username - settings.napisy24.password = request.forms.settings_napisy24_password - settings.subscene.username = request.forms.settings_subscene_username - settings.subscene.password = request.forms.settings_subscene_password - settings.titlovi.username = request.forms.settings_titlovi_username - settings.titlovi.password = request.forms.settings_titlovi_password - settings.betaseries.token = request.forms.settings_betaseries_token + settings.xsubs.username = request.forms.get('settings_xsubs_username') + settings.xsubs.password = request.forms.get('settings_xsubs_password') + settings.napisy24.username = request.forms.get('settings_napisy24_username') + settings.napisy24.password = request.forms.get('settings_napisy24_password') + settings.subscene.username = request.forms.get('settings_subscene_username') + settings.subscene.password = request.forms.get('settings_subscene_password') + settings.titlovi.username = request.forms.get('settings_titlovi_username') + settings.titlovi.password = request.forms.get('settings_titlovi_password') + settings.betaseries.token = request.forms.get('settings_betaseries_token') settings_subliminal_languages = request.forms.getall('settings_subliminal_languages') # Disable all languages in DB @@ -422,7 +422,7 @@ def save_wizard(): # Enable each desired language in DB database.execute("UPDATE table_settings_languages SET enabled=1 WHERE code2=?", (item,)) - settings_serie_default_enabled = request.forms.settings_serie_default_enabled + settings_serie_default_enabled = request.forms.get('settings_serie_default_enabled') if settings_serie_default_enabled is None: settings_serie_default_enabled = 'False' else: @@ -434,14 +434,14 @@ def save_wizard(): settings_serie_default_languages = 'None' settings.general.serie_default_language = text_type(settings_serie_default_languages) - settings_serie_default_hi = request.forms.settings_serie_default_hi + settings_serie_default_hi = request.forms.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 = text_type(settings_serie_default_hi) - settings_movie_default_enabled = request.forms.settings_movie_default_enabled + settings_movie_default_enabled = request.forms.get('settings_movie_default_enabled') if settings_movie_default_enabled is None: settings_movie_default_enabled = 'False' else: @@ -453,14 +453,14 @@ def save_wizard(): settings_movie_default_languages = 'None' settings.general.movie_default_language = text_type(settings_movie_default_languages) - settings_movie_default_hi = request.forms.settings_movie_default_hi + settings_movie_default_hi = request.forms.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 = text_type(settings_movie_default_hi) - settings_movie_default_forced = str(request.forms.settings_movie_default_forced) + settings_movie_default_forced = str(request.forms.get('settings_movie_default_forced')) settings.general.movie_default_forced = text_type(settings_movie_default_forced) with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: @@ -676,8 +676,8 @@ def edit_series(no): if str(lang) == "['']": lang = '[]' - hi = request.forms.hearing_impaired - forced = request.forms.forced + hi = request.forms.get('hearing_impaired') + forced = request.forms.get('forced') if hi == "on": hi = "True" @@ -698,11 +698,11 @@ def edit_serieseditor(): authorize() ref = request.environ['HTTP_REFERER'] - series = request.forms.series + series = request.forms.get('series') series = ast.literal_eval(str('[' + series + ']')) lang = request.forms.getall('languages') - hi = request.forms.hearing_impaired - forced = request.forms.forced + hi = request.forms.get('hearing_impaired') + forced = request.forms.get('forced') for serie in series: if str(lang) != "[]" and str(lang) != "['']": @@ -806,11 +806,11 @@ def edit_movieseditor(): authorize() ref = request.environ['HTTP_REFERER'] - movies = request.forms.movies + movies = request.forms.get('movies') movies = ast.literal_eval(str('[' + movies + ']')) lang = request.forms.getall('languages') - hi = request.forms.hearing_impaired - forced = request.forms.forced + hi = request.forms.get('hearing_impaired') + forced = request.forms.get('forced') for movie in movies: if str(lang) != "[]" and str(lang) != "['']": @@ -852,8 +852,8 @@ def edit_movie(no): if str(lang) == "['']": lang = '[]' - hi = request.forms.hearing_impaired - forced = request.forms.forced + hi = request.forms.get('hearing_impaired') + forced = request.forms.get('forced') if hi == "on": hi = "True" @@ -1199,22 +1199,22 @@ def save_settings(): authorize() ref = request.environ['HTTP_REFERER'] - settings_general_ip = request.forms.settings_general_ip - settings_general_port = request.forms.settings_general_port - settings_general_baseurl = request.forms.settings_general_baseurl + settings_general_ip = request.forms.get('settings_general_ip') + settings_general_port = request.forms.get('settings_general_port') + settings_general_baseurl = request.forms.get('settings_general_baseurl') if not settings_general_baseurl.endswith('/'): settings_general_baseurl += '/' - settings_general_debug = request.forms.settings_general_debug + settings_general_debug = request.forms.get('settings_general_debug') if settings_general_debug is None: settings_general_debug = 'False' else: settings_general_debug = 'True' - settings_general_chmod_enabled = request.forms.settings_general_chmod_enabled + settings_general_chmod_enabled = request.forms.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.forms.settings_general_chmod + settings_general_chmod = request.forms.get('settings_general_chmod') settings_general_sourcepath = request.forms.getall('settings_general_sourcepath') settings_general_destpath = request.forms.getall('settings_general_destpath') settings_general_pathmapping = [] @@ -1224,95 +1224,95 @@ def save_settings(): 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.forms.settings_general_branch - settings_general_automatic = request.forms.settings_general_automatic + settings_general_branch = request.forms.get('settings_general_branch') + settings_general_automatic = request.forms.get('settings_general_automatic') if settings_general_automatic is None: settings_general_automatic = 'False' else: settings_general_automatic = 'True' - settings_general_update_restart = request.forms.settings_general_update_restart + settings_general_update_restart = request.forms.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.forms.settings_analytics_enabled + settings_analytics_enabled = request.forms.get('settings_analytics_enabled') if settings_analytics_enabled is None: settings_analytics_enabled = 'False' else: settings_analytics_enabled = 'True' - settings_general_single_language = request.forms.settings_general_single_language + settings_general_single_language = request.forms.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.forms.settings_general_wanted_search_frequency - settings_general_scenename = request.forms.settings_general_scenename + settings_general_wanted_search_frequency = request.forms.get('settings_general_wanted_search_frequency') + settings_general_scenename = request.forms.get('settings_general_scenename') if settings_general_scenename is None: settings_general_scenename = 'False' else: settings_general_scenename = 'True' - settings_general_embedded = request.forms.settings_general_embedded + settings_general_embedded = request.forms.get('settings_general_embedded') if settings_general_embedded is None: settings_general_embedded = 'False' else: settings_general_embedded = 'True' - settings_general_utf8_encode = request.forms.settings_general_utf8_encode + settings_general_utf8_encode = request.forms.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.forms.settings_general_ignore_pgs + settings_general_ignore_pgs = request.forms.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.forms.settings_general_adaptive_searching + settings_general_adaptive_searching = request.forms.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.forms.settings_general_multithreading + settings_general_multithreading = request.forms.get('settings_general_multithreading') if settings_general_multithreading is None: settings_general_multithreading = 'False' else: settings_general_multithreading = 'True' - settings_general_minimum_score = request.forms.settings_general_minimum_score - settings_general_minimum_score_movies = request.forms.settings_general_minimum_score_movies - settings_general_use_postprocessing = request.forms.settings_general_use_postprocessing + 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' else: settings_general_use_postprocessing = 'True' - settings_general_postprocessing_cmd = request.forms.settings_general_postprocessing_cmd - settings_general_use_sonarr = request.forms.settings_general_use_sonarr + settings_general_postprocessing_cmd = request.forms.get('settings_general_postprocessing_cmd') + settings_general_use_sonarr = request.forms.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.forms.settings_general_use_radarr + settings_general_use_radarr = request.forms.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.forms.settings_page_size - settings_subfolder = request.forms.settings_subfolder - settings_subfolder_custom = request.forms.settings_subfolder_custom - settings_upgrade_subs = request.forms.settings_upgrade_subs + settings_page_size = request.forms.get('settings_page_size') + settings_subfolder = request.forms.get('settings_subfolder') + settings_subfolder_custom = request.forms.get('settings_subfolder_custom') + settings_upgrade_subs = request.forms.get('settings_upgrade_subs') if settings_upgrade_subs is None: settings_upgrade_subs = 'False' else: settings_upgrade_subs = 'True' - settings_upgrade_subs_frequency = request.forms.settings_upgrade_subs_frequency - settings_days_to_upgrade_subs = request.forms.settings_days_to_upgrade_subs - settings_upgrade_manual = request.forms.settings_upgrade_manual + settings_upgrade_subs_frequency = request.forms.get('settings_upgrade_subs_frequency') + settings_days_to_upgrade_subs = request.forms.get('settings_days_to_upgrade_subs') + settings_upgrade_manual = request.forms.get('settings_upgrade_manual') if settings_upgrade_manual is None: settings_upgrade_manual = 'False' else: settings_upgrade_manual = 'True' - settings_anti_captcha_provider = request.forms.settings_anti_captcha_provider - settings_anti_captcha_key = request.forms.settings_anti_captcha_key - settings_death_by_captcha_username = request.forms.settings_death_by_captcha_username - settings_death_by_captcha_password = request.forms.settings_death_by_captcha_password + settings_anti_captcha_provider = request.forms.get('settings_anti_captcha_provider') + settings_anti_captcha_key = request.forms.get('settings_anti_captcha_key') + settings_death_by_captcha_username = request.forms.get('settings_death_by_captcha_username') + settings_death_by_captcha_password = request.forms.get('settings_death_by_captcha_password') before = (six.text_type(settings.general.ip), int(settings.general.port), six.text_type(settings.general.base_url), six.text_type(settings.general.path_mappings), six.text_type(settings.general.getboolean('use_sonarr')), @@ -1377,12 +1377,12 @@ def save_settings(): if after != before: configured() - settings_proxy_type = request.forms.settings_proxy_type - settings_proxy_url = request.forms.settings_proxy_url - settings_proxy_port = request.forms.settings_proxy_port - settings_proxy_username = request.forms.settings_proxy_username - settings_proxy_password = request.forms.settings_proxy_password - settings_proxy_exclude = request.forms.settings_proxy_exclude + settings_proxy_type = request.forms.get('settings_proxy_type') + settings_proxy_url = request.forms.get('settings_proxy_url') + settings_proxy_port = request.forms.get('settings_proxy_port') + settings_proxy_username = request.forms.get('settings_proxy_username') + settings_proxy_password = request.forms.get('settings_proxy_password') + settings_proxy_exclude = request.forms.get('settings_proxy_exclude') before_proxy_password = (six.text_type(settings.proxy.type), six.text_type(settings.proxy.exclude)) if before_proxy_password[0] != settings_proxy_type: @@ -1401,9 +1401,9 @@ def save_settings(): settings.proxy.password = text_type(settings_proxy_password) settings.proxy.exclude = text_type(settings_proxy_exclude) - settings_auth_type = request.forms.settings_auth_type - settings_auth_username = request.forms.settings_auth_username - settings_auth_password = request.forms.settings_auth_password + settings_auth_type = request.forms.get('settings_auth_type') + settings_auth_username = request.forms.get('settings_auth_username') + settings_auth_password = request.forms.get('settings_auth_password') if settings.auth.type != settings_auth_type: configured() @@ -1437,25 +1437,25 @@ def save_settings(): pass else: aaa._beaker_session.delete() - settings.auth.apikey = request.forms.settings_auth_apikey + settings.auth.apikey = request.forms.get('settings_auth_apikey') - settings_sonarr_ip = request.forms.settings_sonarr_ip - settings_sonarr_port = request.forms.settings_sonarr_port - settings_sonarr_baseurl = request.forms.settings_sonarr_baseurl - settings_sonarr_ssl = request.forms.settings_sonarr_ssl + settings_sonarr_ip = request.forms.get('settings_sonarr_ip') + settings_sonarr_port = request.forms.get('settings_sonarr_port') + settings_sonarr_baseurl = request.forms.get('settings_sonarr_baseurl') + settings_sonarr_ssl = request.forms.get('settings_sonarr_ssl') if settings_sonarr_ssl is None: settings_sonarr_ssl = 'False' else: settings_sonarr_ssl = 'True' - settings_sonarr_apikey = request.forms.settings_sonarr_apikey - settings_sonarr_only_monitored = request.forms.settings_sonarr_only_monitored + settings_sonarr_apikey = request.forms.get('settings_sonarr_apikey') + settings_sonarr_only_monitored = request.forms.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.forms.settings_sonarr_sync - settings_sonarr_sync_day = request.forms.settings_sonarr_sync_day - settings_sonarr_sync_hour = request.forms.settings_sonarr_sync_hour + settings_sonarr_sync = request.forms.get('settings_sonarr_sync') + settings_sonarr_sync_day = request.forms.get('settings_sonarr_sync_day') + settings_sonarr_sync_hour = request.forms.get('settings_sonarr_sync_hour') settings.sonarr.ip = text_type(settings_sonarr_ip) settings.sonarr.port = text_type(settings_sonarr_port) @@ -1467,23 +1467,23 @@ def save_settings(): settings.sonarr.full_update_day = text_type(settings_sonarr_sync_day) settings.sonarr.full_update_hour = text_type(settings_sonarr_sync_hour) - settings_radarr_ip = request.forms.settings_radarr_ip - settings_radarr_port = request.forms.settings_radarr_port - settings_radarr_baseurl = request.forms.settings_radarr_baseurl - settings_radarr_ssl = request.forms.settings_radarr_ssl + settings_radarr_ip = request.forms.get('settings_radarr_ip') + settings_radarr_port = request.forms.get('settings_radarr_port') + settings_radarr_baseurl = request.forms.get('settings_radarr_baseurl') + settings_radarr_ssl = request.forms.get('settings_radarr_ssl') if settings_radarr_ssl is None: settings_radarr_ssl = 'False' else: settings_radarr_ssl = 'True' - settings_radarr_apikey = request.forms.settings_radarr_apikey - settings_radarr_only_monitored = request.forms.settings_radarr_only_monitored + settings_radarr_apikey = request.forms.get('settings_radarr_apikey') + settings_radarr_only_monitored = request.forms.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.forms.settings_radarr_sync - settings_radarr_sync_day = request.forms.settings_radarr_sync_day - settings_radarr_sync_hour = request.forms.settings_radarr_sync_hour + settings_radarr_sync = request.forms.get('settings_radarr_sync') + settings_radarr_sync_day = request.forms.get('settings_radarr_sync_day') + settings_radarr_sync_hour = request.forms.get('settings_radarr_sync_hour') settings.radarr.ip = text_type(settings_radarr_ip) settings.radarr.port = text_type(settings_radarr_port) @@ -1499,57 +1499,57 @@ def save_settings(): settings.general.enabled_providers = u'' if not settings_subliminal_providers else ','.join( settings_subliminal_providers) - settings_addic7ed_random_agents = request.forms.settings_addic7ed_random_agents + settings_addic7ed_random_agents = request.forms.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.forms.settings_opensubtitles_vip + settings_opensubtitles_vip = request.forms.get('settings_opensubtitles_vip') if settings_opensubtitles_vip is None: settings_opensubtitles_vip = 'False' else: settings_opensubtitles_vip = 'True' - settings_opensubtitles_ssl = request.forms.settings_opensubtitles_ssl + settings_opensubtitles_ssl = request.forms.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.forms.settings_opensubtitles_skip_wrong_fps + settings_opensubtitles_skip_wrong_fps = request.forms.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.forms.settings_addic7ed_username - settings.addic7ed.password = request.forms.settings_addic7ed_password + settings.addic7ed.username = request.forms.get('settings_addic7ed_username') + settings.addic7ed.password = request.forms.get('settings_addic7ed_password') settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agents) - settings.assrt.token = request.forms.settings_assrt_token - settings.legendastv.username = request.forms.settings_legendastv_username - settings.legendastv.password = request.forms.settings_legendastv_password - settings.opensubtitles.username = request.forms.settings_opensubtitles_username - settings.opensubtitles.password = request.forms.settings_opensubtitles_password + settings.assrt.token = request.forms.get('settings_assrt_token') + settings.legendastv.username = request.forms.get('settings_legendastv_username') + settings.legendastv.password = request.forms.get('settings_legendastv_password') + settings.opensubtitles.username = request.forms.get('settings_opensubtitles_username') + settings.opensubtitles.password = request.forms.get('settings_opensubtitles_password') settings.opensubtitles.vip = text_type(settings_opensubtitles_vip) settings.opensubtitles.ssl = text_type(settings_opensubtitles_ssl) settings.opensubtitles.skip_wrong_fps = text_type(settings_opensubtitles_skip_wrong_fps) - settings.xsubs.username = request.forms.settings_xsubs_username - settings.xsubs.password = request.forms.settings_xsubs_password - settings.napisy24.username = request.forms.settings_napisy24_username - settings.napisy24.password = request.forms.settings_napisy24_password - settings.subscene.username = request.forms.settings_subscene_username - settings.subscene.password = request.forms.settings_subscene_password - settings.titlovi.username = request.forms.settings_titlovi_username - settings.titlovi.password = request.forms.settings_titlovi_password - settings.betaseries.token = request.forms.settings_betaseries_token + settings.xsubs.username = request.forms.get('settings_xsubs_username') + settings.xsubs.password = request.forms.get('settings_xsubs_password') + settings.napisy24.username = request.forms.get('settings_napisy24_username') + settings.napisy24.password = request.forms.get('settings_napisy24_password') + settings.subscene.username = request.forms.get('settings_subscene_username') + settings.subscene.password = request.forms.get('settings_subscene_password') + settings.titlovi.username = request.forms.get('settings_titlovi_username') + settings.titlovi.password = request.forms.get('settings_titlovi_password') + settings.betaseries.token = request.forms.get('settings_betaseries_token') settings_subliminal_languages = request.forms.getall('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.forms.settings_serie_default_enabled + settings_serie_default_enabled = request.forms.get('settings_serie_default_enabled') if settings_serie_default_enabled is None: settings_serie_default_enabled = 'False' else: @@ -1561,17 +1561,17 @@ def save_settings(): settings_serie_default_languages = 'None' settings.general.serie_default_language = text_type(settings_serie_default_languages) - settings_serie_default_hi = request.forms.settings_serie_default_hi + settings_serie_default_hi = request.forms.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 = text_type(settings_serie_default_hi) - settings_serie_default_forced = str(request.forms.settings_serie_default_forced) + settings_serie_default_forced = str(request.forms.get('settings_serie_default_forced')) settings.general.serie_default_forced = text_type(settings_serie_default_forced) - settings_movie_default_enabled = request.forms.settings_movie_default_enabled + settings_movie_default_enabled = request.forms.get('settings_movie_default_enabled') if settings_movie_default_enabled is None: settings_movie_default_enabled = 'False' else: @@ -1583,14 +1583,14 @@ def save_settings(): settings_movie_default_languages = 'None' settings.general.movie_default_language = text_type(settings_movie_default_languages) - settings_movie_default_hi = request.forms.settings_movie_default_hi + settings_movie_default_hi = request.forms.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 = text_type(settings_movie_default_hi) - settings_movie_default_forced = str(request.forms.settings_movie_default_forced) + settings_movie_default_forced = str(request.forms.get('settings_movie_default_forced')) settings.general.movie_default_forced = text_type(settings_movie_default_forced) with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: @@ -1749,11 +1749,11 @@ def execute_task(taskid): @custom_auth_basic(check_credentials) def remove_subtitles(): authorize() - episodePath = request.forms.episodePath - language = request.forms.language - subtitlesPath = request.forms.subtitlesPath - sonarrSeriesId = request.forms.sonarrSeriesId - sonarrEpisodeId = request.forms.sonarrEpisodeId + episodePath = request.forms.get('episodePath') + language = request.forms.get('language') + subtitlesPath = request.forms.get('subtitlesPath') + sonarrSeriesId = request.forms.get('sonarrSeriesId') + sonarrEpisodeId = request.forms.get('sonarrEpisodeId') try: os.remove(subtitlesPath) @@ -1768,10 +1768,10 @@ def remove_subtitles(): @custom_auth_basic(check_credentials) def remove_subtitles_movie(): authorize() - moviePath = request.forms.moviePath - language = request.forms.language - subtitlesPath = request.forms.subtitlesPath - radarrId = request.forms.radarrId + moviePath = request.forms.get('moviePath') + language = request.forms.get('language') + subtitlesPath = request.forms.get('subtitlesPath') + radarrId = request.forms.get('radarrId') try: os.remove(subtitlesPath) @@ -1788,14 +1788,14 @@ def get_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.episodePath - sceneName = request.forms.sceneName - language = request.forms.language - hi = request.forms.hi - forced = request.forms.forced - sonarrSeriesId = request.forms.sonarrSeriesId - sonarrEpisodeId = request.forms.sonarrEpisodeId - title = request.forms.title + episodePath = request.forms.get('episodePath') + sceneName = request.forms.get('sceneName') + language = request.forms.get('language') + hi = request.forms.get('hi') + forced = request.forms.get('forced') + sonarrSeriesId = request.forms.get('sonarrSeriesId') + sonarrEpisodeId = request.forms.get('sonarrEpisodeId') + title = request.forms.get('title') providers_list = get_providers() providers_auth = get_providers_auth() @@ -1823,12 +1823,12 @@ def get_subtitle(): def manual_search_json(): authorize() - episodePath = request.forms.episodePath - sceneName = request.forms.sceneName - language = request.forms.language - hi = request.forms.hi - forced = request.forms.forced - title = request.forms.title + episodePath = request.forms.get('episodePath') + sceneName = request.forms.get('sceneName') + language = request.forms.get('language') + hi = request.forms.get('hi') + forced = request.forms.get('forced') + title = request.forms.get('title') providers_list = get_providers() providers_auth = get_providers_auth() @@ -1843,16 +1843,16 @@ def manual_get_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.episodePath - sceneName = request.forms.sceneName - language = request.forms.language - hi = request.forms.hi - forced = request.forms.forced - selected_provider = request.forms.provider - subtitle = request.forms.subtitle - sonarrSeriesId = request.forms.sonarrSeriesId - sonarrEpisodeId = request.forms.sonarrEpisodeId - title = request.forms.title + episodePath = request.forms.get('episodePath') + sceneName = request.forms.get('sceneName') + language = request.forms.get('language') + hi = request.forms.get('hi') + forced = request.forms.get('forced') + selected_provider = request.forms.get('provider') + subtitle = request.forms.get('subtitle') + sonarrSeriesId = request.forms.get('sonarrSeriesId') + sonarrEpisodeId = request.forms.get('sonarrEpisodeId') + title = request.forms.get('title') providers_auth = get_providers_auth() @@ -1881,14 +1881,14 @@ def perform_manual_upload_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.episodePath - sceneName = request.forms.sceneName - language = request.forms.language - forced = True if request.forms.forced == '1' else False + episodePath = request.forms.get('episodePath') + sceneName = request.forms.get('sceneName') + language = request.forms.get('language') + forced = True if request.forms.get('forced') == '1' else False upload = request.files.get('upload') - sonarrSeriesId = request.forms.sonarrSeriesId - sonarrEpisodeId = request.forms.sonarrEpisodeId - title = request.forms.title + sonarrSeriesId = request.forms.get('sonarrSeriesId') + sonarrEpisodeId = request.forms.get('sonarrEpisodeId') + title = request.forms.get('title') _, ext = os.path.splitext(upload.filename) @@ -1925,13 +1925,13 @@ def get_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.moviePat - sceneName = request.forms.sceneName - language = request.forms.language - hi = request.forms.hi - forced = request.forms.forced - radarrId = request.forms.radarrId - title = request.forms.title + moviePath = request.forms.get('moviePath') + sceneName = request.forms.get('sceneName') + language = request.forms.get('language') + hi = request.forms.get('hi') + forced = request.forms.get('forced') + radarrId = request.forms.get('radarrId') + title = request.forms.get('title') providers_list = get_providers() providers_auth = get_providers_auth() @@ -1959,12 +1959,12 @@ def get_subtitle_movie(): def manual_search_movie_json(): authorize() - moviePath = request.forms.moviePath - sceneName = request.forms.sceneName - language = request.forms.language - hi = request.forms.hi - forced = request.forms.forced - title = request.forms.title + moviePath = request.forms.get('moviePath') + sceneName = request.forms.get('sceneName') + language = request.forms.get('language') + hi = request.forms.get('hi') + forced = request.forms.get('forced') + title = request.forms.get('title') providers_list = get_providers() providers_auth = get_providers_auth() @@ -1979,15 +1979,15 @@ def manual_get_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.moviePath - sceneName = request.forms.sceneName - language = request.forms.language - hi = request.forms.hi - forced = request.forms.forced - selected_provider = request.forms.provider - subtitle = request.forms.subtitle - radarrId = request.forms.radarrId - title = request.forms.title + moviePath = request.forms.get('moviePath') + sceneName = request.forms.get('sceneName') + language = request.forms.get('language') + hi = request.forms.get('hi') + forced = request.forms.get('forced') + selected_provider = request.forms.get('provider') + subtitle = request.forms.get('subtitle') + radarrId = request.forms.get('radarrId') + title = request.forms.get('title') providers_auth = get_providers_auth() @@ -2015,13 +2015,13 @@ def perform_manual_upload_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.moviePath - sceneName = request.forms.sceneName - language = request.forms.language - forced = True if request.forms.forced == '1' else False + moviePath = request.forms.get('moviePath') + sceneName = request.forms.get('sceneName') + language = request.forms.get('language') + forced = True if request.forms.get('forced') == '1' else False upload = request.files.get('upload') - radarrId = request.forms.radarrId - title = request.forms.title + radarrId = request.forms.get('radarrId') + title = request.forms.get('title') _, ext = os.path.splitext(upload.filename) -- cgit v1.2.3 From b3b15252eab87ae418b643afbd81dc397e4c9677 Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 4 Jan 2020 01:11:29 -0500 Subject: New fix for #730. --- bazarr/main.py | 62 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/bazarr/main.py b/bazarr/main.py index 369bbb28b..0a149e31c 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1749,9 +1749,9 @@ def execute_task(taskid): @custom_auth_basic(check_credentials) def remove_subtitles(): authorize() - episodePath = request.forms.get('episodePath') + episodePath = request.forms.episodePath language = request.forms.get('language') - subtitlesPath = request.forms.get('subtitlesPath') + subtitlesPath = request.forms.subtitlesPath sonarrSeriesId = request.forms.get('sonarrSeriesId') sonarrEpisodeId = request.forms.get('sonarrEpisodeId') @@ -1768,9 +1768,9 @@ def remove_subtitles(): @custom_auth_basic(check_credentials) def remove_subtitles_movie(): authorize() - moviePath = request.forms.get('moviePath') + moviePath = request.forms.moviePath language = request.forms.get('language') - subtitlesPath = request.forms.get('subtitlesPath') + subtitlesPath = request.forms.subtitlesPath radarrId = request.forms.get('radarrId') try: @@ -1788,14 +1788,14 @@ def get_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.get('episodePath') - sceneName = request.forms.get('sceneName') + episodePath = request.forms.episodePath + sceneName = request.forms.sceneName language = request.forms.get('language') hi = request.forms.get('hi') forced = request.forms.get('forced') sonarrSeriesId = request.forms.get('sonarrSeriesId') sonarrEpisodeId = request.forms.get('sonarrEpisodeId') - title = request.forms.get('title') + title = request.forms.title providers_list = get_providers() providers_auth = get_providers_auth() @@ -1823,12 +1823,12 @@ def get_subtitle(): def manual_search_json(): authorize() - episodePath = request.forms.get('episodePath') - sceneName = request.forms.get('sceneName') + episodePath = request.forms.episodePath + sceneName = request.forms.sceneName language = request.forms.get('language') hi = request.forms.get('hi') forced = request.forms.get('forced') - title = request.forms.get('title') + title = request.forms.title providers_list = get_providers() providers_auth = get_providers_auth() @@ -1843,16 +1843,16 @@ def manual_get_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.get('episodePath') - sceneName = request.forms.get('sceneName') + episodePath = request.forms.episodePath + sceneName = request.forms.sceneName language = request.forms.get('language') hi = request.forms.get('hi') forced = request.forms.get('forced') selected_provider = request.forms.get('provider') - subtitle = request.forms.get('subtitle') + subtitle = request.forms.subtitle sonarrSeriesId = request.forms.get('sonarrSeriesId') sonarrEpisodeId = request.forms.get('sonarrEpisodeId') - title = request.forms.get('title') + title = request.forms.title providers_auth = get_providers_auth() @@ -1881,14 +1881,14 @@ def perform_manual_upload_subtitle(): authorize() ref = request.environ['HTTP_REFERER'] - episodePath = request.forms.get('episodePath') - sceneName = request.forms.get('sceneName') + episodePath = request.forms.episodePath + sceneName = request.forms.sceneName language = request.forms.get('language') forced = True if request.forms.get('forced') == '1' else False upload = request.files.get('upload') sonarrSeriesId = request.forms.get('sonarrSeriesId') sonarrEpisodeId = request.forms.get('sonarrEpisodeId') - title = request.forms.get('title') + title = request.forms.title _, ext = os.path.splitext(upload.filename) @@ -1925,13 +1925,13 @@ def get_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.get('moviePath') - sceneName = request.forms.get('sceneName') + moviePath = request.forms.moviePath + sceneName = request.forms.sceneName language = request.forms.get('language') hi = request.forms.get('hi') forced = request.forms.get('forced') radarrId = request.forms.get('radarrId') - title = request.forms.get('title') + title = request.forms.title providers_list = get_providers() providers_auth = get_providers_auth() @@ -1959,12 +1959,12 @@ def get_subtitle_movie(): def manual_search_movie_json(): authorize() - moviePath = request.forms.get('moviePath') - sceneName = request.forms.get('sceneName') + moviePath = request.forms.moviePath + sceneName = request.forms.sceneName language = request.forms.get('language') hi = request.forms.get('hi') forced = request.forms.get('forced') - title = request.forms.get('title') + title = request.forms.title providers_list = get_providers() providers_auth = get_providers_auth() @@ -1979,15 +1979,15 @@ def manual_get_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.get('moviePath') - sceneName = request.forms.get('sceneName') + moviePath = request.forms.moviePath + sceneName = request.forms.sceneName language = request.forms.get('language') hi = request.forms.get('hi') forced = request.forms.get('forced') - selected_provider = request.forms.get('provider') - subtitle = request.forms.get('subtitle') + selected_provider = request.forms.provider + subtitle = request.forms.subtitle radarrId = request.forms.get('radarrId') - title = request.forms.get('title') + title = request.forms.title providers_auth = get_providers_auth() @@ -2015,13 +2015,13 @@ def perform_manual_upload_subtitle_movie(): authorize() ref = request.environ['HTTP_REFERER'] - moviePath = request.forms.get('moviePath') - sceneName = request.forms.get('sceneName') + moviePath = request.forms.moviePath + sceneName = request.forms.sceneName language = request.forms.get('language') forced = True if request.forms.get('forced') == '1' else False upload = request.files.get('upload') radarrId = request.forms.get('radarrId') - title = request.forms.get('title') + title = request.forms.title _, ext = os.path.splitext(upload.filename) -- cgit v1.2.3 From db7951ced2749da0ac4537807b817aab40b916e9 Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 5 Jan 2020 10:33:36 -0500 Subject: Fix for #737. --- bazarr/get_subtitle.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 81d2e8a6e..be4d36ad2 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -249,6 +249,11 @@ def download_subtitle(path, language, hi, forced, providers, providers_auth, sce if os.name == 'nt': out = out.decode(encoding) + + try: + out = out.decode(sys.stdout.encoding) + except (UnicodeDecodeError, AttributeError): + pass except: if out == "": @@ -474,6 +479,11 @@ def manual_download_subtitle(path, language, hi, forced, subtitle, provider, pro if os.name == 'nt': out = out.decode(encoding) + + try: + out = out.decode(sys.stdout.encoding) + except (UnicodeDecodeError, AttributeError): + pass except: if out == "": -- cgit v1.2.3 From a7689393e17995a6c132352365a7a6c5a515f46e Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 5 Jan 2020 12:49:12 -0500 Subject: Fix for #718. --- bazarr/get_series.py | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/bazarr/get_series.py b/bazarr/get_series.py index 1cd46b2ef..d34a509b5 100644 --- a/bazarr/get_series.py +++ b/bazarr/get_series.py @@ -62,19 +62,21 @@ def update_series(): seriesListLength = len(r.json()) for i, show in enumerate(r.json(), 1): notifications.write(msg="Getting series data from Sonarr...", queue='get_series', item=i, length=seriesListLength) - try: - overview = six.text_type(show['overview']) - except: - overview = "" - try: - poster_big = show['images'][2]['url'].split('?')[0] - poster = os.path.splitext(poster_big)[0] + '-250' + os.path.splitext(poster_big)[1] - except: - poster = "" - try: - fanart = show['images'][0]['url'].split('?')[0] - except: - fanart = "" + + if 'overview' in show: + overview = show['overview'] + else: + overview = '' + + poster = '' + fanart = '' + for image in show['images']: + if image['coverType'] == 'poster': + poster_big = image['url'].split('?')[0] + poster = os.path.splitext(poster_big)[0] + '-250' + os.path.splitext(poster_big)[1] + + if image['coverType'] == 'fanart': + fanart = image['url'].split('?')[0] if show['alternateTitles'] != None: alternateTitles = str([item['title'] for item in show['alternateTitles']]) @@ -85,17 +87,17 @@ def update_series(): current_shows_sonarr.append(show['id']) if show['id'] in current_shows_db_list: - series_to_update.append({'title': six.text_type(show["title"]), - 'path': six.text_type(show["path"]), + series_to_update.append({'title': show["title"], + 'path': show["path"], 'tvdbId': int(show["tvdbId"]), 'sonarrSeriesId': int(show["id"]), - 'overview': six.text_type(overview), - 'poster': six.text_type(poster), - 'fanart': six.text_type(fanart), - 'audio_language': six.text_type(profile_id_to_language((show['qualityProfileId'] if get_sonarr_version().startswith('2') else show['languageProfileId']), audio_profiles)), - 'sortTitle': six.text_type(show['sortTitle']), - 'year': six.text_type(show['year']), - 'alternateTitles': six.text_type(alternateTitles)}) + 'overview': overview, + 'poster': poster, + 'fanart': fanart, + 'audio_language': profile_id_to_language((show['qualityProfileId'] if get_sonarr_version().startswith('2') else show['languageProfileId']), audio_profiles), + 'sortTitle': show['sortTitle'], + 'year': show['year'], + 'alternateTitles': alternateTitles}) else: if serie_default_enabled is True: series_to_add.append({'title': show["title"], -- cgit v1.2.3 From 298a563b4f80e876d400760202072a61e957c253 Mon Sep 17 00:00:00 2001 From: Louis Vézina <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 6 Jan 2020 17:11:01 -0500 Subject: Fix for #737. --- bazarr/get_subtitle.py | 107 +++++++++++++++++++------------------------------ 1 file changed, 41 insertions(+), 66 deletions(-) diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index be4d36ad2..698afd853 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -40,6 +40,7 @@ from analytics import track_event import six from six.moves import range from functools import reduce +from locale import getpreferredencoding def get_video(path, title, sceneName, use_scenename, providers=None, media_type="movie"): @@ -234,39 +235,7 @@ def download_subtitle(path, language, hi, forced, providers, providers_auth, sce command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2, downloaded_language_code3, subtitle.language.forced) - try: - if os.name == 'nt': - codepage = subprocess.Popen("chcp", shell=True, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - # wait for the process to terminate - out_codepage, err_codepage = codepage.communicate() - encoding = out_codepage.split(':')[-1].strip() - - process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - # wait for the process to terminate - out, err = process.communicate() - - if os.name == 'nt': - out = out.decode(encoding) - - try: - out = out.decode(sys.stdout.encoding) - except (UnicodeDecodeError, AttributeError): - pass - - except: - if out == "": - logging.error( - 'BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution') - else: - logging.error('BAZARR Post-processing result for file ' + path + ' : ' + out) - else: - if out == "": - logging.info( - 'BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution') - else: - logging.info('BAZARR Post-processing result for file ' + path + ' : ' + out) + postprocessing(command, path) # fixme: support multiple languages at once if media_type == 'series': @@ -464,39 +433,7 @@ def manual_download_subtitle(path, language, hi, forced, subtitle, provider, pro command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2, downloaded_language_code3, subtitle.language.forced) - try: - if os.name == 'nt': - codepage = subprocess.Popen("chcp", shell=True, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - # wait for the process to terminate - out_codepage, err_codepage = codepage.communicate() - encoding = out_codepage.split(':')[-1].strip() - - process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - # wait for the process to terminate - out, err = process.communicate() - - if os.name == 'nt': - out = out.decode(encoding) - - try: - out = out.decode(sys.stdout.encoding) - except (UnicodeDecodeError, AttributeError): - pass - - except: - if out == "": - logging.error( - 'BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution') - else: - logging.error('BAZARR Post-processing result for file ' + path + ' : ' + out) - else: - if out == "": - logging.info( - 'BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution') - else: - logging.info('BAZARR Post-processing result for file ' + path + ' : ' + out) + postprocessing(command, path) if media_type == 'series': reversed_path = path_replace_reverse(path) @@ -1183,3 +1120,41 @@ def upgrade_subtitles(): store_subtitles_movie(movie['video_path'], path_replace_movie(movie['video_path'])) history_log_movie(3, movie['radarrId'], message, path, language_code, provider, score) send_notifications_movie(movie['radarrId'], message) + + +def postprocessing(command, path): + try: + encoding = getpreferredencoding() + if os.name == 'nt': + if six.PY3: + codepage = subprocess.Popen("chcp", shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, encoding=getpreferredencoding()) + else: + codepage = subprocess.Popen("chcp", shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + # wait for the process to terminate + out_codepage, err_codepage = codepage.communicate() + encoding = out_codepage.split(':')[-1].strip() + + if six.PY3: + process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, encoding=encoding) + else: + process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + # wait for the process to terminate + out, err = process.communicate() + + if six.PY2: + out = out.decode(encoding) + + out = out.replace('\n', ' ').replace('\r', ' ') + + except Exception as e: + logging.error('BAZARR Post-processing failed for file ' + path + ' : ' + repr(e)) + else: + if out == "": + logging.info( + 'BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution') + else: + logging.info('BAZARR Post-processing result for file ' + path + ' : ' + out) -- cgit v1.2.3 From 6c3cc4be28d078a49eab0088326bf7b1b7c0b3fa Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Tue, 7 Jan 2020 12:23:17 +0100 Subject: providers: adding bsplayer initial commit --- libs/subliminal_patch/core.py | 4 + libs/subliminal_patch/providers/bsplayer.py | 240 ++++++++++++++++++++++++++++ views/providers.tpl | 16 ++ 3 files changed, 260 insertions(+) create mode 100644 libs/subliminal_patch/providers/bsplayer.py diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index d4685c289..38a603eed 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -543,6 +543,10 @@ def scan_video(path, dont_use_actual_file=False, hints=None, providers=None, ski if video.size > 10485760: logger.debug('Size is %d', video.size) osub_hash = None + + if "bsplayer" in providers: + video.hashes['bsplayer'] = osub_hash = hash_opensubtitles(hash_path) + if "opensubtitles" in providers: video.hashes['opensubtitles'] = osub_hash = hash_opensubtitles(hash_path) diff --git a/libs/subliminal_patch/providers/bsplayer.py b/libs/subliminal_patch/providers/bsplayer.py new file mode 100644 index 000000000..877db2523 --- /dev/null +++ b/libs/subliminal_patch/providers/bsplayer.py @@ -0,0 +1,240 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import +import logging +import re +import io +import os +import sys + +from requests import Session +from guessit import guessit +from babelfish import language_converters +from subliminal_patch.providers import Provider +from subliminal_patch.subtitle import Subtitle +from subliminal_patch.utils import sanitize +from subliminal.exceptions import ProviderError +from subliminal.utils import sanitize_release_group +from subliminal.subtitle import guess_matches +from subliminal.video import Episode, Movie +from subliminal.subtitle import fix_line_ending +from subzero.language import Language +from .utils import FIRST_THOUSAND_OR_SO_USER_AGENTS as AGENT_LIST + +import gzip +import random +from time import sleep +from xml.etree import ElementTree +import struct + +logger = logging.getLogger(__name__) + +class BSPlayerSubtitle(Subtitle): + """BSPlayer Subtitle.""" + provider_name = 'bsplayer' + + def __init__(self, language, filename, subtype, video, link): + super(BSPlayerSubtitle, self).__init__(language) + self.language = language + self.filename = filename + self.page_link = link + self.subtype = subtype + self.video = video + + @property + def id(self): + return self.page_link + + def get_matches(self, video): + matches = set() + + video_filename = video.name + video_filename = os.path.basename(video_filename) + video_filename, _ = os.path.splitext(video_filename) + video_filename = sanitize_release_group(video_filename) + + subtitle_filename = self.filename + subtitle_filename = os.path.basename(subtitle_filename) + subtitle_filename, _ = os.path.splitext(subtitle_filename) + subtitle_filename = sanitize_release_group(subtitle_filename) + + + matches |= guess_matches(video, guessit(self.filename)) + + matches.add(id(self)) + matches.add('hash') + + return matches + + + +class BSPlayerProvider(Provider): + """BSPlayer Provider.""" + languages = {Language('por', 'BR')} | {Language(l) for l in [ + 'ara', 'bul', 'ces', 'dan', 'deu', 'ell', 'eng', 'fin', 'fra', 'hun', 'ita', 'jpn', 'kor', 'nld', 'pol', 'por', + 'ron', 'rus', 'spa', 'swe', 'tur', 'ukr', 'zho' + ]} + SEARCH_THROTTLE = 8 + + # batantly based on kodi's bsplayer plugin + # also took from BSPlayer-Subtitles-Downloader + def __init__(self): + self.initialize() + + def initialize(self): + self.session = Session() + self.search_url = self.get_sub_domain() + self.token = None + self.login() + + def terminate(self): + self.session.close() + self.logout() + + def api_request(self, func_name='logIn', params='', tries=5): + headers = { + 'User-Agent': 'BSPlayer/2.x (1022.12360)', + 'Content-Type': 'text/xml; charset=utf-8', + 'Connection': 'close', + 'SOAPAction': '"http://api.bsplayer-subtitles.com/v1.php#{func_name}"'.format(func_name=func_name) + } + data = ( + '\n' + '' + '' + '{params}' + ).format(search_url=self.search_url, func_name=func_name, params=params) + logger.info('Sending request: %s.' % func_name) + for i in iter(range(tries)): + try: + self.session.headers.update(headers.items()) + res = self.session.post(self.search_url, data) + return ElementTree.fromstring(res.text) + + ### with requests + # res = requests.post( + # url=self.search_url, + # data=data, + # headers=headers + # ) + # return ElementTree.fromstring(res.text) + + except Exception as ex: + logger.info("ERROR: %s." % ex) + if func_name == 'logIn': + self.search_url = self.get_sub_domain() + sleep(1) + logger.info('ERROR: Too many tries (%d)...' % tries) + raise Exception('Too many tries...') + + def login(self): + # If already logged in + if self.token: + return True + + root = self.api_request( + func_name='logIn', + params=('' + '' + 'BSPlayer v2.67') + ) + res = root.find('.//return') + if res.find('status').text == 'OK': + self.token = res.find('data').text + logger.info("Logged In Successfully.") + return True + return False + + def logout(self): + # If already logged out / not logged in + if not self.token: + return True + + root = self.api_request( + func_name='logOut', + params='{token}'.format(token=self.token) + ) + res = root.find('.//return') + self.token = None + if res.find('status').text == 'OK': + logger.info("Logged Out Successfully.") + return True + return False + + def query(self, video, video_hash, language): + if not self.login(): + return [] + + if isinstance(language, (tuple, list, set)): + # language_ids = ",".join(language) + # language_ids = 'spa' + language_ids = ','.join(sorted(l.opensubtitles for l in language)) + + + if video.imdb_id is None: + imdbId = '*' + else: + imdbId = video.imdb_id + sleep(self.SEARCH_THROTTLE) + root = self.api_request( + func_name='searchSubtitles', + params=( + '{token}' + '{movie_hash}' + '{movie_size}' + '{language_ids}' + '{imdbId}' + ).format(token=self.token, movie_hash=video_hash, + movie_size=video.size, language_ids=language_ids, imdbId=imdbId) + ) + res = root.find('.//return/result') + if res.find('status').text != 'OK': + return [] + + items = root.findall('.//return/data/item') + subtitles = [] + if items: + logger.info("Subtitles Found.") + for item in items: + subID=item.find('subID').text + subDownloadLink=item.find('subDownloadLink').text + subLang= Language.fromopensubtitles(item.find('subLang').text) + subName=item.find('subName').text + subFormat=item.find('subFormat').text + subtitles.append( + BSPlayerSubtitle(subLang,subName, subFormat, video, subDownloadLink) + ) + return subtitles + + def list_subtitles(self, video, languages): + return self.query(video, video.hashes['bsplayer'], languages) + + def get_sub_domain(self): + # s1-9, s101-109 + SUB_DOMAINS = ['s1', 's2', 's3', 's4', 's5', 's6', 's7', 's8', 's9', + 's101', 's102', 's103', 's104', 's105', 's106', 's107', 's108', 's109'] + API_URL_TEMPLATE = "http://{sub_domain}.api.bsplayer-subtitles.com/v1.php" + sub_domains_end = len(SUB_DOMAINS) - 1 + return API_URL_TEMPLATE.format(sub_domain=SUB_DOMAINS[random.randint(0, sub_domains_end)]) + + def download_subtitle(self, subtitle): + session = Session() + _addheaders = { + 'User-Agent': 'Mozilla/4.0 (compatible; Synapse)' + } + session.headers.update(_addheaders) + res = session.get(subtitle.page_link) + if res: + if res.text == '500': + raise ValueError('Error 500 on server') + + with gzip.GzipFile(fileobj=io.BytesIO(res.content)) as gf: + subtitle.content = gf.read() + subtitle.normalize() + + return subtitle + raise ValueError('Problems conecting to the server') + + diff --git a/views/providers.tpl b/views/providers.tpl index e8c694411..08148e895 100644 --- a/views/providers.tpl +++ b/views/providers.tpl @@ -144,6 +144,22 @@ +
+
+ +
+
+
+ + +
+
+
+ +
+ +
+
-- cgit v1.2.3 From 0ddb78b59655c9aed062ed670cd67255ed2c2ec6 Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Fri, 10 Jan 2020 10:35:56 +0100 Subject: Forgot adding the BSPlayer provider in the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ef15757bf..b00e844e1 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ If you need something that is not already part of Bazarr, feel free to create a * Argenteam * Assrt * BetaSeries +* BSPlayer * GreekSubtitles * Hosszupuska * LegendasTV -- cgit v1.2.3 From e26f7fc49e86a6a8aaf78409c565bf1ba37af865 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Sun, 12 Jan 2020 15:27:14 +0100 Subject: Fixed: when receiving a SIGTERM signal, a smooth shutdown procedure should be performed on children processes. --- bazarr.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 7 deletions(-) diff --git a/bazarr.py b/bazarr.py index ae5d88f13..afb9b52c9 100644 --- a/bazarr.py +++ b/bazarr.py @@ -11,6 +11,7 @@ import os import sys import platform import re +import signal from bazarr.get_args import args @@ -39,15 +40,97 @@ check_python_version() dir_name = os.path.dirname(__file__) -def start_bazarr(): +class ProcessRegistry: + + def register(self, process): + pass + + def unregister(self, process): + pass + + +class DaemonStatus(ProcessRegistry): + + def __init__(self): + self.__should_stop = False + self.__processes = set() + + def register(self, process): + self.__processes.add(process) + + def unregister(self, process): + self.__processes.remove(process) + + ''' + Waits all the provided processes for the specified amount of time in seconds. + ''' + @staticmethod + def __wait_for_processes(processes, timeout): + reference_ts = time.time() + elapsed = 0 + remaining_processes = list(processes) + while elapsed < timeout and len(remaining_processes) > 0: + remaining_time = timeout - elapsed + for ep in list(remaining_processes): + if ep.poll() is not None: + remaining_processes.remove(ep) + else: + if remaining_time > 0: + if PY3: + try: + ep.wait(remaining_time) + remaining_processes.remove(ep) + except sp.TimeoutExpired: + pass + else: + ''' + In python 2 there is no such thing as some mechanism to wait with a timeout. + ''' + time.sleep(1) + elapsed = time.time() - reference_ts + remaining_time = timeout - elapsed + return remaining_processes + + ''' + Sends to every single of the specified processes the given signal and (if live_processes is not None) append to it processes which are still alive. + ''' + @staticmethod + def __send_signal(processes, signal_no, live_processes=None): + for ep in processes: + if ep.poll() is None: + if live_processes is not None: + live_processes.append(ep) + try: + ep.send_signal(signal_no) + except Exception as e: + print('Failed sending signal %s to process %s because of an unexpected error: %s' % (signal_no, ep.pid, e)) + return live_processes + + ''' + Flags this instance as should stop and terminates as smoothly as possible children processes. + ''' + def stop(self): + self.__should_stop = True + live_processes = DaemonStatus.__send_signal(self.__processes, signal.SIGINT, list()) + live_processes = DaemonStatus.__wait_for_processes(live_processes, 120) + DaemonStatus.__send_signal(live_processes, signal.SIGTERM) + + def should_stop(self): + return self.__should_stop + + +def start_bazarr(process_registry=ProcessRegistry()): script = [sys.executable, "-u", os.path.normcase(os.path.join(dir_name, 'bazarr', 'main.py'))] + sys.argv[1:] ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT, stdin=sp.PIPE) + process_registry.register(ep) print("Bazarr starting...") try: while True: line = ep.stdout.readline() if line == '' or not line: + # Process ended so let's unregister it + process_registry.unregister(ep) break if PY3: sys.stdout.buffer.write(line) @@ -73,7 +156,7 @@ if __name__ == '__main__': pass - def daemon(): + def daemon(daemonStatus): if os.path.exists(stopfile): try: os.remove(stopfile) @@ -89,12 +172,21 @@ if __name__ == '__main__': except: print('Unable to delete restart file.') else: - start_bazarr() + start_bazarr(daemonStatus) + + + daemonStatus = DaemonStatus() + def shutdown(): + # indicates that everything should stop + daemonStatus.stop() + # emulate a Ctrl C command on itself (bypasses the signal thing but, then, emulates the "Ctrl+C break") + os.kill(os.getpid(), signal.SIGINT) - start_bazarr() + signal.signal(signal.SIGTERM, lambda signal_no, frame: shutdown()) + start_bazarr(daemonStatus) - # Keep the script running forever. - while True: - daemon() + # Keep the script running forever until stop is requested through term or keyboard interrupt + while not daemonStatus.should_stop(): + daemon(daemonStatus) time.sleep(1) -- cgit v1.2.3 From 46b59cdae71722f7b99aa5917587fcbc68c90111 Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Thu, 16 Jan 2020 21:38:41 +0100 Subject: Provider LegendasDivx v1 --- README.md | 1 + bazarr/config.py | 4 + bazarr/get_providers.py | 5 +- bazarr/main.py | 4 + libs/subliminal_patch/providers/legendasdivx.py | 327 ++++++++++++++++++++++++ views/providers.tpl | 41 +++ 6 files changed, 381 insertions(+), 1 deletion(-) create mode 100644 libs/subliminal_patch/providers/legendasdivx.py diff --git a/README.md b/README.md index b00e844e1..418c33ac4 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ If you need something that is not already part of Bazarr, feel free to create a * BSPlayer * GreekSubtitles * Hosszupuska +* LegendasDivx * LegendasTV * Napiprojekt * Napisy24 diff --git a/bazarr/config.py b/bazarr/config.py index ca61871e0..b64040ebf 100644 --- a/bazarr/config.py +++ b/bazarr/config.py @@ -102,6 +102,10 @@ defaults = { 'password': '', 'random_agents': 'True' }, + 'legendasdivx': { + 'username': '', + 'password': '' + }, 'legendastv': { 'username': '', 'password': '' diff --git a/bazarr/get_providers.py b/bazarr/get_providers.py index c543f930d..d345b79ff 100644 --- a/bazarr/get_providers.py +++ b/bazarr/get_providers.py @@ -38,7 +38,7 @@ PROVIDER_THROTTLE_MAP = { } } -PROVIDERS_FORCED_OFF = ["addic7ed", "tvsubtitles", "legendastv", "napiprojekt", "shooter", "hosszupuska", +PROVIDERS_FORCED_OFF = ["addic7ed", "tvsubtitles", "legendasdivx", "legendastv", "napiprojekt", "shooter", "hosszupuska", "supersubtitles", "titlovi", "argenteam", "assrt", "subscene"] throttle_count = {} @@ -114,6 +114,9 @@ def get_providers_auth(): 'password': settings.subscene.password, 'only_foreign': False, # fixme }, + 'legendasdivx': {'username': settings.legendasdivx.username, + 'password': settings.legendasdivx.password, + }, 'legendastv': {'username': settings.legendastv.username, 'password': settings.legendastv.password, }, diff --git a/bazarr/main.py b/bazarr/main.py index 0a149e31c..2115e2976 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -398,6 +398,8 @@ def save_wizard(): settings.addic7ed.password = request.forms.get('settings_addic7ed_password') settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agents) settings.assrt.token = request.forms.get('settings_assrt_token') + settings.legendasdivx.username = request.forms.get('settings_legendasdivx_username') + settings.legendasdivx.password = request.forms.get('settings_legendasdivx_password') settings.legendastv.username = request.forms.get('settings_legendastv_username') settings.legendastv.password = request.forms.get('settings_legendastv_password') settings.opensubtitles.username = request.forms.get('settings_opensubtitles_username') @@ -1527,6 +1529,8 @@ def save_settings(): settings.addic7ed.password = request.forms.get('settings_addic7ed_password') settings.addic7ed.random_agents = text_type(settings_addic7ed_random_agents) settings.assrt.token = request.forms.get('settings_assrt_token') + settings.legendasdivx.username = request.forms.get('settings_legendasdivx_username') + settings.legendasdivx.password = request.forms.get('settings_legendasdivx_password') settings.legendastv.username = request.forms.get('settings_legendastv_username') settings.legendastv.password = request.forms.get('settings_legendastv_password') settings.opensubtitles.username = request.forms.get('settings_opensubtitles_username') diff --git a/libs/subliminal_patch/providers/legendasdivx.py b/libs/subliminal_patch/providers/legendasdivx.py new file mode 100644 index 000000000..a6d297b5d --- /dev/null +++ b/libs/subliminal_patch/providers/legendasdivx.py @@ -0,0 +1,327 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import +import logging +import io +import os +import sys +import rarfile +import zipfile + +from requests import Session +from guessit import guessit +from subliminal_patch.providers import Provider +from subliminal.providers import ParserBeautifulSoup +from subliminal_patch.subtitle import Subtitle +from subliminal_patch.utils import sanitize +from subliminal.exceptions import ProviderError +from subliminal.utils import sanitize_release_group +from subliminal.subtitle import guess_matches +from subliminal.video import Episode, Movie +from subliminal.subtitle import SUBTITLE_EXTENSIONS, fix_line_ending,guess_matches +from subzero.language import Language + +import gzip + +logger = logging.getLogger(__name__) + +class LegendasdivxSubtitle(Subtitle): + """Legendasdivx Subtitle.""" + provider_name = 'legendasdivx' + + def __init__(self, language, video, data): + super(LegendasdivxSubtitle, self).__init__(language) + self.language = language + self.page_link = data['link'] + self.hits=data['hits'] + self.exact_match=data['exact_match'] + self.description=data['description'].lower() + self.video = video + self.videoname =data['videoname'] + + @property + def id(self): + return self.page_link + + @property + def release_info(self): + return self.description + + def get_matches(self, video): + matches = set() + + logger.info('got %s' % self.videoname) + logger.info('got %s' % self.description) + logger.info('title %s' % video.title) + if self.videoname.lower() in self.description: + matches.update(['title']) + matches.update(['season']) + matches.update(['episode']) + + # episode + if video.title and video.title.lower() in self.description: + logger.info('title matched') + matches.update(['title']) + if video.year and '{:04d}'.format(video.year) in self.description: + logger.info('year matched') + matches.update(['year']) + + if isinstance(video, Episode): + # already matched in search query + if video.season and 's{:02d}'.format(video.season) in self.description: + logger.info('season matched') + matches.update(['season']) + if video.episode and 'e{:02d}'.format(video.episode) in self.description: + logger.info('episode matched') + matches.update(['episode']) + if video.episode and video.season and video.series: + if '{}.s{:02d}e{:02d}'.format(video.series.lower(),video.season,video.episode) in self.description: + logger.info('series matched') + matches.update(['series']) + matches.update(['season']) + matches.update(['episode']) + if '{} s{:02d}e{:02d}'.format(video.series.lower(),video.season,video.episode) in self.description: + logger.info('series matched') + matches.update(['series']) + matches.update(['season']) + matches.update(['episode']) + + logger.info('matches: %s' % matches) + # release_group + if video.release_group and video.release_group.lower() in self.description: + matches.update(['release_group']) + + # resolution + + if video.resolution and video.resolution.lower() in self.description: + matches.update(['resolution']) + + # format + formats = [] + if video.format: + formats = [video.format.lower()] + if formats[0] == "web-dl": + formats.append("webdl") + formats.append("webrip") + formats.append("web ") + for frmt in formats: + if frmt.lower() in self.description: + matches.update(['format']) + break + + # video_codec + if video.video_codec: + video_codecs = [video.video_codec.lower()] + if video_codecs[0] == "h264": + formats.append("x264") + elif video_codecs[0] == "h265": + formats.append("x265") + for vc in formats: + if vc.lower() in self.description: + matches.update(['video_codec']) + break + + matches |= guess_matches(video, guessit(self.description)) + return matches + + + + +class LegendasdivxProvider(Provider): + """Legendasdivx Provider.""" + languages = {Language('por', 'BR')} | {Language('por')} + SEARCH_THROTTLE = 8 + site = 'https://www.legendasdivx.pt' + headers = { + 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0', + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', + 'Origin': 'https://www.legendasdivx.pt', + 'Referer': 'https://www.legendasdivx.pt', + 'Pragma': 'no-cache', + 'Cache-Control': 'no-cache' + } + loginpage = site + '/forum/ucp.php?mode=login' + searchurl = site + '/modules.php?name=Downloads&file=jz&d_op=search&op=_jz00&query={query}' + language_list = list(languages) + + + def __init__(self, username, password): + self.username = username + self.password = password + + def initialize(self): + self.session = Session() + self.login() + + def terminate(self): + self.logout() + self.session.close() + + def login(self): + logger.info('Starting login') + self.headers['Referer'] = self.site + '/index.php' + self.session.headers.update(self.headers.items()) + res = self.session.get(self.loginpage) + bsoup = ParserBeautifulSoup(res.content, ['lxml']) + + _allinputs = bsoup.findAll('input') + fields = {} + for field in _allinputs: + fields[field.get('name')] = field.get('value') + logger.debug('%s: %s' % (field.get('name'), field.get('value'))) + + fields['username'] = self.username + fields['password'] = self.password + fields['autologin'] = 'on' + fields['viewonline'] = 'on' + + self.headers['Referer'] = self.loginpage + self.session.headers.update(self.headers.items()) + res = self.session.post(self.loginpage, fields) + try: + logger.debug('Got session id %s' % + self.session.cookies.get_dict()['PHPSESSID']) + except KeyError as e: + logger.error(repr(e)) + logger.error("Didn't get session id, check your credentials") + return False + except Exception as e: + logger.error(repr(e)) + logger.error('uncached error #legendasdivx #AA') + return False + + return True + def logout(self): + # need to figure this out + return True + + def query(self, video, language): + try: + logger.debug('Got session id %s' % + self.session.cookies.get_dict()['PHPSESSID']) + except Exception as e: + self.login() + return [] + + language_ids = '0' + if isinstance(language, (tuple, list, set)): + logger.error('language %s' % language) + if len(language) == 1: + language_ids = ','.join(sorted(l.opensubtitles for l in language)) + logger.error('language_ids %s' % language_ids) + if language_ids == 'por': + language_ids = '&form_cat=28' + else: + language_ids = '&form_cat=29' + + querytext = video.name + querytext = os.path.basename(querytext) + querytext, _ = os.path.splitext(querytext) + videoname = querytext + querytext = querytext.lower() + querytext = querytext.replace( + ".", "+").replace("[", "").replace("]", "") + if language_ids != '0': + querytext = querytext + language_ids + self.headers['Referer'] = self.site + '/index.php' + self.session.headers.update(self.headers.items()) + res = self.session.get(self.searchurl.format(query=querytext)) + # form_cat=28 = br + # form_cat=29 = pt + if "A legenda não foi encontrada" in res.text: + logger.warning('%s not found', querytext) + return [] + logger.warning(self.searchurl.format(query=querytext)) + + bsoup = ParserBeautifulSoup(res.content, ['html.parser']) + _allsubs = bsoup.findAll("div", {"class": "sub_box"}) + subtitles = [] + lang = Language.fromopensubtitles("pob") + for _subbox in _allsubs: + logger.info("============================================") + hits=0 + for th in _subbox.findAll("th", {"class": "color2"}): + if th.string == 'Hits:': + hits = int(th.parent.find("td").string) + if th.string == 'Idioma:': + lang = th.parent.find("td").find ("img").get ('src') + logger.debug('lang img %s' % lang) + if 'brazil' in lang: + lang = Language.fromopensubtitles('pob') + else: + lang = Language.fromopensubtitles('por') + + + description = _subbox.find("td", {"class": "td_desc brd_up"}) + download = _subbox.find("a", {"class": "sub_download"}) + try: + # sometimes BSoup just doesn't get the link + logger.debug(download.get('href')) + except Exception as e: + logger.warning('skipping subbox on %s' % self.searchurl.format(query=querytext)) + continue + + logger.info(hits) + exact_match = False + if video.name.lower() in description.get_text().lower(): + logger.info("exact match!") + exact_match = True + data = {'link': self.site + '/modules.php' + download.get('href'), + 'exact_match': exact_match, + 'hits': hits, + 'videoname': videoname, + 'description': description.get_text() } + subtitles.append( + LegendasdivxSubtitle(lang, video, data) + ) + + return subtitles + + def list_subtitles(self, video, languages): + return self.query(video, languages) + + def download_subtitle(self, subtitle): + res = self.session.get(subtitle.page_link) + if res: + if res.text == '500': + raise ValueError('Error 500 on server') + + archive = self._get_archive(res.content) + # extract the subtitle + subtitle_content = self._get_subtitle_from_archive(archive) + subtitle.content = fix_line_ending(subtitle_content) + subtitle.normalize() + + return subtitle + raise ValueError('Problems conecting to the server') + + def _get_archive(self, content): + # open the archive + # stole^H^H^H^H^H inspired from subvix provider + archive_stream = io.BytesIO(content) + if rarfile.is_rarfile(archive_stream): + logger.debug('Identified rar archive') + archive = rarfile.RarFile(archive_stream) + elif zipfile.is_zipfile(archive_stream): + logger.debug('Identified zip archive') + archive = zipfile.ZipFile(archive_stream) + else: + # raise ParseResponseError('Unsupported compressed format') + raise Exception('Unsupported compressed format') + + return archive + + def _get_subtitle_from_archive(self, archive): + logger.warning(archive.namelist()) + for name in archive.namelist(): + # discard hidden files + if os.path.split(name)[-1].startswith('.'): + continue + + # discard non-subtitle files + if not name.lower().endswith(SUBTITLE_EXTENSIONS): + continue + + logger.warning(name) + return archive.read(name) + + raise ParseResponseError('Can not find the subtitle in the compressed file') diff --git a/views/providers.tpl b/views/providers.tpl index 08148e895..510ee7857 100644 --- a/views/providers.tpl +++ b/views/providers.tpl @@ -226,6 +226,47 @@
+
+
+ +
+
+
+ + +
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+
+
+
-- cgit v1.2.3 From b4b7a3ed2e5004eb94ea54e852285a85560c43fe Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Thu, 16 Jan 2020 21:48:38 +0100 Subject: LegendasDivs: cleaning up debug logging --- libs/subliminal_patch/providers/legendasdivx.py | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/libs/subliminal_patch/providers/legendasdivx.py b/libs/subliminal_patch/providers/legendasdivx.py index a6d297b5d..df8a8aef7 100644 --- a/libs/subliminal_patch/providers/legendasdivx.py +++ b/libs/subliminal_patch/providers/legendasdivx.py @@ -49,9 +49,6 @@ class LegendasdivxSubtitle(Subtitle): def get_matches(self, video): matches = set() - logger.info('got %s' % self.videoname) - logger.info('got %s' % self.description) - logger.info('title %s' % video.title) if self.videoname.lower() in self.description: matches.update(['title']) matches.update(['season']) @@ -59,33 +56,26 @@ class LegendasdivxSubtitle(Subtitle): # episode if video.title and video.title.lower() in self.description: - logger.info('title matched') matches.update(['title']) if video.year and '{:04d}'.format(video.year) in self.description: - logger.info('year matched') matches.update(['year']) if isinstance(video, Episode): # already matched in search query if video.season and 's{:02d}'.format(video.season) in self.description: - logger.info('season matched') matches.update(['season']) if video.episode and 'e{:02d}'.format(video.episode) in self.description: - logger.info('episode matched') matches.update(['episode']) if video.episode and video.season and video.series: if '{}.s{:02d}e{:02d}'.format(video.series.lower(),video.season,video.episode) in self.description: - logger.info('series matched') matches.update(['series']) matches.update(['season']) matches.update(['episode']) if '{} s{:02d}e{:02d}'.format(video.series.lower(),video.season,video.episode) in self.description: - logger.info('series matched') matches.update(['series']) matches.update(['season']) matches.update(['episode']) - logger.info('matches: %s' % matches) # release_group if video.release_group and video.release_group.lower() in self.description: matches.update(['release_group']) @@ -157,7 +147,7 @@ class LegendasdivxProvider(Provider): self.session.close() def login(self): - logger.info('Starting login') + logger.info('Logging in') self.headers['Referer'] = self.site + '/index.php' self.session.headers.update(self.headers.items()) res = self.session.get(self.loginpage) @@ -167,7 +157,6 @@ class LegendasdivxProvider(Provider): fields = {} for field in _allinputs: fields[field.get('name')] = field.get('value') - logger.debug('%s: %s' % (field.get('name'), field.get('value'))) fields['username'] = self.username fields['password'] = self.password @@ -204,10 +193,8 @@ class LegendasdivxProvider(Provider): language_ids = '0' if isinstance(language, (tuple, list, set)): - logger.error('language %s' % language) if len(language) == 1: language_ids = ','.join(sorted(l.opensubtitles for l in language)) - logger.error('language_ids %s' % language_ids) if language_ids == 'por': language_ids = '&form_cat=28' else: @@ -230,21 +217,18 @@ class LegendasdivxProvider(Provider): if "A legenda não foi encontrada" in res.text: logger.warning('%s not found', querytext) return [] - logger.warning(self.searchurl.format(query=querytext)) bsoup = ParserBeautifulSoup(res.content, ['html.parser']) _allsubs = bsoup.findAll("div", {"class": "sub_box"}) subtitles = [] lang = Language.fromopensubtitles("pob") for _subbox in _allsubs: - logger.info("============================================") hits=0 for th in _subbox.findAll("th", {"class": "color2"}): if th.string == 'Hits:': hits = int(th.parent.find("td").string) if th.string == 'Idioma:': lang = th.parent.find("td").find ("img").get ('src') - logger.debug('lang img %s' % lang) if 'brazil' in lang: lang = Language.fromopensubtitles('pob') else: @@ -255,15 +239,12 @@ class LegendasdivxProvider(Provider): download = _subbox.find("a", {"class": "sub_download"}) try: # sometimes BSoup just doesn't get the link - logger.debug(download.get('href')) except Exception as e: logger.warning('skipping subbox on %s' % self.searchurl.format(query=querytext)) continue - logger.info(hits) exact_match = False if video.name.lower() in description.get_text().lower(): - logger.info("exact match!") exact_match = True data = {'link': self.site + '/modules.php' + download.get('href'), 'exact_match': exact_match, @@ -311,7 +292,6 @@ class LegendasdivxProvider(Provider): return archive def _get_subtitle_from_archive(self, archive): - logger.warning(archive.namelist()) for name in archive.namelist(): # discard hidden files if os.path.split(name)[-1].startswith('.'): @@ -321,7 +301,6 @@ class LegendasdivxProvider(Provider): if not name.lower().endswith(SUBTITLE_EXTENSIONS): continue - logger.warning(name) return archive.read(name) raise ParseResponseError('Can not find the subtitle in the compressed file') -- cgit v1.2.3 From 6677d206868130da7ebbdbf165700e6f5a4f0a7d Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Thu, 16 Jan 2020 23:13:44 -0500 Subject: Quick fix for #752 --- libs/subliminal_patch/providers/legendasdivx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/subliminal_patch/providers/legendasdivx.py b/libs/subliminal_patch/providers/legendasdivx.py index df8a8aef7..2eec7c326 100644 --- a/libs/subliminal_patch/providers/legendasdivx.py +++ b/libs/subliminal_patch/providers/legendasdivx.py @@ -239,6 +239,7 @@ class LegendasdivxProvider(Provider): download = _subbox.find("a", {"class": "sub_download"}) try: # sometimes BSoup just doesn't get the link + logger.debug(download.get('href')) except Exception as e: logger.warning('skipping subbox on %s' % self.searchurl.format(query=querytext)) continue -- cgit v1.2.3 From 22ce5dc450cf1d3f9d1d736155d088688420c8a8 Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Sat, 18 Jan 2020 12:58:22 +0100 Subject: LegendasDivx: adding missing import ParseResponseError --- libs/subliminal_patch/providers/legendasdivx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/subliminal_patch/providers/legendasdivx.py b/libs/subliminal_patch/providers/legendasdivx.py index 2eec7c326..67736db83 100644 --- a/libs/subliminal_patch/providers/legendasdivx.py +++ b/libs/subliminal_patch/providers/legendasdivx.py @@ -9,6 +9,7 @@ import zipfile from requests import Session from guessit import guessit +from subliminal_patch.exceptions import ParseResponseError from subliminal_patch.providers import Provider from subliminal.providers import ParserBeautifulSoup from subliminal_patch.subtitle import Subtitle -- cgit v1.2.3 From 304ee8766ce592a5f4457e7c8d62a24ef69969e4 Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Sat, 18 Jan 2020 12:59:14 +0100 Subject: Adding release info to bsplayer and subdvix providers --- libs/subliminal_patch/providers/bsplayer.py | 4 ++++ libs/subliminal_patch/providers/subdivx.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libs/subliminal_patch/providers/bsplayer.py b/libs/subliminal_patch/providers/bsplayer.py index 877db2523..33077895b 100644 --- a/libs/subliminal_patch/providers/bsplayer.py +++ b/libs/subliminal_patch/providers/bsplayer.py @@ -44,6 +44,10 @@ class BSPlayerSubtitle(Subtitle): def id(self): return self.page_link + @property + def release_info(self): + return self.filename + def get_matches(self, video): matches = set() diff --git a/libs/subliminal_patch/providers/subdivx.py b/libs/subliminal_patch/providers/subdivx.py index ab7db33b6..74b3c4f7b 100644 --- a/libs/subliminal_patch/providers/subdivx.py +++ b/libs/subliminal_patch/providers/subdivx.py @@ -35,6 +35,10 @@ class SubdivxSubtitle(Subtitle): def id(self): return self.page_link + @property + def release_info(self): + return self.description + def get_matches(self, video): matches = set() -- cgit v1.2.3 From 6291cf7134a6430761ae7f4bb80c5e7da860f920 Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Sat, 18 Jan 2020 13:02:37 +0100 Subject: removing unneeded imports from bsplayer and legendasdivx --- libs/subliminal_patch/providers/bsplayer.py | 9 --------- libs/subliminal_patch/providers/legendasdivx.py | 9 +-------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/libs/subliminal_patch/providers/bsplayer.py b/libs/subliminal_patch/providers/bsplayer.py index 33077895b..9839a0331 100644 --- a/libs/subliminal_patch/providers/bsplayer.py +++ b/libs/subliminal_patch/providers/bsplayer.py @@ -1,30 +1,21 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import import logging -import re import io import os -import sys from requests import Session from guessit import guessit -from babelfish import language_converters from subliminal_patch.providers import Provider from subliminal_patch.subtitle import Subtitle -from subliminal_patch.utils import sanitize -from subliminal.exceptions import ProviderError from subliminal.utils import sanitize_release_group from subliminal.subtitle import guess_matches -from subliminal.video import Episode, Movie -from subliminal.subtitle import fix_line_ending from subzero.language import Language -from .utils import FIRST_THOUSAND_OR_SO_USER_AGENTS as AGENT_LIST import gzip import random from time import sleep from xml.etree import ElementTree -import struct logger = logging.getLogger(__name__) diff --git a/libs/subliminal_patch/providers/legendasdivx.py b/libs/subliminal_patch/providers/legendasdivx.py index 67736db83..ae40ed482 100644 --- a/libs/subliminal_patch/providers/legendasdivx.py +++ b/libs/subliminal_patch/providers/legendasdivx.py @@ -3,7 +3,6 @@ from __future__ import absolute_import import logging import io import os -import sys import rarfile import zipfile @@ -13,16 +12,10 @@ from subliminal_patch.exceptions import ParseResponseError from subliminal_patch.providers import Provider from subliminal.providers import ParserBeautifulSoup from subliminal_patch.subtitle import Subtitle -from subliminal_patch.utils import sanitize -from subliminal.exceptions import ProviderError -from subliminal.utils import sanitize_release_group -from subliminal.subtitle import guess_matches -from subliminal.video import Episode, Movie +from subliminal.video import Episode from subliminal.subtitle import SUBTITLE_EXTENSIONS, fix_line_ending,guess_matches from subzero.language import Language -import gzip - logger = logging.getLogger(__name__) class LegendasdivxSubtitle(Subtitle): -- cgit v1.2.3 From 7d5fdafe0ca5e064edac5c9dde6da295f3c4e95f Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Sat, 18 Jan 2020 14:20:53 +0100 Subject: LegendasDivxs: skipping .txt files from archived file --- libs/subliminal_patch/providers/legendasdivx.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/subliminal_patch/providers/legendasdivx.py b/libs/subliminal_patch/providers/legendasdivx.py index ae40ed482..5537e5828 100644 --- a/libs/subliminal_patch/providers/legendasdivx.py +++ b/libs/subliminal_patch/providers/legendasdivx.py @@ -287,15 +287,21 @@ class LegendasdivxProvider(Provider): return archive def _get_subtitle_from_archive(self, archive): + # some files have a non subtitle with .txt extension + _tmp = list(SUBTITLE_EXTENSIONS) + _tmp.remove('.txt') + _subtitle_extensions = tuple(_tmp) + for name in archive.namelist(): # discard hidden files if os.path.split(name)[-1].startswith('.'): continue # discard non-subtitle files - if not name.lower().endswith(SUBTITLE_EXTENSIONS): + if not name.lower().endswith(_subtitle_extensions): continue + logger.debug("returning from archive: %s" % name) return archive.read(name) raise ParseResponseError('Can not find the subtitle in the compressed file') -- cgit v1.2.3 From 314c1f90e510749b3c75f767b43e9dccb013a1df Mon Sep 17 00:00:00 2001 From: panni Date: Sun, 19 Jan 2020 05:23:25 +0100 Subject: update subliminal_patch; possibly fix bazarr#656 --- libs/subliminal_patch/subtitle.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/libs/subliminal_patch/subtitle.py b/libs/subliminal_patch/subtitle.py index 8116697bf..43e9a9716 100644 --- a/libs/subliminal_patch/subtitle.py +++ b/libs/subliminal_patch/subtitle.py @@ -358,6 +358,15 @@ class ModifiedSubtitle(Subtitle): id = None +MERGED_FORMATS = { + "TV": ("HDTV", "SDTV", "AHDTV", "UHDTV"), + "Air": ("SATRip", "DVB", "PPV"), + "Disk": ("DVD", "HD-DVD", "BluRay") +} + +MERGED_FORMATS_REV = dict((v.lower(), k.lower()) for k in MERGED_FORMATS for v in MERGED_FORMATS[k]) + + def guess_matches(video, guess, partial=False): """Get matches between a `video` and a `guess`. @@ -386,12 +395,15 @@ def guess_matches(video, guess, partial=False): for title in titles: if sanitize(title) in (sanitize(name) for name in [video.series] + video.alternative_series): matches.add('series') + # title if video.title and 'episode_title' in guess and sanitize(guess['episode_title']) == sanitize(video.title): matches.add('title') + # season if video.season and 'season' in guess and guess['season'] == video.season: matches.add('season') + # episode # Currently we only have single-ep support (guessit returns a multi-ep as a list with int values) # Most providers only support single-ep, so make sure it contains only 1 episode @@ -401,12 +413,15 @@ def guess_matches(video, guess, partial=False): episode = min(episode_guess) if episode_guess and isinstance(episode_guess, list) else episode_guess if episode == video.episode: matches.add('episode') + # year if video.year and 'year' in guess and guess['year'] == video.year: matches.add('year') + # count "no year" as an information if not partial and video.original_series and 'year' not in guess: matches.add('year') + elif isinstance(video, Movie): # year if video.year and 'year' in guess and guess['year'] == video.year: @@ -440,21 +455,25 @@ def guess_matches(video, guess, partial=False): formats = [formats] if video.format: - video_format = video.format - if video_format in ("HDTV", "SDTV", "TV"): - video_format = "TV" - logger.debug("Treating HDTV/SDTV the same") + video_format = video.format.lower() + _video_gen_format = MERGED_FORMATS_REV.get(video_format) + if _video_gen_format: + logger.debug("Treating %s as %s the same", video_format, _video_gen_format) for frmt in formats: - if frmt in ("HDTV", "SDTV"): - frmt = "TV" + _guess_gen_frmt = MERGED_FORMATS_REV.get(frmt.lower()) - if frmt.lower() == video_format.lower(): + if _guess_gen_frmt == _video_gen_format: matches.add('format') break + if "release_group" in matches and "format" not in matches: + logger.info("Release group matched but format didn't. Remnoving release group match.") + matches.remove("release_group") + # video_codec if video.video_codec and 'video_codec' in guess and guess['video_codec'] == video.video_codec: matches.add('video_codec') + # audio_codec if video.audio_codec and 'audio_codec' in guess and guess['audio_codec'] == video.audio_codec: matches.add('audio_codec') -- cgit v1.2.3 From 02c3c98cf80b8f447dcc7561ebc1adcd4213ed48 Mon Sep 17 00:00:00 2001 From: Smaarn Date: Sun, 19 Jan 2020 14:46:27 +0100 Subject: Fixed: when receiving a SIGTERM signal, a smooth shutdown procedure should be performed on children processes. Reverted the change for Python 2 --- bazarr.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/bazarr.py b/bazarr.py index afb9b52c9..f9228e2be 100644 --- a/bazarr.py +++ b/bazarr.py @@ -156,7 +156,7 @@ if __name__ == '__main__': pass - def daemon(daemonStatus): + def daemon(bazarr_runner = lambda: start_bazarr()): if os.path.exists(stopfile): try: os.remove(stopfile) @@ -172,21 +172,30 @@ if __name__ == '__main__': except: print('Unable to delete restart file.') else: - start_bazarr(daemonStatus) + bazarr_runner() - daemonStatus = DaemonStatus() + bazarr_runner = lambda: start_bazarr() - def shutdown(): - # indicates that everything should stop - daemonStatus.stop() - # emulate a Ctrl C command on itself (bypasses the signal thing but, then, emulates the "Ctrl+C break") - os.kill(os.getpid(), signal.SIGINT) + should_stop = lambda: False - signal.signal(signal.SIGTERM, lambda signal_no, frame: shutdown()) - start_bazarr(daemonStatus) + if PY3: + daemonStatus = DaemonStatus() + + def shutdown(): + # indicates that everything should stop + daemonStatus.stop() + # emulate a Ctrl C command on itself (bypasses the signal thing but, then, emulates the "Ctrl+C break") + os.kill(os.getpid(), signal.SIGINT) + + signal.signal(signal.SIGTERM, lambda signal_no, frame: shutdown()) + + should_stop = lambda: daemonStatus.should_stop() + bazarr_runner = lambda: start_bazarr(daemonStatus) + + bazarr_runner() # Keep the script running forever until stop is requested through term or keyboard interrupt - while not daemonStatus.should_stop(): - daemon(daemonStatus) + while not should_stop(): + daemon(bazarr_runner) time.sleep(1) -- cgit v1.2.3