From 5b286bfe6862a43cf69eefe9aab24e14ebdd6a46 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 11 Aug 2021 10:00:17 +0100 Subject: [PATCH] Handle languages list as a string --- utils.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/utils.py b/utils.py index 1c0892713..8f291b0f7 100644 --- a/utils.py +++ b/utils.py @@ -42,13 +42,32 @@ def getActorLanguagesList(actorJson: {}) -> []: continue if not propertyValue.get('value'): continue - if not isinstance(propertyValue['value'], list): - continue if propertyValue['type'] != 'PropertyValue': continue - langList = propertyValue['value'] - langList.sort() - return langList + if isinstance(propertyValue['value'], list): + langList = propertyValue['value'] + langList.sort() + return langList + elif isinstance(propertyValue['value'], str): + langStr = propertyValue['value'] + langListTemp = [] + if ',' in langStr: + langListTemp = langStr.split(',') + elif ';' in langStr: + langListTemp = langStr.split(';') + elif '/' in langStr: + langListTemp = langStr.split('/') + elif '+' in langStr: + langListTemp = langStr.split('+') + elif ' ' in langStr: + langListTemp = langStr.split(' ') + langList = [] + for lang in langListTemp: + lang = lang.strip() + if lang not in langList: + langList.append(lang) + langList.sort() + return langList return []