SubtitlesParser
SubtitlesParser copied to clipboard
compatibility error
hello sir, i used this parser in asp net core 2.1 but it doesn't work, i got this error in that line "using (var fileStream = File.OpenRead(pathToSrtFile))" i got this error message(IformFile doesn't have definition for "OpenRead") i replaced (OpenRead with OpenReadStream) but still don't work. so do you have any suggestion sir?
I think you are using the wrong File class. You need to use System.IO.File.OpenRead (see documentation) and not Microsoft.AspNetCore.Http.IFormFile.OpenReadStream (see documentation). Let me know if that works.
i already used System.IO.File.OpenRead but i got another error in that line "var items = parser.ParseStream(fileStream);" About (ParseStream)
Could you copy and paste the code you are using to parse subtitle files and the complete error message that you get?
Here's a full working csx example:
#!/usr/bin/env dotnet-script
#r "nuget: SubtitlesParser, 1.4.8"
#load "serilog.csx"
using Serilog;
using SubtitlesParser.Classes.Parsers;
var parser = new VttParser();
using (var fileStream = File.OpenRead("captions.vtt")){
var items = parser.ParseStream(fileStream, Encoding.UTF8);
Log.Verbose("{@items}", items);
}
@mondherroo : your compiling error is due to the fact that you are not specifying an encoding when using the SrtParser. The generic Parser (SubParser) has a method ParseStream which defaults the encoding to UTF-8 but not the specific parsers.
@gldraphael Could you provide the subtitles file as well (captions.vtt)?
Here's the file as a text document: captions.vtt.txt
Also, it'd be nice if the VttParser
could default to a UTF8 encoding, since UTF8 would be in conformance to the WebVTT spec. Link