summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAnderson Shindy Oki <[email protected]>2024-08-25 22:46:57 +0900
committerGitHub <[email protected]>2024-08-25 22:46:57 +0900
commit4887066000a461d2026e95ba8d493bd667d9bfb2 (patch)
tree660b7092dcfd8a99373f6d5eb2ef2b2fdda05829
parent609349b4002290e771935c7e6d02263c3fdd7ce4 (diff)
downloadbazarr-4887066000a461d2026e95ba8d493bd667d9bfb2.tar.gz
bazarr-4887066000a461d2026e95ba8d493bd667d9bfb2.zip
Fixed chinese audio language (#2632)
-rw-r--r--bazarr/languages/get_languages.py7
-rw-r--r--bazarr/radarr/sync/parser.py6
-rw-r--r--bazarr/sonarr/sync/parser.py5
-rw-r--r--frontend/src/components/bazarr/AudioList.tsx3
-rw-r--r--frontend/src/pages/views/ItemOverview.tsx3
-rw-r--r--frontend/src/utilities/languages.ts4
6 files changed, 20 insertions, 8 deletions
diff --git a/bazarr/languages/get_languages.py b/bazarr/languages/get_languages.py
index 2fbd52c89..881dd6ce0 100644
--- a/bazarr/languages/get_languages.py
+++ b/bazarr/languages/get_languages.py
@@ -54,6 +54,13 @@ def create_languages_dict():
TableSettingsLanguages.code3b))
.all()]
+def audio_language_from_alpha2(lang):
+ lang_map = {
+ 'Chinese': 'zh',
+ 'Portuguese (Brazil)': 'pb'
+ }
+
+ return language_from_alpha2(lang_map.get(lang, lang))
def language_from_alpha2(lang):
return next((item['name'] for item in languages_dict if item['code2'] == lang[:2]), None)
diff --git a/bazarr/radarr/sync/parser.py b/bazarr/radarr/sync/parser.py
index d5f3e08c8..11b2a6687 100644
--- a/bazarr/radarr/sync/parser.py
+++ b/bazarr/radarr/sync/parser.py
@@ -3,7 +3,7 @@
import os
from app.config import settings
-from languages.get_languages import language_from_alpha2
+from languages.get_languages import audio_language_from_alpha2
from radarr.info import get_radarr_info
from utilities.video_analyzer import embedded_audio_reader
from utilities.path_mappings import path_mappings
@@ -117,9 +117,7 @@ def movieParser(movie, action, tags_dict, language_profiles, movie_default_profi
for item in movie['movieFile']['languages']:
if isinstance(item, dict):
if 'name' in item:
- language = item['name']
- if item['name'] == 'Portuguese (Brazil)':
- language = language_from_alpha2('pb')
+ language = audio_language_from_alpha2(item['name'])
audio_language.append(language)
tags = [d['label'] for d in tags_dict if d['id'] in movie['tags']]
diff --git a/bazarr/sonarr/sync/parser.py b/bazarr/sonarr/sync/parser.py
index 32980cbab..24c92c575 100644
--- a/bazarr/sonarr/sync/parser.py
+++ b/bazarr/sonarr/sync/parser.py
@@ -5,6 +5,7 @@ import os
from app.config import settings
from app.database import TableShows, database, select
from constants import MINIMUM_VIDEO_SIZE
+from languages.get_languages import audio_language_from_alpha2
from utilities.path_mappings import path_mappings
from utilities.video_analyzer import embedded_audio_reader
from sonarr.info import get_sonarr_info
@@ -115,13 +116,13 @@ def episodeParser(episode):
item = episode['episodeFile']['language']
if isinstance(item, dict):
if 'name' in item:
- audio_language.append(item['name'])
+ audio_language.append(audio_language_from_alpha2(item['name']))
elif 'languages' in episode['episodeFile'] and len(episode['episodeFile']['languages']):
items = episode['episodeFile']['languages']
if isinstance(items, list):
for item in items:
if 'name' in item:
- audio_language.append(item['name'])
+ audio_language.append(audio_language_from_alpha2(item['name']))
else:
audio_language = database.execute(
select(TableShows.audio_language)
diff --git a/frontend/src/components/bazarr/AudioList.tsx b/frontend/src/components/bazarr/AudioList.tsx
index f1af7ff3c..f0dc07c0d 100644
--- a/frontend/src/components/bazarr/AudioList.tsx
+++ b/frontend/src/components/bazarr/AudioList.tsx
@@ -1,6 +1,7 @@
import { FunctionComponent } from "react";
import { Badge, BadgeProps, Group, GroupProps } from "@mantine/core";
import { BuildKey } from "@/utilities";
+import { normalizeAudioLanguage } from "@/utilities/languages";
export type AudioListProps = GroupProps & {
audios: Language.Info[];
@@ -16,7 +17,7 @@ const AudioList: FunctionComponent<AudioListProps> = ({
<Group gap="xs" {...group}>
{audios.map((audio, idx) => (
<Badge color="blue" key={BuildKey(idx, audio.code2)} {...badgeProps}>
- {audio.name}
+ {normalizeAudioLanguage(audio.name)}
</Badge>
))}
</Group>
diff --git a/frontend/src/pages/views/ItemOverview.tsx b/frontend/src/pages/views/ItemOverview.tsx
index d03da3b80..36d296850 100644
--- a/frontend/src/pages/views/ItemOverview.tsx
+++ b/frontend/src/pages/views/ItemOverview.tsx
@@ -31,6 +31,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Language } from "@/components/bazarr";
import { BuildKey } from "@/utilities";
import {
+ normalizeAudioLanguage,
useLanguageProfileBy,
useProfileItemsToLanguages,
} from "@/utilities/languages";
@@ -87,7 +88,7 @@ const ItemOverview: FunctionComponent<Props> = (props) => {
icon={faMusic}
title="Audio Language"
>
- {v.name}
+ {normalizeAudioLanguage(v.name)}
</ItemBadge>
)) ?? [],
[item?.audio_language],
diff --git a/frontend/src/utilities/languages.ts b/frontend/src/utilities/languages.ts
index 1b59aa4e7..7885e9667 100644
--- a/frontend/src/utilities/languages.ts
+++ b/frontend/src/utilities/languages.ts
@@ -51,3 +51,7 @@ export function useLanguageFromCode3(code3: string) {
[data, code3],
);
}
+
+export const normalizeAudioLanguage = (name: string) => {
+ return name === "Chinese Simplified" ? "Chinese" : name;
+};