feat: Add per-provider language exclusions#151
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad21deb5db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| # check whether we want to search this provider for the languages | ||
| use_languages = languages_search_base & languages | ||
| use_languages = languages - excluded_languages |
There was a problem hiding this comment.
Exclude all variants of a language, not only exact flags
The new exclusion logic subtracts excluded_languages from languages by exact Language object equality, so excluding eng does not remove requests like eng:hi or eng:forced. This regression is reachable because the settings UI only stores base language codes (no :hi/:forced variants), while requested subtitle sets can contain flagged variants from profile/missing-subtitle flows; in that case the provider is still queried for a language the user explicitly excluded. Consider normalizing exclusions by base language (or expanding exclusions to all flag variants) before computing use_languages.
Useful? React with 👍 / 👎.
| [`settings-general-provider_languages-${info?.key}`]: | ||
| seededProviderLanguageExclusions[info?.key ?? ""] ?? [], |
There was a problem hiding this comment.
Restrict provider-language staging to provider settings only
This field is seeded for every ProviderTool instance, including the integrations drawer (settings-general-enabled_integrations). In that path, submit does not remove the temporary settings-general-provider_languages-<key> entry, so saving an integration posts a synthetic general.provider_languages.<integration> key (empty string via form encoding), polluting config with non-provider entries. Gate this seed behind settingsKey === "settings-general-enabled_providers" (or always delete the temp key before submit).
Useful? React with 👍 / 👎.
| blacklist=None, | ||
| ban_list=None, | ||
| language_hook=None, | ||
| language_hook=get_provider_language_hook(), |
There was a problem hiding this comment.
Include provider-language exclusions in compat cache invalidation
Adding language_hook=get_provider_language_hook() makes compat search results depend on general.provider_languages, but compat cache keys are still derived from media/request params and enabled providers only. After an operator changes per-provider exclusions, /api/v1/subtitles can continue serving stale cached entries that ignore the new exclusions until TTL expiry. The new dependency needs cache-key coverage (or explicit compat cache invalidation on settings save) so exclusions take effect immediately.
Useful? React with 👍 / 👎.
| ...staged, | ||
| [`settings-general-provider_priorities-${info?.key}`]: | ||
| seededPriorities[info?.key ?? ""] ?? 100, | ||
| [`settings-general-provider_languages-${info?.key}`]: |
There was a problem hiding this comment.
Remove undefined language key when adding a new provider
When the drawer opens in “add provider” mode (payload === null), info?.key is undefined, so the form seeds a temporary field named settings-general-provider_languages-undefined. During submit, only the real provider key is deleted, leaving this synthetic field in changes; once persisted, it creates a bogus general.provider_languages.undefined entry in config. This is a new data pollution path for normal add-provider saves and should be prevented by skipping seed until info.key exists (or deleting the -undefined key before submit).
Useful? React with 👍 / 👎.
Seven fixes from review of PRs #137 / #151 / #152 / #154 / #157. Held back from v2.3.1 patch line; targeted at the next release. Auto-translation: - Pass real episode/movie metadata to translate_subtitles_file from _trigger_auto_translation and from both wanted-scan paths. None was crashing postprocess_subtitles on plex/jellyfin refresh. - Re-queue translation when the previously translated subtitle file no longer exists on disk. Old guard only checked for an action=6 history row, so deletes/moves left the target language permanently unsatisfied. Provider language exclusions: - Set subtraction in SZProviderPool now compares by alpha3/country/ script so excluding base 'eng' also excludes 'eng:hi' and 'eng:forced'. Language.__eq__ includes hi/forced flags, so plain set difference missed variants. - save_settings now treats provider_languages changes the same as enabled_providers changes and resets the compat pool, so the cache picks up exclusion edits without waiting for TTL. Embedded subtitle history: - _log_embedded_history{,_movie} now receives the DB-side path (original_path) instead of the local filesystem path. Brings embedded action=7 rows in line with download rows in path-mapped installs. Provider settings UI: - ProviderTool no longer seeds settings-general-provider_languages- undefined when the drawer opens in add-provider mode. - The temporary provider_languages staging key is cleaned out of changes for integrations drawers too, not just provider drawers.
https://bazarr.featureupvote.com/suggestions/78910/per-provider-language
Summary
general.provider_languagesas the stored config key, now interpreted as excluded languagesValidation
pytest -q tests/bazarr/test_app_get_providers.py tests/compat/unit/test_provider_languages.py tests/subliminal_patch/test_core.py::test_language_hook_none_keeps_requested_languages tests/subliminal_patch/test_core.py::test_language_hook_excludes_configured_languagesruff check bazarr/app/get_providers.py custom_libs/subliminal_patch/core.py bazarr/subtitles/pool.py bazarr/compat/service.py tests/bazarr/test_app_get_providers.py tests/compat/unit/test_provider_languages.py tests/subliminal_patch/test_core.pynpm run test -- --run src/pages/Settings/Providers/hub/__tests__/hub.test.tsxnpm run check:tsnpm run buildbazarr-ui-test: backend hook exclusions, provider pool exclusion behavior, served frontend bundle text, and compat Matrix Hungarian search excluding OpenSubtitles/OpenSubtitles.com/SubtitleCat