pysub-parser
pysub-parser copied to clipboard
Allow parsing from file-like objects, not only files.
E.g., the subtitle files could be contained in a zip file, which can be opened as a file-like object. The current API requires the subtitles to be extracted.
E.g.,
def parse(path: str, encoding: str = "utf-8", **_) -> Iterator[Subtitle]:
with open(path, encoding=encoding) as file:
yield from parse_file(file)
def parse_file(file):
... code as before ...