AlexPoint / SubtitlesParser

Multi formats subtitles parser in C#
MIT License
134 stars 40 forks source link

compatibility error #18

Open mondherroo opened 5 years ago

mondherroo commented 5 years ago

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?

AlexPoint commented 5 years ago

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.

mondherroo commented 5 years ago

i already used System.IO.File.OpenRead but i got another error in that line "var items = parser.ParseStream(fileStream);" About (ParseStream)

AlexPoint commented 5 years ago

Could you copy and paste the code you are using to parse subtitle files and the complete error message that you get?

mondherroo commented 5 years ago

Sans titre

gldraphael commented 5 years ago

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);
}
AlexPoint commented 5 years ago

@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.

AlexPoint commented 5 years ago

@gldraphael Could you provide the subtitles file as well (captions.vtt)?

gldraphael commented 5 years ago

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