Fixed async audio languages not mapped fallback (#2652)

pull/2654/head v1.4.4-beta.44
Anderson Shindy Oki 2 months ago committed by GitHub
parent 1aff7a35f2
commit 10d475e81e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -54,13 +54,18 @@ def create_languages_dict():
TableSettingsLanguages.code3b)) TableSettingsLanguages.code3b))
.all()] .all()]
def audio_language_from_alpha2(lang): def audio_language_from_name(lang):
lang_map = { lang_map = {
'Chinese': 'zh', 'Chinese': 'zh',
'Portuguese (Brazil)': 'pb' '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): def language_from_alpha2(lang):
return next((item['name'] for item in languages_dict if item['code2'] == lang[:2]), None) return next((item['name'] for item in languages_dict if item['code2'] == lang[:2]), None)

@ -3,7 +3,7 @@
import os import os
from app.config import settings 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 radarr.info import get_radarr_info
from utilities.video_analyzer import embedded_audio_reader from utilities.video_analyzer import embedded_audio_reader
from utilities.path_mappings import path_mappings 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']: for item in movie['movieFile']['languages']:
if isinstance(item, dict): if isinstance(item, dict):
if 'name' in item: if 'name' in item:
language = audio_language_from_alpha2(item['name']) language = audio_language_from_name(item['name'])
audio_language.append(language) audio_language.append(language)
tags = [d['label'] for d in tags_dict if d['id'] in movie['tags']] 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.config import settings
from app.database import TableShows, database, select from app.database import TableShows, database, select
from constants import MINIMUM_VIDEO_SIZE 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.path_mappings import path_mappings
from utilities.video_analyzer import embedded_audio_reader from utilities.video_analyzer import embedded_audio_reader
from sonarr.info import get_sonarr_info from sonarr.info import get_sonarr_info
@ -122,13 +122,13 @@ def episodeParser(episode):
item = episode['episodeFile']['language'] item = episode['episodeFile']['language']
if isinstance(item, dict): if isinstance(item, dict):
if 'name' in item: 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']): elif 'languages' in episode['episodeFile'] and len(episode['episodeFile']['languages']):
items = episode['episodeFile']['languages'] items = episode['episodeFile']['languages']
if isinstance(items, list): if isinstance(items, list):
for item in items: for item in items:
if 'name' in item: if 'name' in item:
audio_language.append(audio_language_from_alpha2(item['name'])) audio_language.append(audio_language_from_name(item['name']))
else: else:
audio_language = database.execute( audio_language = database.execute(
select(TableShows.audio_language) select(TableShows.audio_language)

Loading…
Cancel
Save