diff options
author | morpheus65535 <[email protected]> | 2022-01-08 14:26:40 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2022-01-08 14:26:40 -0500 |
commit | 58a967c892ef78cb6cf8ab790c2af8728e8c079e (patch) | |
tree | 3a80020628f9366c2daa700a1c762d4693c0cdb3 | |
parent | 926f3d1f145596d1946e5be28db9b10e0dd20d74 (diff) | |
download | bazarr-58a967c892ef78cb6cf8ab790c2af8728e8c079e.tar.gz bazarr-58a967c892ef78cb6cf8ab790c2af8728e8c079e.zip |
Added settings to change the hearing-impaired subtitles file extension to use when saving to disk.
-rw-r--r-- | bazarr/config.py | 6 | ||||
-rw-r--r-- | bazarr/init.py | 3 | ||||
-rw-r--r-- | frontend/src/Settings/Subtitles/index.tsx | 11 | ||||
-rw-r--r-- | frontend/src/Settings/Subtitles/options.ts | 15 | ||||
-rw-r--r-- | libs/subliminal_patch/core.py | 7 |
5 files changed, 40 insertions, 2 deletions
diff --git a/bazarr/config.py b/bazarr/config.py index a577da32a..843e92823 100644 --- a/bazarr/config.py +++ b/bazarr/config.py @@ -73,7 +73,8 @@ defaults = { 'wanted_search_frequency': '3', 'wanted_search_frequency_movie': '3', 'subzero_mods': '[]', - 'dont_notify_manual_actions': 'False' + 'dont_notify_manual_actions': 'False', + 'hi_extension': 'hi' }, 'auth': { 'type': 'None', @@ -368,6 +369,9 @@ def save_settings(settings_items): if key == 'settings-general-debug': configure_debug = True + if key == 'settings-general-hi_extension': + os.environ["SZ_HI_EXTENSION"] = str(value) + if key in ['settings-general-anti_captcha_provider', 'settings-anticaptcha-anti_captcha_key', 'settings-deathbycaptcha-username', 'settings-deathbycaptcha-password']: configure_captcha = True diff --git a/bazarr/init.py b/bazarr/init.py index fffac5ee5..2d94b858c 100644 --- a/bazarr/init.py +++ b/bazarr/init.py @@ -23,6 +23,9 @@ startTime = time.time() # set subliminal_patch user agent os.environ["SZ_USER_AGENT"] = "Bazarr/{}".format(os.environ["BAZARR_VERSION"]) +# set subliminal_patch hearing-impaired extension to use when naming subtitles +os.environ["SZ_HI_EXTENSION"] = settings.general.hi_extension + # set anti-captcha provider and key configure_captcha_func() diff --git a/frontend/src/Settings/Subtitles/index.tsx b/frontend/src/Settings/Subtitles/index.tsx index 20bdc72d7..17e5f1d56 100644 --- a/frontend/src/Settings/Subtitles/index.tsx +++ b/frontend/src/Settings/Subtitles/index.tsx @@ -16,6 +16,7 @@ import { antiCaptchaOption, colorOptions, folderOptions, + hiExtensionOptions, } from "./options"; const subzeroOverride = (key: string) => { @@ -87,6 +88,16 @@ const SettingsSubtitlesView: FunctionComponent = () => { </Input> </CollapseBox.Content> </CollapseBox> + <Input name="Hearing-impaired subtitles extension"> + <Selector + options={hiExtensionOptions} + settingKey="settings-general-hi_extension" + ></Selector> + <Message> + What file extension to use when saving hearing-impaired subtitles to + disk (e.g., video.en.sdh.srt). + </Message> + </Input> </Group> <Group header="Anti-Captcha Options"> <CollapseBox> diff --git a/frontend/src/Settings/Subtitles/options.ts b/frontend/src/Settings/Subtitles/options.ts index 88cfe7ee6..fe6adaa2a 100644 --- a/frontend/src/Settings/Subtitles/options.ts +++ b/frontend/src/Settings/Subtitles/options.ts @@ -1,3 +1,18 @@ +export const hiExtensionOptions: SelectorOption<string>[] = [ + { + label: ".hi (Hearing-Impaired)", + value: "hi", + }, + { + label: ".sdh (Subtitles for the Deaf or Hard-of-Hearing)", + value: "sdh", + }, + { + label: ".cc (Close Captioned)", + value: "cc", + }, +]; + export const folderOptions: SelectorOption<string>[] = [ { label: "AlongSide Media File", diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index 08415a3c5..3ecd9d1b6 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -1011,17 +1011,22 @@ def get_subtitle_path(video_path, language=None, extension='.srt', forced_tag=Fa :param language: language of the subtitle to put in the path. :type language: :class:`~babelfish.language.Language` :param str extension: extension of the subtitle. + :param bool forced_tag: is the subtitles forced/foreign? + :param bool hi_tag: is the subtitles hearing-impaired? + :param list tags: list of custom tags :return: path of the subtitle. :rtype: str """ subtitle_root = os.path.splitext(video_path)[0] tags = tags or [] + hi_extension = os.environ.get("SZ_HI_EXTENSION", "hi") + if forced_tag: tags.append("forced") elif hi_tag: - tags.append("hi") + tags.append(hi_extension) if language: subtitle_root += '.' + str(language.basename) |