npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ass-parser

v0.2.0

Published

Parse SSA/ASS subtitle format

Downloads

429

Readme

npm

ass-parser

Build Status Dependency Status

Parse SSA/ASS subtitle format.

Example

For the ASS subtitle below (from the Wikipedia page)

[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:

[
    {
        "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

Related

Install

npm install ass-parser

License

MIT