Haxy 9 Posted April 19, 2018 Share Posted April 19, 2018 Hi everyone, I am working on new subtitles provider for Emby using napiprojekt.pl (only for PL subtitles). Everything works fine except encoding in downloaded file. Polish special characters need UTF-8 file format, how to set up encoding during file downloading? Currently I get error "2018-04-19 22:00:46.002 Warn SubtitleEncoder: Unrecognized line in srt: [5333][5366]Lepiej bĹagaÄ o przebaczenie,|niĹź prosiÄ o zgodÄ, D." in log when trying to play movie with subtitles. My code: using (var response = await _httpClient.GetResponse(opts).ConfigureAwait(false)) { var ms = new MemoryStream(); await response.Content.CopyToAsync(ms).ConfigureAwait(false); ms.Position = 0; response.Headers.TryGetValue("Content-Disposition", out var cd); var fileExt = (cd ?? string.Empty).Split('.').LastOrDefault(); if (string.IsNullOrWhiteSpace(fileExt)) { fileExt = "srt"; } return new SubtitleResponse { Format = fileExt, Language = id.Split('=').LastOrDefault(), Stream = ms }; } Response for: http://napiprojekt.pl/unit_napisy/dl.php?l=PL&f=41170265c134e08a6f3167e7510efdb8&t=2e34f&v=dreambox&kolejka=false&nick=&pass=&napios=Linux Thanks for help PS. Sorry for my english. Link to comment Share on other sites More sharing options...
Luke 37290 Posted April 19, 2018 Share Posted April 19, 2018 what is the encoding from the source? Link to comment Share on other sites More sharing options...
Haxy 9 Posted April 19, 2018 Author Share Posted April 19, 2018 From log: 22:45:27.736 Debug SubtitleEncoder: charset windows-1250 detected for D:\Download\TestLibrary\The.Walking.Dead.S08E13.720p.HDTV.x264-AVS\The.Walking.Dead.S08E13.720p.HDTV.x264-AVS.pl.srt 2018-04-19 22:45:27.737 Debug TextEncoding: Getting encoding object for character set: windows-1250 Link to comment Share on other sites More sharing options...
Luke 37290 Posted April 19, 2018 Share Posted April 19, 2018 Well that's what was detected, but detection is not always perfect. What i'm asking is to find out what's coming down from the api you're getting them from. Link to comment Share on other sites More sharing options...
Haxy 9 Posted April 19, 2018 Author Share Posted April 19, 2018 Jus open the link from my first post (below code block). You will get subtitles Link to comment Share on other sites More sharing options...
Luke 37290 Posted April 19, 2018 Share Posted April 19, 2018 Sure, but then I have to do the research to figure out the original encoding. I was asking if you knew that information. Link to comment Share on other sites More sharing options...
Haxy 9 Posted April 19, 2018 Author Share Posted April 19, 2018 I just generate that link in my code by calculating hash from file then i need to save this text to srt file with utf8. Maybe something like: Encoding.UTF8.GetString after i get content of respons Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now