SubtitleBytesClearFormatting 5.0.0

dotnet add package SubtitleBytesClearFormatting --version 5.0.0
NuGet\Install-Package SubtitleBytesClearFormatting -Version 5.0.0
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="SubtitleBytesClearFormatting" Version="5.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SubtitleBytesClearFormatting --version 5.0.0
#r "nuget: SubtitleBytesClearFormatting, 5.0.0"
#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 SubtitleBytesClearFormatting as a Cake Addin
#addin nuget:?package=SubtitleBytesClearFormatting&version=5.0.0

// Install SubtitleBytesClearFormatting as a Cake Tool
#tool nuget:?package=SubtitleBytesClearFormatting&version=5.0.0

SubtitleBytesClearFormatting

.Net library that allows to extract bytes after subtitle formatting structures. Also allows you to remove bytes representing subtitle tags.

Supports extraction from 5 types of subtitles: ass, sbv, srt, sub, vtt.

Installation

To install, use the nuget package.

Cleaner usage

All cleaners work in the same way. They look for subtitle structures and extract the text after them. Let's look at the example of the srt file.

1
00:00:31,540 --> 00:00:35,190
Hello world!

First, we read the bytes from this file. Then we will send them for cleaning. Then we write them to a file and get the following result:

Hello world!

Let's see how to use the cleaners. SrtCleaner was used as an example.

// First create an instance of the class
SrtCleaner cleaner = new();
// Then you can extract text bytes by passing the subtitle bytes to the method
List<byte> bytesWithoutFormatting = cleaner.DeleteFormatting(subtitleBytes);
// Or do it async
List<byte> bytesWithoutFormatting = await cleaner.DeleteFormattingAsync(subtitleBytes);

Static class TxtCleaner allows transforming text bytes.

// Makes text in one line (Asynchronous version: ToOneLineAsync(byte[] textInBytes))
TxtCleaner.ToOneLine(textInBytes);
// Removes required tags (Asynchronous version: DeleteTagsAsync(byte[] textInBytes, Dictionary<byte, List<TxtTag>> tagsDictionary))
TxtCleaner.DeleteTags(textInBytes, targetTagsDictionary);

One abstract class and two interfaces add flexibility to cleaners:

  1. SubtitleFormatCleaner - all cleaner inherit from it (except TxtCleaner).
  2. ISubtitleCleaner - the inherited must implement the method: List<byte> DeleteFormatting().
  3. ISubtitleCleanerAsync - the inherited must implement the method: Task<List<byte>> DeleteFormattingAsync().

Tags generator usage

Static class TagsCollectionGeneretor allows you to create dictionaries of tags. Consider his methods:

  1. GetBasicTags() - return tags: <b>, </b>, {b}, {/b}, <i>, </i>, {i}, {/i}, <u>, </u>, {u}, {/u}, <font*>, </font>, {\a*}.
  2. GetSubSpecificTags() - returns tags: {y:i}, {y:b}, {y:u}, {y:s}, {Y:i}, {Y:b}, {Y:u}, {Y:s}, {f:*}, {F:*}, {s:*}, {S:*}, {c:*}, {C:*}, {p:*}, {P:*}, {h:*}, {H:*}, {DEFAULT}
  3. GetAssSpecificTags() - returns common ass tags.
  4. GetTagsFromXml(string path) - returns tags from your XML file.

Dictionaries of tags (Dictionary<byte, List<TxtTag>>) have simple structure. Consider his elements:

  1. byte - all tags in the list start with this byte.
  2. List<TxtTag> - list with target tags.

Class TxtTag represent common tag. Which have a tag name, bytes of that tag and bytes to replace that tag.

XML tags file

You can use your own XML files to create a dictionary of tags. Just follow the example.

<tags>
  <tag>
    
    
    
    <name>{b*}</name>
    
    
    <replaceBytes>
      <byte>58</byte>
      <byte>41</byte>
    </replaceBytes>
  </tag>
  ...
</tags>
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.0 191 3/10/2023