{"id":13880802,"url":"https://github.com/1c7/srt-parser-2","last_synced_at":"2025-04-07T12:05:17.617Z","repository":{"id":44644998,"uuid":"240525228","full_name":"1c7/srt-parser-2","owner":"1c7","description":"SRT parser that can handle wrong SRT format too (like 00:00:12.682 use dot as separator, which is wrong, it should be a comma)","archived":false,"fork":false,"pushed_at":"2023-09-25T14:03:12.000Z","size":382,"stargazers_count":67,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T10:06:22.822Z","etag":null,"topics":["srt","srt-parser","srt-subtitles","subtitles-parser"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/srt-parser-2","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1c7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-14T14:22:14.000Z","updated_at":"2025-03-30T14:51:00.000Z","dependencies_parsed_at":"2023-02-09T10:45:26.370Z","dependency_job_id":"34d0f52c-5cbc-44ac-8b66-5cdb1000879d","html_url":"https://github.com/1c7/srt-parser-2","commit_stats":{"total_commits":73,"total_committers":9,"mean_commits":8.11111111111111,"dds":"0.20547945205479456","last_synced_commit":"caa2b743aad8d991a0967051cb5ef3fcee637eba"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1c7%2Fsrt-parser-2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1c7%2Fsrt-parser-2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1c7%2Fsrt-parser-2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1c7%2Fsrt-parser-2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1c7","download_url":"https://codeload.github.com/1c7/srt-parser-2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648976,"owners_count":20972945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["srt","srt-parser","srt-subtitles","subtitles-parser"],"created_at":"2024-08-06T08:03:29.943Z","updated_at":"2025-04-07T12:05:17.600Z","avatar_url":"https://github.com/1c7.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"## srt-parser-2\n\nAn SRT parser for Javascript.\n\nIt reads an `.srt` file into an array.\n\n## Install\n\n`npm`\n\n```\nnpm install srt-parser-2\n```\n\nor `yarn`\n\n```\nyarn add srt-parser-2\n```\n\n## Example\n\nThis is a srt format file:\n\n```\n1\n00:00:11,544 --\u003e 00:00:12,682\nHello\n```\n\nit would become:\n\n```\n[{\n    id: '1',\n    startTime: '00:00:11,544',\n    startSeconds: 11.544,\n    endTime: '00:00:12,682',\n    endSeconds: 12.682,\n    text: 'Hello'\n}]\n```\n\n### Enviroment support\n\nSince it only process text,  \nit should work in both `Browser` and `Node.js` enviroment\n\n## Usage\n\n```javascript\nlet srt = `\n1\n00:00:11,544 --\u003e 00:00:12,682\nHello\n`;\n\nimport srtParser2 from \"srt-parser-2\";\nvar parser = new srtParser2();\nvar srt_array = parser.fromSrt(srt);\nconsole.log(srt_array);\n\n// turn array back to SRT string.\nvar srt_string = parser.toSrt(srt_array);\nconsole.log(srt_string);\n```\n\nYou can run this example using `node example/1.Comma.js`\n\n## CLI\n\n```\nnpx srt-parser-2 -i input.srt -o output.json --minify\n```\n\nOptions:\n\n| Option         | Required | Default     |\n| -------------- | -------- | ----------- |\n| --input or -i  | Yes      |             |\n| --output or -o | No       | output.json |\n| --minify       | No       | false       |\n\n## License\n\nMIT\n\n## Why?\n\nWhy this one special? There are plently SRT parser on npm:\n\n- [subtitles-parser](https://www.npmjs.com/package/subtitles-parser)\n- [subtitles-parser-vtt](https://www.npmjs.com/package/subtitles-parser-vtt)\n- [subtitle](https://www.npmjs.com/package/subtitle)\n- [srt](https://www.npmjs.com/package/srt)\n\n## What's wrong with them?\n\nNothing wrong.  \nAll of them can handle this format:\n\n```\n1\n00:00:11,544 --\u003e 00:00:12,682\nHello\n```\n\n## But I want to handle format like these:\n\n```\n00:00:11.544\n```\n\nThis is wrong format, it use period as separator\n\nOr this:\n\n```\n00:00:11,5440\n```\n\nThis is also wrong format, millisecond has 4 digit (should be 3)\n\nOr this:\n\n```\n1:00:11,5\n```\n\nSimiliar, hour \u0026 millisecond is only 1 digit (wrong)\n\nOr this\n\n```\n00:00:00.05\n```\n\netc\n\n## Format Support\n\n| Format        | Other parser                    | srt-parser-2           | srt-parser-2 would turn this into |\n| ------------- | ------------------------------- | ---------------------- | --------------------------------- |\n| 00:00:01,544  | Yes :white_check_mark:          | Yes :white_check_mark: | 00:00:01,544                      |\n| 00:00:01.544  | :question: Yes for some of them | Yes :white_check_mark: | 00:00:01,544                      |\n| 00:00:01.54   | :question: Yes for some of them | Yes :white_check_mark: | 00:00:01,544                      |\n| 00:00:00.3333 | No :x:                          | Yes :white_check_mark: | 00:00:00,333                      |\n| 00:00:00.3    | No :x:                          | Yes :white_check_mark: | 00:00:00,300                      |\n| 1:2:3.4       | No :x:                          | Yes :white_check_mark: | 01:02:03,400                      |\n\nBasic principle:\n\n1. If hour,minute,second is shorter than 2 digit, pad start with \"0\", if longer than 2 digit, only save first 2 digit.\n2. Millisecond is the same, but it's 3 digit.\n3. Seperator can be `.`(periods) or `,`(comma), periods(incorrect) will be replace with comma(correct)\n\n\u003c!-- ## SRT Format Standard (kind of)\n| Format       | Is this SRT standard  |\n|--------------|-----------------------|\n| 00:00:01,544 | Yes :white_check_mark:|\n| 00:00:01.544 | No     :x:            |\n| 00:00:00.05  | No     :x:            |\n\nNote: There are no official SRT standard.\n`00:00:01.544` and `00:00:00.05` is not 100% wrong. There are gray area.\nBut most tutorial/file/example/code on the internet use `00:00:01,544`    --\u003e\n\n## Conclusion\n\n1. Support more time format (even wrong format)\n2. Have extensive test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1c7%2Fsrt-parser-2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1c7%2Fsrt-parser-2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1c7%2Fsrt-parser-2/lists"}