mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-21 23:32:31 +00:00
Fixed async audio languages not mapped fallback (#2652)
This commit is contained in:
parent
1aff7a35f2
commit
10d475e81e
3 changed files with 12 additions and 7 deletions
|
@ -54,13 +54,18 @@ def create_languages_dict():
|
|||
TableSettingsLanguages.code3b))
|
||||
.all()]
|
||||
|
||||
def audio_language_from_alpha2(lang):
|
||||
def audio_language_from_name(lang):
|
||||
lang_map = {
|
||||
'Chinese': 'zh',
|
||||
'Portuguese (Brazil)': 'pb'
|
||||
}
|
||||
|
||||
return language_from_alpha2(lang_map.get(lang, lang))
|
||||
alpha2_code = lang_map.get(lang, None)
|
||||
|
||||
if alpha2_code is None:
|
||||
return lang
|
||||
|
||||
return language_from_alpha2(alpha2_code)
|
||||
|
||||
def language_from_alpha2(lang):
|
||||
return next((item['name'] for item in languages_dict if item['code2'] == lang[:2]), None)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import os
|
||||
|
||||
from app.config import settings
|
||||
from languages.get_languages import audio_language_from_alpha2
|
||||
from languages.get_languages import audio_language_from_name
|
||||
from radarr.info import get_radarr_info
|
||||
from utilities.video_analyzer import embedded_audio_reader
|
||||
from utilities.path_mappings import path_mappings
|
||||
|
@ -117,7 +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 = audio_language_from_alpha2(item['name'])
|
||||
language = audio_language_from_name(item['name'])
|
||||
audio_language.append(language)
|
||||
|
||||
tags = [d['label'] for d in tags_dict if d['id'] in movie['tags']]
|
||||
|
|
|
@ -5,7 +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 languages.get_languages import audio_language_from_name
|
||||
from utilities.path_mappings import path_mappings
|
||||
from utilities.video_analyzer import embedded_audio_reader
|
||||
from sonarr.info import get_sonarr_info
|
||||
|
@ -122,13 +122,13 @@ def episodeParser(episode):
|
|||
item = episode['episodeFile']['language']
|
||||
if isinstance(item, dict):
|
||||
if 'name' in item:
|
||||
audio_language.append(audio_language_from_alpha2(item['name']))
|
||||
audio_language.append(audio_language_from_name(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(audio_language_from_alpha2(item['name']))
|
||||
audio_language.append(audio_language_from_name(item['name']))
|
||||
else:
|
||||
audio_language = database.execute(
|
||||
select(TableShows.audio_language)
|
||||
|
|
Loading…
Reference in a new issue