SubtitlesParser icon indicating copy to clipboard operation
SubtitlesParser copied to clipboard

compatibility error

Open mondherroo opened this issue 5 years ago • 8 comments

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?

mondherroo avatar Apr 26 '19 22:04 mondherroo

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.

AlexPoint avatar Apr 27 '19 12:04 AlexPoint

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

mondherroo avatar Apr 27 '19 23:04 mondherroo

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

AlexPoint avatar Apr 28 '19 12:04 AlexPoint

Sans titre

mondherroo avatar Apr 29 '19 09:04 mondherroo

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);
}

gldraphael avatar Apr 30 '19 04:04 gldraphael

@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 avatar Apr 30 '19 19:04 AlexPoint

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

AlexPoint avatar Apr 30 '19 19:04 AlexPoint

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

gldraphael avatar May 15 '19 03:05 gldraphael