{"id":24919547,"url":"https://github.com/kitsumed/subtitlesparserv2","last_synced_at":"2025-04-14T21:43:58.772Z","repository":{"id":274338334,"uuid":"920276424","full_name":"kitsumed/SubtitlesParserV2","owner":"kitsumed","description":"A ASP.NET library for lyrics/subtitles file parsing. Rework/continuation of the original SubtitlesParser.","archived":false,"fork":false,"pushed_at":"2025-04-06T19:41:27.000Z","size":92,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T19:48:32.607Z","etag":null,"topics":["asp-net-core","lyrics","parser","parsing","subtitle","subtitles-parsing"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kitsumed.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":"2025-01-21T21:36:36.000Z","updated_at":"2025-04-06T19:37:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c9c6271-6c0c-46ba-91d8-123720e09be9","html_url":"https://github.com/kitsumed/SubtitlesParserV2","commit_stats":null,"previous_names":["kitsumed/subtitlesparserv2"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitsumed%2FSubtitlesParserV2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitsumed%2FSubtitlesParserV2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitsumed%2FSubtitlesParserV2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitsumed%2FSubtitlesParserV2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kitsumed","download_url":"https://codeload.github.com/kitsumed/SubtitlesParserV2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248966359,"owners_count":21190758,"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":["asp-net-core","lyrics","parser","parsing","subtitle","subtitles-parsing"],"created_at":"2025-02-02T10:20:10.845Z","updated_at":"2025-04-14T21:43:58.733Z","avatar_url":"https://github.com/kitsumed.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Publish to NuGet Gallery](https://github.com/kitsumed/SubtitlesParserV2/actions/workflows/Create%20NuGet%20release.yml/badge.svg)](https://github.com/kitsumed/SubtitlesParserV2/actions/workflows/Create%20NuGet%20release.yml) [![NuGet Version](https://img.shields.io/nuget/v/SubtitlesParserV2)](https://www.nuget.org/packages/SubtitlesParserV2/)\n## SubtitlesParserV2\nUniversal subtitles parser which aims at supporting **parsing** for all subtitle formats.\nFor more info on subtitles formats, see this page: http://en.wikipedia.org/wiki/Category:Subtitle_file_formats\n\u003e [!NOTE]\n\u003e This is a fork/continuation of the original [SubtitlesParser](https://github.com/AlexPoint/SubtitlesParser) that seems to be a bit outdated / not updated anymore on nuget. Since I needed to parse subtitles in one of my projects, I decided to take this existing library, update the dependencies, and rewrite some parts of it in my own way at the same time, fixing / improving some parsers.\n\n## Supported Parsers/Writers\n| Subtitle Format                         | Parser | Writer | Extensions Detection            | Supported Specs / Versions     |\n|-----------------------------------------|:------:|:------:|:-------------------------------:|--------------------------------|\n| SubRip                                  | ✅     | ❌     | `.srt`                         | `srt`                          |\n| LRC                                     | ✅     | ❌     | `.lrc`                         | `Core LRC`, `Enhanced LRC format (A2 extension)`|\n| TMPlayer                                | ✅     | ❌     | `.tmp`                         | [`long \u0026 short codes`](https://wiki.multimedia.cx/index.php/TMPlayer)|\n| MicroDvd                                | ✅     | ❌     | `.sub`                         | `MicroDVD`                     |\n| SubViewer                               | ✅     | ❌     | `.sbv`                         | `SubViewer2`, `SubViewer1`     |\n| SubStationAlpha                         | ✅     | ❌     | `.ssa`, `.ass`                 | `v4.00` + backward             |\n| TTML                                    | ✅     | ❌     | `.ttml`, `.dfxp`               | `TTML 1.0`, `TTML 2.0`         |\n| WebVTT                                  | ✅     | ❌     | `.vtt`                         | `WebVTT`                       |\n| Synchronized Accessible Media Interchange (SAMI) | ✅ | ❌| `.smi`, `.sami`                | `Only Support Time in MS`      |\n| YouTube Timed Text (YoutubeXml)         | ✅     | ❌     | `.ytt`, `.srv3`, `.srv2`, `.srv1` | `srv3`, `srv2`, `srv1`      |\n| MPL2                                    | ✅     | ❌     | `.mpl`, `.mpl2`                | [`MPL`](https://wiki.multimedia.cx/index.php/MPL2)|\n\n### Quickstart\n#### Universal parser\n\nIf you don't specify the subtitle format, the SubtitlesParserV2 will try all the registered parsers with the default configuration\n\n```csharp\nusing (FileStream fileStream = File.OpenRead(pathToSrtFile)){\n\t// Try to parse with all supported parsers\n\tSubtitleParserResultModel? result = SubtitleParser.ParseStream(fileStream, Encoding.UTF8)\n\t// Access the Subtitles with result.Subtitles\n\t// Note that if all parsers fail, the method will return null\n}\n```\n\n#### Get Subtitle format by extension (Extensions detection)\n\n```csharp\nstring fileName = Path.GetFileName(file);\n// Get format enum\nSubtitleFormatType? mostLikelyFormat = SubtitleFormat.GetFormatTypeByFileExtensionName(Path.GetExtension(fileName).Replace(\".\",\"\"));\n// Get format instance\nif (mostLikelyFormat != null) \n{\n\tSubtitleFormat format = SubtitleFormat.GetFormat(mostLikelyFormat.Value);\n\tConsole.WriteLine($\"Matching format is : {format.Name}\");\n}\n```\n\n#### Specific parser (default configuration)\n\nYou can use a specific parser if you know the format of the files you parse.\n\n```csharp\nusing (FileStream fileStream = File.OpenRead(pathToSrtFile)){\n\t// Try to parse with a specific parser using default configuration\n\tSubtitleParserResultModel result = SubtitleParser.ParseStream(fileStream, Encoding.UTF8, SubtitleFormatType.SubStationAlpha)\n\t// Try to parse with a multiple parser using default configuration\n\tSubtitleParserResultModel result = SubtitleParser.ParseStream(fileStream, Encoding.UTF8, new[] { SubtitleFormatType.SubStationAlpha, SubtitleFormatType.LRC });\n}\n```\n#### Specific parser (Advanced configuration)\n\nYou can also specify advanced configurations for parsers that support it.\n\u003e[!NOTE]\n\u003e This is not supported inside `SubtitleParser.ParseStream` methods.\n\n```csharp\n// Get the format\nSubtitleFormat format = SubtitleFormat.GetFormat(SubtitleFormatType.MicroDvd);\n// Get the instance as a advanced parser\nISubtitlesParser\u003cMicroDvdParserConfig\u003e microDvdParserInstance = format.ParserInstance as ISubtitlesParser\u003cMicroDvdParserConfig\u003e;\n// Parse\nmicroDvdParserInstance.ParseStream(fileStream, Encoding.UTF8, new MicroDvdParserConfig() \n{\n\tFramerate = 30, // Force the parser to use a framerate of 30\n});\n\n```\n### Logging\nSubtitlesParserV2 implements [microsoft.extensions.logging.abstractions](https://www.nuget.org/packages/microsoft.extensions.logging.abstractions/) to allow you to redirect the log output to your own logging method (using a LoggerFactory)\n#### Base example\n```csharp\n// Assuming a LoggerFactory already exist\nILoggerFactory existingLoggerFactory = LoggerFactory.Create(builder =\u003e\n{\n\tbuilder.AddConsole(); // Adding the default console logging\n});\n\n// Set SubtitlesParserV2 LoggerFactory to the existing one\nLoggerManager.LoggerFactory = existingLoggerFactory;\n```\n#### ASP.NET Core Websites\n```csharp\n// Get the app loggerFactory\nILoggerFactory loggerFactory = app.Services.GetRequiredService\u003cILoggerFactory\u003e();\nLoggerManager.LoggerFactory = loggerFactory; // Redirect SubtitlesParserV2 logs to our LoggerFactory\n```\n\n## Licenses / Acknowledgements\n**Current code** is licensed under the **GNU Lesser General Public License v3.0** (LGPLv3).\n\u003e [!TIP]\n\u003e While this is not legal advice, a common misconception is that the [LGPL license](https://choosealicense.com/licenses/lgpl-3.0/), due to having \"GPL\" in its name, requires you to license your program under the GPL or the same license. This is not necessarily true. Since this project is a library,\n\u003e the requirements depend on how you use the library and the compatibility between this project's license and your project's license. However, please note that this tip does not override the specific requirements of the LGPL license. There may be\n\u003e additional obligations based on your use case. For further clarification, you can refer to the [LGPL FAQ about static vs dynamic linking requirements](https://www.gnu.org/licenses/gpl-faq.html#LGPLStaticVsDynamic), this [Reddit post](https://www.reddit.com/r/rust/comments/fevz37/comment/fjsg393/), or this [blog post](https://coding.abel.nu/2016/10/the-lgpl-license/#:~:text=LGPL%20is%20not%20%E2%80%9Ccontagious%E2%80%9D%20in,affects%20the%20component%20under%20LGPL.). **Again**, **this is not legal advice**.\n\n⚠️ The **original version**, [available here](https://github.com/AlexPoint/SubtitlesParser/tree/3e3b97409481dccaa5bb96391d1c066cf0f2dfef), is licensed under the original project made by AlexPoint, license/credits:\n```\nThe MIT License (MIT)\n\nCopyright (c) 2015\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitsumed%2Fsubtitlesparserv2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitsumed%2Fsubtitlesparserv2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitsumed%2Fsubtitlesparserv2/lists"}