def parseFile(filename): rArr=[] try: subs=SubRipFile.open(filename) except UnicodeDecodeError: subs=SubRipFile.open(filename,encoding='iso-8859-1') for s in subs: text=s.text text=re.sub(fontpattern,'',text) text=re.sub(npattern,'',text) rArr.append(text) return rArr