Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonw/webvtt-to-json
Convert WebVTT to JSON, optionally removing duplicate lines
https://github.com/simonw/webvtt-to-json
Last synced: 27 days ago
JSON representation
Convert WebVTT to JSON, optionally removing duplicate lines
- Host: GitHub
- URL: https://github.com/simonw/webvtt-to-json
- Owner: simonw
- License: apache-2.0
- Created: 2022-09-24T22:54:25.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-14T01:11:50.000Z (about 1 year ago)
- Last Synced: 2024-10-06T20:30:53.955Z (about 1 month ago)
- Language: Python
- Size: 15.6 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# webvtt-to-json
[![PyPI](https://img.shields.io/pypi/v/webvtt-to-json.svg)](https://pypi.org/project/webvtt-to-json/)
[![Changelog](https://img.shields.io/github/v/release/simonw/webvtt-to-json?include_prereleases&label=changelog)](https://github.com/simonw/webvtt-to-json/releases)
[![Tests](https://github.com/simonw/webvtt-to-json/workflows/Test/badge.svg)](https://github.com/simonw/webvtt-to-json/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/webvtt-to-json/blob/master/LICENSE)Convert WebVTT to JSON, optionally removing duplicate lines
## Installation
Install this tool using `pip`:
pip install webvtt-to-json
## Usage
To output JSON for a WebVTT file:
webvtt-to-json subtitles.vtt
This will output to standard output. Use `-o filename` to send it to a specified file.
Subtitles can often include duplicate lines. Add `-d` or `--dedupe` to attempt to remove those duplicates from the output:
webvtt-to-json --dedupe subtitles.vtt
Use `-s` or `--single` to output single `"line"` keys instead of a `"lines"` array.
You can also use:
python -m webvtt_to_json ...
## Output
Standard output:
```json
[
{
"start": "00:00:00.000",
"end": "00:00:01.829",
"lines": [
" ",
"my<00:00:00.160> career<00:00:00.480> in<00:00:00.640> side<00:00:00.880> projects<00:00:01.280> and<00:00:01.520> open"
]
}
]
```
`--dedupe` output:
```json
[
{
"start": "00:00:01.829",
"end": "00:00:01.839",
"lines": ["my career in side projects and open"]
}
]
```
`--dedupe --single` output:
```json
[
{
"start": "00:00:01.829",
"end": "00:00:01.839",
"line": "my career in side projects and open"
}
]
```## Development
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd webvtt-to-json
python -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest