Skip to content

feat: Add per-provider language exclusions#151

Merged
LavX merged 2 commits into
developmentfrom
provider-language-settings
May 26, 2026
Merged

feat: Add per-provider language exclusions#151
LavX merged 2 commits into
developmentfrom
provider-language-settings

Conversation

@LavX

@LavX LavX commented May 25, 2026

Copy link
Copy Markdown
Owner

https://bazarr.featureupvote.com/suggestions/78910/per-provider-language

Summary

  • add per-provider language exclusion settings in the provider drawer
  • apply exclusions to native and compat provider pools before provider queries
  • keep general.provider_languages as the stored config key, now interpreted as excluded languages

Validation

  • 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_languages
  • ruff 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.py
  • npm run test -- --run src/pages/Settings/Providers/hub/__tests__/hub.test.tsx
  • npm run check:ts
  • npm run build
  • validated on bazarr-ui-test: backend hook exclusions, provider pool exclusion behavior, served frontend bundle text, and compat Matrix Hungarian search excluding OpenSubtitles/OpenSubtitles.com/SubtitleCat

@LavX LavX changed the title Add per-provider language exclusions feat: Add per-provider language exclusions May 25, 2026
@LavX
LavX marked this pull request as ready for review May 26, 2026 08:59
@LavX
LavX merged commit 4316ea5 into development May 26, 2026
5 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +763 to +764
[`settings-general-provider_languages-${info?.key}`]:
seededProviderLanguageExclusions[info?.key ?? ""] ?? [],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread bazarr/compat/service.py
blacklist=None,
ban_list=None,
language_hook=None,
language_hook=get_provider_language_hook(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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}`]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@LavX
LavX deleted the provider-language-settings branch May 26, 2026 14:10
LavX added a commit that referenced this pull request May 28, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant