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

pull/1668/head^2
morpheus65535 2 years ago
parent 926f3d1f14
commit 58a967c892

@ -73,7 +73,8 @@ defaults = {
'wanted_search_frequency': '3', 'wanted_search_frequency': '3',
'wanted_search_frequency_movie': '3', 'wanted_search_frequency_movie': '3',
'subzero_mods': '[]', 'subzero_mods': '[]',
'dont_notify_manual_actions': 'False' 'dont_notify_manual_actions': 'False',
'hi_extension': 'hi'
}, },
'auth': { 'auth': {
'type': 'None', 'type': 'None',
@ -368,6 +369,9 @@ def save_settings(settings_items):
if key == 'settings-general-debug': if key == 'settings-general-debug':
configure_debug = True 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', if key in ['settings-general-anti_captcha_provider', 'settings-anticaptcha-anti_captcha_key',
'settings-deathbycaptcha-username', 'settings-deathbycaptcha-password']: 'settings-deathbycaptcha-username', 'settings-deathbycaptcha-password']:
configure_captcha = True configure_captcha = True

@ -23,6 +23,9 @@ startTime = time.time()
# set subliminal_patch user agent # set subliminal_patch user agent
os.environ["SZ_USER_AGENT"] = "Bazarr/{}".format(os.environ["BAZARR_VERSION"]) 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 # set anti-captcha provider and key
configure_captcha_func() configure_captcha_func()

@ -16,6 +16,7 @@ import {
antiCaptchaOption, antiCaptchaOption,
colorOptions, colorOptions,
folderOptions, folderOptions,
hiExtensionOptions,
} from "./options"; } from "./options";
const subzeroOverride = (key: string) => { const subzeroOverride = (key: string) => {
@ -87,6 +88,16 @@ const SettingsSubtitlesView: FunctionComponent = () => {
</Input> </Input>
</CollapseBox.Content> </CollapseBox.Content>
</CollapseBox> </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>
<Group header="Anti-Captcha Options"> <Group header="Anti-Captcha Options">
<CollapseBox> <CollapseBox>

@ -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>[] = [ export const folderOptions: SelectorOption<string>[] = [
{ {
label: "AlongSide Media File", label: "AlongSide Media 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. :param language: language of the subtitle to put in the path.
:type language: :class:`~babelfish.language.Language` :type language: :class:`~babelfish.language.Language`
:param str extension: extension of the subtitle. :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. :return: path of the subtitle.
:rtype: str :rtype: str
""" """
subtitle_root = os.path.splitext(video_path)[0] subtitle_root = os.path.splitext(video_path)[0]
tags = tags or [] tags = tags or []
hi_extension = os.environ.get("SZ_HI_EXTENSION", "hi")
if forced_tag: if forced_tag:
tags.append("forced") tags.append("forced")
elif hi_tag: elif hi_tag:
tags.append("hi") tags.append(hi_extension)
if language: if language:
subtitle_root += '.' + str(language.basename) subtitle_root += '.' + str(language.basename)

Loading…
Cancel
Save