diff --git a/danmaku2ass.py b/danmaku2ass.py index 29c51a4..044abc5 100755 --- a/danmaku2ass.py +++ b/danmaku2ass.py @@ -824,10 +824,12 @@ def ReadComments(input_files, font_size=25.0, progress_callback=None): if progress_callback: progress_callback(idx, len(input_files)) with ConvertToFile(i, 'r', encoding='utf-8', errors='replace') as f: - CommentProcessor = GetCommentProcessor(f) + s = f.read() + str_io = io.StringIO(s) + CommentProcessor = GetCommentProcessor(str_io) if not CommentProcessor: raise ValueError(_('Unknown comment file format: %s') % i) - comments.extend(CommentProcessor(FilterBadChars(f), font_size)) + comments.extend(CommentProcessor(FilterBadChars(str_io), font_size)) if progress_callback: progress_callback(len(input_files), len(input_files)) comments.sort()