{"id":19771037,"url":"https://github.com/benlipp/srt-parser","last_synced_at":"2025-04-30T17:32:37.718Z","repository":{"id":62493144,"uuid":"86481355","full_name":"benlipp/srt-parser","owner":"benlipp","description":"A PHP library to parse SRT files","archived":false,"fork":false,"pushed_at":"2020-08-28T23:08:59.000Z","size":16,"stargazers_count":21,"open_issues_count":4,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T22:04:27.698Z","etag":null,"topics":["composer","php","srt","srt-parser","srt-subtitles"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benlipp.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}},"created_at":"2017-03-28T16:13:58.000Z","updated_at":"2024-09-06T23:48:21.000Z","dependencies_parsed_at":"2022-11-02T11:30:58.781Z","dependency_job_id":null,"html_url":"https://github.com/benlipp/srt-parser","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlipp%2Fsrt-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlipp%2Fsrt-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlipp%2Fsrt-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benlipp%2Fsrt-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benlipp","download_url":"https://codeload.github.com/benlipp/srt-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251751297,"owners_count":21637899,"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":["composer","php","srt","srt-parser","srt-subtitles"],"created_at":"2024-11-12T05:01:07.259Z","updated_at":"2025-04-30T17:32:37.465Z","avatar_url":"https://github.com/benlipp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"SRT Parser\n=\n[![Build Status](https://travis-ci.org/benlipp/srt-parser.svg?branch=master)](https://travis-ci.org/benlipp/srt-parser)\n\nA PHP library to parse SRT files.  \nBuilt by Ben Lippincott for [LiveTech](http://www.liveteched.com/)\n\nInstallation / Requirements\n-\nRun \n`composer require \"benlipp/srt-parser\"`\nand let Composer do the work.\n\nPHP 7+ is **REQUIRED**! This isn't amateur hour.  \n\nUsage\n-\nImport the `Parser` class: `use Benlipp\\SrtParser\\Parser;`\n\nUse it:\n````\n$parser = new Parser();\n\n$parser-\u003eloadFile('/path/to/srtfile.srt');\n\n$captions = $parser-\u003eparse();\n````\nor\n````\n$parser = new Parser();\n\n$parser-\u003eloadString($formatted_caption_input);\n\n$captions = $parser-\u003eparse();\n````\n\n`parse()` returns an array of captions. Use them like so:\n\n````\nforeach($captions as $caption){\n    echo \"Start Time: \" . $caption-\u003estartTime;\n    echo \"End Time: \" . $caption-\u003eendTime;\n    echo \"Text: \" . $caption-\u003etext;\n}\n````\nA caption can be returned as an array instead of an object, if you prefer. The array is `snake_case` for compatibility with Laravel's attributes.\n````\nforeach($captions as $caption){\n    $caption = $caption-\u003etoArray();\n    echo \"Start Time: \" . $caption['start_time'];\n    echo \"End Time: \" . $caption['end_time'];\n    echo \"Text: \" . $caption['text'];\n}\n````\nFor Laravel usage with a model:\n````\n$url = \"https://youtu.be/dQw4w9WgXcQ\";\n$video = new Video($url);\nforeach ($captions as $caption) {\n    $data = new VideoMetadata($caption-\u003etoArray());\n    $video-\u003evideoMetadata()-\u003esave($data);\n}\n````\n\nYou can also chain the `parse()` method:\n````\n$parser = new Parser();\n$captions = $parser-\u003eloadFile($srtPath)-\u003eparse();\n````\n\nContributing\n-\nRun PHPUnit on your changes, pretty please. If you add a new feature, add tests for that feature.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenlipp%2Fsrt-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenlipp%2Fsrt-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenlipp%2Fsrt-parser/lists"}