From 7950e06e0d989ff76f612917cc978a74046b1291 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Fri, 1 May 2015 22:34:02 +0200 Subject: [PATCH] smi: check if data is empty --- lib/svtplay_dl/subtitle/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/svtplay_dl/subtitle/__init__.py b/lib/svtplay_dl/subtitle/__init__.py index e3a4519..e971a1a 100644 --- a/lib/svtplay_dl/subtitle/__init__.py +++ b/lib/svtplay_dl/subtitle/__init__.py @@ -113,12 +113,15 @@ class subtitle(object): TAG_RE = re.compile(r'<[^>]+>') bad_char = re.compile(r'\x96') for i in ssubdata.readlines(): + i = i.rstrip() sync = re.search(r"", i) if sync: if int(sync.group(1)) != int(timea): - if data != " \r": + if data and data != " ": subs += "%s\n%s --> %s\n" % (number, timestr(timea), timestr(sync.group(1))) text = "%s\n" % TAG_RE.sub('', data.replace("
", "\n")) + if text[len(text)-2] != "\n": + text += "\n" subs += text number += 1 timea = sync.group(1)