Added settings to change the hearing-impaired subtitles file extension to use when saving to disk.

This commit is contained in:
morpheus65535 2022-01-08 14:26:40 -05:00
parent 926f3d1f14
commit 58a967c892
5 changed files with 40 additions and 2 deletions

View File

@ -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

View File

@ -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()

View File

@ -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>

View File

@ -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",

View File

@ -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)