pysub-parser icon indicating copy to clipboard operation
pysub-parser copied to clipboard

Allow parsing from file-like objects, not only files.

Open kno10 opened this issue 1 year ago • 0 comments

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 ...

kno10 avatar Feb 09 '24 13:02 kno10