Skip to content

Deno package to convert Youtube caption format from XML to SRT with Zero dependencies

License

Notifications You must be signed in to change notification settings

Aasim-A/yt_xml2srt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yt_xml2srt

A tiny package to convert YouTube caption format from XML to SRT with ZERO dependencies.

Intended to be used in Deno

Usage

parse() - returns a Promise

import { parse } from 'https://deno.land/x/yt_xml2srt/mod.ts'

parse(XML_STRING)
  .then(srt => /* DO SOMETHING WITH SRT */)
  .catch(err => console.log(`Error while converting XML to SRT : ${err}`));

Or you can use async await

import { parse } from 'https://deno.land/x/yt_xml2srt/mod.ts';

try {
  const srt = await parse(XML_STRING);
  /* DO SOMETHING WITH SRT */
} catch (err) {
  console.log(`Error while converting XML to SRT : ${err}`);
}

parseSync()

import { parseSync } from 'https://deno.land/x/yt_xml2srt/mod.ts';

try {
  const srt = parseSync(XML_STRING);
  /* DO SOMETHING WITH SRT */
} catch (err) {
  console.log(`Error while converting XML to SRT : ${err}`);
}

Tests

deno test test/test.ts

About

Deno package to convert Youtube caption format from XML to SRT with Zero dependencies

Resources

License

Stars

Watchers

Forks

Packages

No packages published