summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bazarr/subtitles/download.py20
-rw-r--r--bazarr/subtitles/manual.py10
-rw-r--r--bazarr/subtitles/utils.py15
3 files changed, 22 insertions, 23 deletions
diff --git a/bazarr/subtitles/download.py b/bazarr/subtitles/download.py
index 50562b91b..64321a9d8 100644
--- a/bazarr/subtitles/download.py
+++ b/bazarr/subtitles/download.py
@@ -17,7 +17,7 @@ from languages.get_languages import alpha3_from_alpha2
from subtitles.tools.score import movie_score, series_score
from .pool import update_pools, _get_pool
-from .utils import get_video, _get_lang_obj, _get_scores
+from .utils import get_video, _get_lang_obj, _get_scores, _set_forced_providers
from .processing import process_subtitle
@@ -39,8 +39,9 @@ def generate_subtitles(path, languages, audio_language, sceneName, title, media_
language_set = _get_language_obj(languages=languages)
hi_required = any([x.hi for x in language_set])
- forced_required = any([x.forced for x in language_set])
- _set_forced_providers(forced_required=forced_required, pool=pool)
+ also_forced = any([x.forced for x in language_set])
+ forced_required = all([x.forced for x in language_set])
+ _set_forced_providers(pool=pool, also_forced=also_forced, forced_required=forced_required)
video = get_video(force_unicode(path), title, sceneName, providers=providers, media_type=media_type)
@@ -140,16 +141,3 @@ def _get_language_obj(languages):
language_set.add(lang_obj)
return language_set
-
-
-def _set_forced_providers(forced_required, pool):
- # TODO: maybe a separate pool for forced configs? only_foreign is hardcoded
- # in get_providers and this causes updating the pool on every call
- if forced_required:
- pool.provider_configs.update(
- {
- "podnapisi": {"only_foreign": True},
- "subscene": {"only_foreign": True},
- "opensubtitles": {"only_foreign": True}
- }
- )
diff --git a/bazarr/subtitles/manual.py b/bazarr/subtitles/manual.py
index b8a1df056..b8ac51250 100644
--- a/bazarr/subtitles/manual.py
+++ b/bazarr/subtitles/manual.py
@@ -20,7 +20,7 @@ from app.database import get_profiles_list
from subtitles.tools.score import movie_score, series_score
from .pool import update_pools, _get_pool, _init_pool
-from .utils import get_video, _get_lang_obj, _get_scores
+from .utils import get_video, _get_lang_obj, _get_scores, _set_forced_providers
from .processing import process_subtitle
@@ -34,7 +34,8 @@ def manual_search(path, profile_id, providers, sceneName, title, media_type):
language_set, initial_language_set, original_format = _get_language_obj(profile_id=profile_id)
also_forced = any([x.forced for x in initial_language_set])
- _set_forced_providers(also_forced=also_forced, pool=pool)
+ forced_required = all([x.forced for x in initial_language_set])
+ _set_forced_providers(pool=pool, also_forced=also_forced, forced_required=forced_required)
if providers:
video = get_video(force_unicode(path), title, sceneName, providers=providers, media_type=media_type)
@@ -264,8 +265,3 @@ def _get_language_obj(profile_id):
language_set.add(lang_obj_hi)
return language_set, initial_language_set, original_format
-
-
-def _set_forced_providers(also_forced, pool):
- if also_forced:
- pool.provider_configs.update({'podnapisi': {'also_foreign': True}, 'opensubtitles': {'also_foreign': True}})
diff --git a/bazarr/subtitles/utils.py b/bazarr/subtitles/utils.py
index 1163ab6e7..dbeeaf3e3 100644
--- a/bazarr/subtitles/utils.py
+++ b/bazarr/subtitles/utils.py
@@ -84,3 +84,18 @@ def get_ban_list(profile_id):
return {'must_contain': profile['mustContain'] or [],
'must_not_contain': profile['mustNotContain'] or []}
return None
+
+
+def _set_forced_providers(pool, also_forced=False, forced_required=False):
+ # TODO: maybe a separate pool for forced configs? also_foreign/only_foreign is hardcoded
+ # in get_providers and this causes updating the pool on every call
+ if also_forced and forced_required:
+ logging.debug('also_forced and forced_required cannot be both True. also_forced will prevail.')
+ forced_required = False
+ pool.provider_configs.update(
+ {
+ "podnapisi": {'also_foreign': also_forced, "only_foreign": forced_required},
+ "subscene": {"only_foreign": forced_required},
+ "opensubtitles": {'also_foreign': also_forced, "only_foreign": forced_required}
+ }
+ )