DEV Community

Cover image for Just Published an NPM Package 🔥
Ali Abbas
Ali Abbas

Posted on

Just Published an NPM Package 🔥

Hey there.🚀 I just published another NPM package on npmjs.com. The npm package converts the subtitle file (.srt) into a readable and well-standard JSON format.

Check out the NPM link SRT-Convert-JSON

Install

$ npm install srt-convert-json
Enter fullscreen mode Exit fullscreen mode

This package can be used to convert Movies Subtitle to JSON format

Usage

const convert = require('srt-convert-json')

convert.process("INPUT_FILE_PATH","OUTPUT_FILE_PATH")
// convert.process("./data.srt","./subtitle.json")
Enter fullscreen mode Exit fullscreen mode

For Example, this is an SRT File

1
00:02:38,910 --> 00:02:40,161
English! I'm English!

2
00:05:40,049 --> 00:05:41,801
It's grenadiers, mate.
Enter fullscreen mode Exit fullscreen mode

After converting, the output will be

[
    {
        "position": 1,
        "start": "00:02:38",
        "timer1": "910",
        "end": "00:02:40",
        "timer2": "161",
        "text": "English! I'm English!"
    },
    {
        "position": 2,
        "start": "00:05:40",
        "timer1": "049",
        "end": "00:05:41",
        "timer2": "801",
        "text": "It's grenadiers, mate."
    },
]
Enter fullscreen mode Exit fullscreen mode

Top comments (6)

Collapse
 
pstev profile image
Petar Stevovski

Interesting. Can it go the other way around too (from .json to .srt file) ? Maybe that could be useful for people that write subtitles. Also, just an idea, maybe convert it to a cli, so it can be used straight away, instead of first having to import it to a .js file and then running it?

Collapse
 
realabbas profile image
Ali Abbas

Yeah . Sure I will work on it. Thanks for the idea and appreciation.

Collapse
 
dmahely profile image
Doaa Mahely

Awesome idea! Will check this out soon 👌

Collapse
 
realabbas profile image
Ali Abbas

Thank you for the appreciation

Collapse
 
realabbas profile image
Ali Abbas

Thank you for the appreciation