Install SubtitlesParser via NuGet
masterTo use SubtitlesParser in your .NET project, install the package using the NuGet Package Manager Console.
Install-Package SubtitlesParserrepository·master·Indexed 41 days ago
https://github.com/alexpoint/subtitlesparserA universal .NET library for parsing and writing various subtitle file formats. It provides a universal SubParser for automatic format detection and specific parsers for MicroDvd, SubRip (Srt), SubStationAlpha (Ssa), SubViewer, TTML, WebVTT, and YouTube XML. It also includes writers for exporting SubtitleItems to SubRip and SubstationAlpha formats.
To use SubtitlesParser in your .NET project, install the package using the NuGet Package Manager Console.
Install-Package SubtitlesParserTo export a list of SubtitleItems to a file or stream, use a specific writer class. Currently, the library supports writing to:
SrtWriter (SubRip)SsaWriter (SubstationAlpha)Both synchronous WriteStream and asynchronous WriteStreamAsync methods are available.
var writer = new SubtitlesParser.Classes.Writers.SrtWriter();
using (var fileStream = File.OpenWrite(pathToSrtFile)) {
writer.WriteStream(fileStream, yourListOfSubtitleItems);
}If you already know the format of the subtitle file, you can instantiate a specific parser class for better performance and reliability. Supported parsing formats include:
MicroDvdParserSrtParser (SubRip)SsaParser (SubStationAlpha)SubViewerParserTtmlParser (TTML)VttParser (WebVTT)YtXmlFormatParser (Youtube specific XML)var parser = new SubtitlesParser.Classes.Parsers.SrtParser();
using (var fileStream = File.OpenRead(pathToSrtFile)){
var items = parser.ParseStream(fileStream);
}If the subtitle format is unknown, use the SubParser class. It will automatically attempt to use all registered parsers (currently supporting MicroDvd, SubRip, SubStationAlpha, SubViewer, TTML, WebVTT, and Youtube specific XML) until one succeeds.
var parser = new SubtitlesParser.Classes.Parsers.SubParser();
using (var fileStream = File.OpenRead(pathToSrtFile)){
var items = parser.ParseStream(fileStream);
}