mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-04-23 22:27:17 -04:00
Upgrade routine and settings UI
This commit is contained in:
parent
1c25d125d3
commit
3ed863a3be
4 changed files with 44 additions and 12 deletions
|
@ -497,3 +497,28 @@ def convert_list_to_clause(arr: list):
|
|||
return f"({','.join(str(x) for x in arr)})"
|
||||
else:
|
||||
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
|
||||
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 languages.get_languages import load_language_in_db # 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)
|
||||
else:
|
||||
migrate_db(app)
|
||||
upgrade_languages_profile_hi_values()
|
||||
|
||||
configure_proxy_func()
|
||||
|
||||
|
|
|
@ -38,12 +38,16 @@ const defaultCutoffOptions: SelectorOption<Language.ProfileItem>[] = [
|
|||
|
||||
const subtitlesTypeOptions: SelectorOption<string>[] = [
|
||||
{
|
||||
label: "Normal or hearing-impaired",
|
||||
value: "normal",
|
||||
label: "Normal only",
|
||||
value: "never",
|
||||
},
|
||||
{
|
||||
label: "Hearing-impaired required",
|
||||
value: "hi",
|
||||
label: "Hearing-impaired only",
|
||||
value: "hi_only",
|
||||
},
|
||||
{
|
||||
label: "Normal or hearing-impaired",
|
||||
value: "hi_also",
|
||||
},
|
||||
{
|
||||
label: "Forced (foreign part only)",
|
||||
|
@ -131,7 +135,7 @@ const ProfileEditForm: FunctionComponent<Props> = ({
|
|||
language,
|
||||
// eslint-disable-next-line camelcase
|
||||
audio_exclude: "False",
|
||||
hi: "False",
|
||||
hi: "Also",
|
||||
forced: "False",
|
||||
};
|
||||
|
||||
|
@ -181,10 +185,12 @@ const ProfileEditForm: FunctionComponent<Props> = ({
|
|||
const selectValue = useMemo(() => {
|
||||
if (item.forced === "True") {
|
||||
return "forced";
|
||||
} else if (item.hi === "True") {
|
||||
return "hi";
|
||||
} else {
|
||||
return "normal";
|
||||
} else if (item.hi === "also") {
|
||||
return "hi_also";
|
||||
} else if (item.hi === "only") {
|
||||
return "hi_only";
|
||||
} else if (item.hi === "never") {
|
||||
return "never";
|
||||
}
|
||||
}, [item.forced, item.hi]);
|
||||
|
||||
|
@ -196,7 +202,7 @@ const ProfileEditForm: FunctionComponent<Props> = ({
|
|||
if (value) {
|
||||
action.mutate(index, {
|
||||
...item,
|
||||
hi: value === "hi" ? "True" : "False",
|
||||
hi: value,
|
||||
forced: value === "forced" ? "True" : "False",
|
||||
});
|
||||
}
|
||||
|
|
2
frontend/src/types/api.d.ts
vendored
2
frontend/src/types/api.d.ts
vendored
|
@ -28,7 +28,7 @@ declare namespace Language {
|
|||
id: number;
|
||||
audio_exclude: PythonBoolean;
|
||||
forced: PythonBoolean;
|
||||
hi: PythonBoolean;
|
||||
hi: string;
|
||||
language: CodeType;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue