def guess_language_(title): """ guess movie language, looking for ISO language representation in title """ language = None match = re.search(r'\b([a-zA-Z]{3})\b', title) if match: # get corresponding language, given 3-letters ISO language code found language = utils.alpha3_to_language(match.group(0)) # language detected if language != None: # remove language from title title = title[:match.start()] + title[match.end():] return title, language
def guess_subtitles_(title): """ guess subtitles subtitles, looking for ISO subtitles representation in title """ subtitles = None match = re.search(r'(?:[^a-zA-Z0-9]sub )([a-zA-Z]{3})(?:[^a-zA-Z0-9])', title) if match: # get corresponding subtitles, given 3-letters ISO subtitles code found subtitles = utils.alpha3_to_language(match.group(1)) # subtitles detected if subtitles != None: # remove subtitles from title title = title[:match.start() + 1] + title[match.end() - 1:] return title, subtitles