Skip to main content
Deno 2 is finally here 🎉️
Learn more

Neta

ci

A SRT and ASS/SSA subtitle parser for Deno.

Usage

import { srtToText } from 'https://deno.land/x/neta/mod.ts';

const srt = await Deno.readTextFile('./test.srt');
const text = srtToText(srt);
await Deno.writeTextFile('./subtitle.txt', text);

Becuase APIs are not stable enough now, I recommend that you specify the version when you import Neta. like this:

import { srtToText } from 'https://deno.land/x/neta@v0.5.0/mod.ts';

API

  • SRT
    • srtParser() Convert SRT string into array of objects
    • srtToText() extract text from SRT subtitle
  • ASS/SSA
    • assParser() Convert ASS string to JSON
    • assToSrt() Convert ASS to SRT
    • assToText() Convert ASS to plain text

Example

const srtString = `1
00:00:00,001 --> 00:00:00,002
Five men is a juicy opportunity.
One man is a waste of ammo.

2
00:00:00,100 --> 00:00:00,200
Keep the sand out of your weapons!`;

const ast = srtParser(srtString);
console.log(ast);

TODO

  • Chinese documents;
  • Parse SRT Formatting;
  • Parse ASS override;
  • Support Node.js;