From d805576f839cff005b75bf160ffce7762203c262 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 13 Jan 2018 12:39:54 -0500 Subject: [PATCH] Switch from next to itertools to avoid StopIteration error #37 --- list_subtitles.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/list_subtitles.py b/list_subtitles.py index 87d17846c..3158ba3b4 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -7,6 +7,7 @@ import sqlite3 import ast import langdetect import chardet +from itertools import islice from get_general_settings import * @@ -35,7 +36,7 @@ def store_subtitles(file): actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) else: with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: - text = [next(f) for x in xrange(20)] + text = list(islice(f, 20)) text = ' '.join(text) encoding = chardet.detect(text)['encoding'] text = text.decode(encoding)