https://github.com/aasim-a/yt-xml2vtt
Easily convert YouTube caption format from XML to VTT with zero dependencies
https://github.com/aasim-a/yt-xml2vtt
caption convert converter format javascript node nodejs vtt xml xml2vtt youtube youtube-caption youtube-xml yt-xml2vtt
Last synced: 8 months ago
JSON representation
Easily convert YouTube caption format from XML to VTT with zero dependencies
- Host: GitHub
- URL: https://github.com/aasim-a/yt-xml2vtt
- Owner: Aasim-A
- License: mit
- Created: 2020-02-28T00:38:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-19T16:03:03.000Z (over 3 years ago)
- Last Synced: 2025-07-22T10:30:16.713Z (9 months ago)
- Topics: caption, convert, converter, format, javascript, node, nodejs, vtt, xml, xml2vtt, youtube, youtube-caption, youtube-xml, yt-xml2vtt
- Language: JavaScript
- Homepage:
- Size: 94.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yt-xml2vtt
A tiny module to easily convert YouTube caption format from XML to VTT with ZERO dependencies.
[](https://nodei.co/npm/yt-xml2vtt/)
# Installation
```bash
npm i -S yt-xml2vtt
```
Or for Yarn users:
```bash
yarn add yt-xml2vtt
```
# Usage
## Using Promises:
```js
const xml2vtt = require('yt-xml2vtt');
xml2vtt.Parse(xmlString)
.then(vtt => /* DO SOMETHING WITH VTT */)
.catch(err => console.log(`Error while converting XML to VTT : ${err}`));
```
Or you can use async await
```js
const xml2vtt = require('yt-xml2vtt');
const vtt = await xml2vtt
.Parse(xmlString)
.catch(err => console.log(`Error while converting XML to VTT : ${err}`));
/* DO SOMETHING WITH VTT */
```
## Using it synchronously:
```js
const xml2vtt = require('yt-xml2vtt');
try {
const vtt = xml2vtt.ParseSync(xmlString);
/* DO SOMETHING WITH VTT */
} catch (err) {
console.log(`Error while converting XML to VTT : ${err}`);
}
```
# Tests
```bash
npm test
```