SpongeEngine.SubtitleSharp
2.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SpongeEngine.SubtitleSharp --version 2.0.1
NuGet\Install-Package SpongeEngine.SubtitleSharp -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SpongeEngine.SubtitleSharp" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SpongeEngine.SubtitleSharp --version 2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SpongeEngine.SubtitleSharp, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SpongeEngine.SubtitleSharp as a Cake Addin #addin nuget:?package=SpongeEngine.SubtitleSharp&version=2.0.1 // Install SpongeEngine.SubtitleSharp as a Cake Tool #tool nuget:?package=SpongeEngine.SubtitleSharp&version=2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SubtitleSharp
C# library for parsing and handling subtitle files (e.g., SRT, VTT, ASS).
Features
- Supports parsing subtitle formats including SubRip (SRT), WebVTT (VTT), and SubStation Alpha (ASS).
- Converts subtitle files to structured data (
SubtitleItem
) for easy processing. - Handles timecode validation and parsing.
- Cross-platform compatibility with .NET 6.0+.
- Async/await support for non-blocking subtitle processing.
Installation
Install via NuGet:
dotnet add package SpongeEngine.SubtitleSharp
Quick Start
Basic Usage
using SpongeEngine.SubtitleSharp;
// Parse an SRT file into structured subtitle items
var srtFilePath = "path_to_subtitle.srt";
using var fileStream = new FileStream(srtFilePath, FileMode.Open, FileAccess.Read);
var parser = new SrtParser();
var subtitleItems = parser.ParseStream(fileStream, Encoding.UTF8);
// Output subtitle start and end times
foreach (var item in subtitleItems)
{
Console.WriteLine($"Start: {item.StartTime}, End: {item.EndTime}");
}
Configuration
Parsing Options
// Manually specify format for parsing
SubtitlesFormat format = SubtitlesFormat.SubRipFormat;
using var fileStream = new FileStream("path_to_subtitle.srt", FileMode.Open, FileAccess.Read);
var parser = new SubtitleParser();
var subtitleItems = parser.ParseStream(fileStream, Encoding.UTF8, format);
Error Handling
try
{
var subtitleItems = parser.ParseStream(fileStream, Encoding.UTF8, format);
}
catch (ArgumentException ex)
{
Console.WriteLine($"Error parsing subtitle: {ex.Message}");
}
Logging
ILogger logger = LoggerFactory
.Create(builder => builder
.AddConsole()
.SetMinimumLevel(LogLevel.Debug))
.CreateLogger<SubtitleParser>();
// Example usage of logger in subtitle parsing
var parser = new SubtitleParser(logger);
Testing
To run the tests:
dotnet test
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and feature requests, please use the GitHub issues page.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.Extensions.AI (>= 9.1.0-preview.1.25064.3)
- Microsoft.Extensions.Caching.Memory (>= 9.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.1)
- Polly (>= 8.5.1)
- System.Linq.Async (>= 6.0.1)
-
net7.0
- Microsoft.Extensions.AI (>= 9.1.0-preview.1.25064.3)
- Microsoft.Extensions.Caching.Memory (>= 9.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.1)
- Polly (>= 8.5.1)
- System.Linq.Async (>= 6.0.1)
-
net8.0
- Microsoft.Extensions.AI (>= 9.1.0-preview.1.25064.3)
- Microsoft.Extensions.Caching.Memory (>= 9.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.1)
- Polly (>= 8.5.1)
- System.Linq.Async (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.