https://github.com/remram44/subtitle-parser
Parser for SRT and WebVTT subtitle files
https://github.com/remram44/subtitle-parser
srt subtitles subtitles-parsing webvtt
Last synced: 3 months ago
JSON representation
Parser for SRT and WebVTT subtitle files
- Host: GitHub
- URL: https://github.com/remram44/subtitle-parser
- Owner: remram44
- License: mit
- Created: 2022-01-26T23:46:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-15T21:12:14.000Z (over 1 year ago)
- Last Synced: 2026-01-14T02:03:00.766Z (5 months ago)
- Topics: srt, subtitles, subtitles-parsing, webvtt
- Language: Python
- Homepage:
- Size: 83 KB
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
subtitle-parser
===============
This is a simple Python library for parsing subtitle files in SRT or WebVTT format.
How to use stand-alone?
-----------------------
You can use this as a script to convert subtitles to HTML or CSV.
If you have installed it using `pip install subtitle-parser`, use `python3 -m subtitle_parser`. If you have cloned this repository or downloaded the file, use `python3 subtitle_parser.py`.
Examples:
```
$ python3 subtitle_parser.py --to csv Zoom_transcript.vtt --output transcript.csv
```
```
$ python3 -m subtitle_parser --to html episode.srt --input-charset iso-8859-15 --output dialogue.html
```
How to use as a library?
------------------------
```python
import subtitle_parser
with open('some_file.srt', 'r') as input_file:
parser = subtitle_parser.SrtParser(input_file)
parser.parse()
parser.print_warnings()
for subtitle in parser.subtitles:
print(subtitle.text)
```