Upgrade routine and settings UI

non-hi-only
morpheus65535 3 months ago
parent 1c25d125d3
commit 3ed863a3be

@ -497,3 +497,28 @@ def convert_list_to_clause(arr: list):
return f"({','.join(str(x) for x in arr)})" return f"({','.join(str(x) for x in arr)})"
else: else:
return "" return ""
def upgrade_languages_profile_hi_values():
for languages_profile in (database.execute(
select(
TableLanguagesProfiles.profileId,
TableLanguagesProfiles.name,
TableLanguagesProfiles.cutoff,
TableLanguagesProfiles.items,
TableLanguagesProfiles.mustContain,
TableLanguagesProfiles.mustNotContain,
TableLanguagesProfiles.originalFormat)
))\
.all():
items = json.loads(languages_profile.items)
for language in items:
if language['hi'] == "True":
language['hi'] = "only"
elif language['hi'] == "False":
language['hi'] = "also"
database.execute(
update(TableLanguagesProfiles)
.values({"items": json.dumps(items)})
.where(TableLanguagesProfiles.profileId == languages_profile.profileId)
)

@ -36,7 +36,7 @@ else:
# there's missing embedded packages after a commit # there's missing embedded packages after a commit
check_if_new_update() check_if_new_update()
from app.database import System, database, update, migrate_db, create_db_revision # noqa E402 from app.database import System, database, update, migrate_db, create_db_revision, upgrade_languages_profile_hi_values # noqa E402
from app.notifier import update_notifier # noqa E402 from app.notifier import update_notifier # noqa E402
from languages.get_languages import load_language_in_db # noqa E402 from languages.get_languages import load_language_in_db # noqa E402
from app.signalr_client import sonarr_signalr_client, radarr_signalr_client # noqa E402 from app.signalr_client import sonarr_signalr_client, radarr_signalr_client # noqa E402
@ -48,6 +48,7 @@ if args.create_db_revision:
stop_bazarr(EXIT_NORMAL) stop_bazarr(EXIT_NORMAL)
else: else:
migrate_db(app) migrate_db(app)
upgrade_languages_profile_hi_values()
configure_proxy_func() configure_proxy_func()

@ -38,12 +38,16 @@ const defaultCutoffOptions: SelectorOption<Language.ProfileItem>[] = [
const subtitlesTypeOptions: SelectorOption<string>[] = [ const subtitlesTypeOptions: SelectorOption<string>[] = [
{ {
label: "Normal or hearing-impaired", label: "Normal only",
value: "normal", value: "never",
},
{
label: "Hearing-impaired only",
value: "hi_only",
}, },
{ {
label: "Hearing-impaired required", label: "Normal or hearing-impaired",
value: "hi", value: "hi_also",
}, },
{ {
label: "Forced (foreign part only)", label: "Forced (foreign part only)",
@ -131,7 +135,7 @@ const ProfileEditForm: FunctionComponent<Props> = ({
language, language,
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
audio_exclude: "False", audio_exclude: "False",
hi: "False", hi: "Also",
forced: "False", forced: "False",
}; };
@ -181,10 +185,12 @@ const ProfileEditForm: FunctionComponent<Props> = ({
const selectValue = useMemo(() => { const selectValue = useMemo(() => {
if (item.forced === "True") { if (item.forced === "True") {
return "forced"; return "forced";
} else if (item.hi === "True") { } else if (item.hi === "also") {
return "hi"; return "hi_also";
} else { } else if (item.hi === "only") {
return "normal"; return "hi_only";
} else if (item.hi === "never") {
return "never";
} }
}, [item.forced, item.hi]); }, [item.forced, item.hi]);
@ -196,7 +202,7 @@ const ProfileEditForm: FunctionComponent<Props> = ({
if (value) { if (value) {
action.mutate(index, { action.mutate(index, {
...item, ...item,
hi: value === "hi" ? "True" : "False", hi: value,
forced: value === "forced" ? "True" : "False", forced: value === "forced" ? "True" : "False",
}); });
} }

@ -28,7 +28,7 @@ declare namespace Language {
id: number; id: number;
audio_exclude: PythonBoolean; audio_exclude: PythonBoolean;
forced: PythonBoolean; forced: PythonBoolean;
hi: PythonBoolean; hi: string;
language: CodeType; language: CodeType;
} }

Loading…
Cancel
Save