# ass-parser

> Parse SSA/ASS subtitle format

Latest version **0.2.0** (published 2018-01-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install ass-parser
pnpm add ass-parser
yarn add ass-parser
bun add ass-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-01-08 |
| First published | 2015-01-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Eugene Sharygin |
| Maintainers | eush77 |
| Keywords | SSA, ASS, subtitle, format, subtitles, parser |

## Links

- npm: https://www.npmjs.com/package/ass-parser
- Repository: https://github.com/eush77/ass-parser
- Issues: https://github.com/eush77/ass-parser/issues
- npm.io page: https://npm.io/package/ass-parser

## Dependencies (4)

- [fzip](https://npm.io/package/fzip.md) ^0.2.0
- [zipmap](https://npm.io/package/zipmap.md) ^1.1.1
- [flatmap](https://npm.io/package/flatmap.md) 0.0.3
- [regexp.execall](https://npm.io/package/regexp.execall.md) ^1.0.2

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2018-01-08
- 0.1.2 — 2017-06-05
- 0.1.1 — 2015-01-21
- 0.1.0 — 2015-01-20

## README

[![npm](https://nodei.co/npm/ass-parser.png)](https://nodei.co/npm/ass-parser/)

# ass-parser

[![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david]

Parse SSA/ASS subtitle format.

[travis]: https://travis-ci.org/eush77/ass-parser
[travis-badge]: https://travis-ci.org/eush77/ass-parser.svg
[david]: https://david-dm.org/eush77/ass-parser
[david-badge]: https://david-dm.org/eush77/ass-parser.png

## Example

For the ASS subtitle below (from the [Wikipedia page](http://en.wikipedia.org/wiki/SubStation_Alpha))

```
[Script Info]
; This is a Sub Station Alpha v4 script.
; For Sub Station Alpha info and downloads,
; go to http://www.eswat.demon.co.uk/
Title: Neon Genesis Evangelion - Episode 26 (neutral Spanish)
Original Script: RoRo
Script Updated By: version 2.8.01
ScriptType: v4.00
Collisions: Normal
PlayResY: 600
PlayDepth: 0
Timer: 100,0000

[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: DefaultVCD, Arial,28,11861244,11861244,11861244,-2147483640,-1,0,1,1,2,2,30,30,30,0,0

[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: Marked=0,0:00:01.18,0:00:06.85,DefaultVCD, NTP,0000,0000,0000,,{\pos(400,570)}Like an angel with pity on nobody

```

`assParser(text, { comments: true })` returns the following:

```js
[
    {
        "section": "Script Info",
        "body": [
            {
                "type": "comment",
                "value": " This is a Sub Station Alpha v4 script."
            },
            {
                "type": "comment",
                "value": " For Sub Station Alpha info and downloads,"
            },
            {
                "type": "comment",
                "value": " go to http://www.eswat.demon.co.uk/"
            },
            {
                "key": "Title",
                "value": "Neon Genesis Evangelion - Episode 26 (neutral Spanish)"
            },
            {
                "key": "Original Script",
                "value": "RoRo"
            },
            {
                "key": "Script Updated By",
                "value": "version 2.8.01"
            },
            {
                "key": "ScriptType",
                "value": "v4.00"
            },
            {
                "key": "Collisions",
                "value": "Normal"
            },
            {
                "key": "PlayResY",
                "value": "600"
            },
            {
                "key": "PlayDepth",
                "value": "0"
            },
            {
                "key": "Timer",
                "value": "100,0000"
            }
        ]
    },
    {
        "section": "V4 Styles",
        "body": [
            {
                "key": "Format",
                "value": [
                    "Name",
                    "Fontname",
                    "Fontsize",
                    "PrimaryColour",
                    "SecondaryColour",
                    "TertiaryColour",
                    "BackColour",
                    "Bold",
                    "Italic",
                    "BorderStyle",
                    "Outline",
                    "Shadow",
                    "Alignment",
                    "MarginL",
                    "MarginR",
                    "MarginV",
                    "AlphaLevel",
                    "Encoding"
                ]
            },
            {
                "key": "Style",
                "value": {
                    "Name": "DefaultVCD",
                    "Fontname": "Arial",
                    "Fontsize": "28",
                    "PrimaryColour": "11861244",
                    "SecondaryColour": "11861244",
                    "TertiaryColour": "11861244",
                    "BackColour": "-2147483640",
                    "Bold": "-1",
                    "Italic": "0",
                    "BorderStyle": "1",
                    "Outline": "1",
                    "Shadow": "2",
                    "Alignment": "2",
                    "MarginL": "30",
                    "MarginR": "30",
                    "MarginV": "30",
                    "AlphaLevel": "0",
                    "Encoding": "0"
                }
            }
        ]
    },
    {
        "section": "Events",
        "body": [
            {
                "key": "Format",
                "value": [
                    "Marked",
                    "Start",
                    "End",
                    "Style",
                    "Name",
                    "MarginL",
                    "MarginR",
                    "MarginV",
                    "Effect",
                    "Text"
                ]
            },
            {
                "key": "Dialogue",
                "value": {
                    "Marked": "Marked=0",
                    "Start": "0:00:01.18",
                    "End": "0:00:06.85",
                    "Style": "DefaultVCD",
                    "Name": "NTP",
                    "MarginL": "0000",
                    "MarginR": "0000",
                    "MarginV": "0000",
                    "Effect": "",
                    "Text": "{\\pos(400,570)}Like an angel with pity on nobody"
                }
            }
        ]
    }
]
```

## API

### `assParser(text, [options])`

Returns the parse tree.

Comments are ignored unless `options.comments` is set.

| Option   | Type    | Required? | Default |
| :------- | :------ | :-------: | :------ |
| comments | boolean | No        | `false` |

## Format

Subtitle is a list of sections, each of them has `section` and `body` properties. The `body` is a list of key-value bindings (descriptors), with `key` and `value` properties (`type == 'comment'` and `value` for comments).

`value` can be one of the following:
- array if the descriptor key is `"Format"`;
- object if there is a `"Format"` descriptor above in the section;
- string otherwise.

## References

- [Wikipedia page](http://en.wikipedia.org/wiki/SubStation_Alpha)
- [format specification](http://www.perlfu.co.uk/projects/asa/ass-specs.doc)

## Related

- [ass-stringify](https://www.npmjs.com/packages/ass-stringify) - stringify SSA/ASS parse tree.

## Install

```shell
npm install ass-parser
```

## License

MIT

---
_Source: https://npm.io/package/ass-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
