Jump to content

Emby Server - Compreehensive subtitles recognition with alternatives and fallback


anderbytes

Recommended Posts

anderbytes

As of today, the 1st parameter of each item in https://github.com/MediaBrowser/Emby/blob/master/MediaBrowser.Server.Implementations/Localization/iso6392.txt is a 3-digit format of the language and dictates the matcheable text to be searched in a subtitle file name, for autodetection of preferred language.

 

my example here:

preferred language: pt-BR (Portuguese from Brazil)

subtitle files already recognized: #######.pob.srt

 

PROBLEMs:

- VLC doesn't translates the 3-digit format, so in list it only says "pob" instead of "Portuguese (Brazil)". He only understands it when the file has "pt-BR" instead.

- Subtitle downloaders usually don't use the 3-digit format, be it Windows or Linux versions

- Users are forced to always rename everything to 3-digit, no choice is given to us.
 

 

It happens that there's another correct way of storing the language name... using exactly the other parameters seen in the file above. in my case... a subtitle called #######.pt-BR.srt is VERY common in subtitle downloaders around the web.

 

 

My question here is: is it possible to... when Emby finds a file #######.LANG.srt but no LANG as one of the 1st parameter of iso6932.txt, that it fallbacks into search the 2nd and 3rd parameters?

 

I know that this won't impact 90% of the users. But the rest of us appreciate the help.

 

 

ps: it has to be a case-insensitive search, or else the format 2-digit-lowercase-2-digit-uppercase has to be enforced in that txt.

Edited by anderbytes
Link to comment
Share on other sites

I looked into this and we're already doing this, so you should be ok naming with pt-br

Link to comment
Share on other sites

anderbytes

Remember that other topic where we discussed the reason to respect the official format of 5-digit as (lo-HI) for metadata download?

 

Well... I guess it's the same here. He doesn't recognize pt-BR as the same as pt-br. I guess if we just substitute the lowercase pt-br for pt-BR in iso6932.txt , it might just work.

 

I'm perfectionist. Sue me :-) :-)

 

 

 

I can create a simple pull request for this later (and maybe even searching for more occurrences in the whole code)

Edited by anderbytes
Link to comment
Share on other sites

I don't think any changes are necessary because we don't really do anything with the value you enter. it could just as easily be elephant instead of pt-br.

Link to comment
Share on other sites

anderbytes

I know. I'm just trying to polish it.

 

Renaming everything from pt-BR to pt-br is as bad as renaming to pob. It's just extra work that shouldn't happen. Understand?

Link to comment
Share on other sites

but our string comparisons are already case-insensitive so that's why that shouldn't matter.

Link to comment
Share on other sites

anderbytes

I'm trying to explain that it seems that if the cases aren't exact, the fallback won't work, it won't find anything, and that's what happens today

Edited by anderbytes
Link to comment
Share on other sites

anderbytes

but our string comparisons are already case-insensitive so that's why that shouldn't matter.

Very strange! Emby doesn't plays automatically my pt-BR external sub, only when it is pob :-(

Link to comment
Share on other sites

anderbytes

what won't find anything?

Find = auto-select from preferred language when in playback

Link to comment
Share on other sites

anderbytes

In short: When I have pt-BR instead of pob external subtitle file, when I go to play something there are no subtitles playing in default. I have to manually select it

Edited by anderbytes
Link to comment
Share on other sites

anderbytes

@@Luke, @@ebr, Just did some more tests... and I guarantee that it's not working as it should.

 

Downloaded subtitles: fr.srt (French) , por.srt (Portuguese Portugal), pt-BR.srt (mine, for Brazil) and created a copy of the last one with pt-br.srt extension (for testing case sensitivity).

 

Now look how strange Emby has chosen the default playback subtitle "Marked with symbol of CHECK" for different scenarios in the attached files. The name of the attached jpeg file indicates what external subs were at the folder while that test and were refreshed in the movie. Also, the items below that are in bold point which files were in folder, too.

 

####################################################################################################################

fr - pob - por - pt-br - pt-BR

"pob" brought correctly... So as I understood, the 1st column of iso6932.txt is a top priority. Good.

 

fr - POB - por - pt-br - pt-BR

changed "pob" to "POB", and that alone messed up with Emby. For some bizzarre reason he gave me FR as the default playback subtitle. Bad case sensivity! Bad!

 

fr - por - pt-br - pt-BR

He chose to give me "por", which is wrong, even more because there are pt-br and pt-BR in the folder!

 

fr - pt-br - pt-BR

Erased "por"  and now he correctly brought me "pt-br". I can tell because it appears "Ptbr" and not "PtBR".

 

pt-br

Removing "fr"and leaving "pt-br" alone in the folder messes up with Emby that before in test above had recognized correctly that subtitle file as default. He choses no subtitle, and "Off" is chosen by default.

 

pt-BR

Same as above

 

pob

Now this works... "pob" alone in folder works OK

 

POB

Same as above.

####################################################################################################################

 

 

What I see is: Emby choses differently depending on some weird conditions that I haven't learned the pattern yet.

post-109582-0-97255000-1469059495_thumb.jpg

post-109582-0-11927100-1469059502_thumb.jpg

post-109582-0-23706000-1469059506_thumb.jpg

post-109582-0-45158000-1469059510_thumb.jpg

post-109582-0-84753900-1469059515_thumb.jpg

post-109582-0-60978600-1469059521_thumb.jpg

post-109582-0-16023300-1469059684_thumb.jpg

post-109582-0-23815800-1469059688_thumb.jpg

Edited by anderbytes
Link to comment
Share on other sites

anderbytes

Stuff has just got weirder!

 

I just remembered that @@Luke coded something in the past to "remember" last used or most used languages , the more the user playbacks and chooses...

Well, whether I change the subtitles within playback, next playback default subtitle changes.

 

With the scenarios where a lot of subtitle are available, we have to learn if is it wrong or not...

BUT, in the scenarios where pt-BR or pt-br are alone... should work whatever, and they don't, as described in the last post.

Edited by anderbytes
Link to comment
Share on other sites

anderbytes

Ok, I'm adding a fix, thanks.

Tnx. Looking forward to it.

Link to comment
Share on other sites

anderbytes

Ok, I'm adding a fix, thanks.

 

Now that I use Docker, I could create a Beta envinronment, and I'm happy to report that the issue is 90% gone.

 

I still couldn't re-do all those test scenarios just like before with this Beta... but I can state these, for now:

#1 -> Alone pt-BR in folder now is recognized correctly... for some reason it shows itself as "pob" in Media Details and Subtitles list in Playback (even if there no "pob" in folder). But that's the least of the problems!!  :-)

 

#2 -> When some other languages were in the folder and "por" was included, he incorrectly chose default as "por" (that is related to pt-PT) over "pt-BR" or "pt-br" . This shouldn't happen. If I see anything in the new code that explains this... I'll gladly point it. Maybe he is getting "pt" from "pt-BR" and deciding it only with that? If yes... wrong behaviour.

 

------------

Complemeting #1 above, about the language name shown in "Media Details" and Playback subtitles options, today it shows the [1] (first field) of iso6392.txt, but actually it had to show the [3] (third field) , example: English, Portuguese (Brazil), French, German, Portuguese (Portugal), etc...  OR EVEN BETTER : There could be a [5] (fifth field) where it stores how is the language called in it's own language. So the before would be: English, Português (Brasil), Français, Portugais (Portugal), etc...etc... to be shown in playback subtitles list and Media Details. That would be neat!

 

Thanks!!!

Edited by anderbytes
  • Like 1
Link to comment
Share on other sites

anderbytes

Thanks for confirming.

 

Now it's time for some jaw-dropping :D :D . In this latest Beta.... I believe he's now using  ALPHABETICAL ORDER to choose the default subtitle to start playback!

 

Look at this sequence of tests using BETA (each time deleting the chosen one in the previous test), see if you recognize Emby's chosing pattern....

####################################################################################################################

en - eng - fr - pob - por - pt-br - pt-BR   => chosen: en

 

eng - fr - pob - por - pt-br - pt-BR          => chosen: eng

 

fr - pob - por - pt-br - pt-BR                 => chosen: fr

 

pob - por - pt-br - pt-BR                      => chosen: pob (can tell the difference because I put text -pob- inside this subtitle file, to tell them apart) - Blue here... but it was alphabetical luck

 

por - pt-br - pt-BR                              => chosen: por

 

pt-br - pt-BR                                      => chosen: pt-br  (can tell the difference because I put text -pt-br- inside this subtitle file, to tell them apart)

 

pt-BR                                               => chosen: pt-BR (yay! no more "Off" like the reported yesterday)

####################################################################################################################

 

I'll be taking a closer look at the code... use my time today to try to find what could be done in the code.

See ya

post-109582-0-74311300-1469149716_thumb.jpg

post-109582-0-15351000-1469149717_thumb.jpg

post-109582-0-55927800-1469149717_thumb.jpg

post-109582-0-81113600-1469149717_thumb.jpg

post-109582-0-19365400-1469149718_thumb.jpg

post-109582-0-49976700-1469149718_thumb.jpg

Edited by anderbytes
Link to comment
Share on other sites

The display order in the menu doesn't matter. For external subtitles, that's just going to be the order of the file names.

Link to comment
Share on other sites

anderbytes

The display order in the menu doesn't matter. For external subtitles, that's just going to be the order of the file names.

 

If it were only the display order in list... there would be no problem.

 

What I'm saying IS: the default subtitle played at start of playback is alwas the first in alphabetical order, if we have more than 1 subtitle in folder.

Edited by anderbytes
Link to comment
Share on other sites

anderbytes

I could just use ONE subtitle for each movie... but I'm trying to help free Emby of nasty bugs like this one. Ignoring it is not an option for me.

 

 

 

and more...showing the "3 letter" in Subtitle List is also unpleasant... showing the readable name ( [3] in iso6392.txt )  is way more beautiful, you just have to create another private variable in CultureDto object for it... fill it along the other when they are filled... and use it at the right moment.

 

ps: can you imagine Netflix showing 3-letter options for audio and subtitles options?

Edited by anderbytes
Link to comment
Share on other sites

What I'm saying IS: the default subtitle played at start of playback is alwas the first in alphabetical order, if we have more than 1 subtitle in folder.

 

Not necessarily. If they have different characteristics such as default/forced flags, then that will affect which one is chosen. If all three have the same characteristics, then yes, the first one is chosen. Sorry but this isn't a bug. It just so happens you want the second one to be chosen, but if they're all pt-BR or pob then they're all the same.

Link to comment
Share on other sites

and more...showing the "3 letter" in Subtitle List is also unpleasant... showing the readable name ( [3] in iso6392.txt )  is way more beautiful, you just have to create another private variable in CultureDto object for it... fill it along the other when they are filled... and use it at the right moment.

 

ps: can you imagine Netflix showing 3-letter options for audio and subtitles options?

 

Yes, this we can definitely improve on.

Link to comment
Share on other sites

anderbytes

Not necessarily. If they have different characteristics such as default/forced flags, then that will affect which one is chosen. If all three have the same characteristics, then yes, the first one is chosen. Sorry but this isn't a bug. It just so happens you want the second one to be chosen, but if they're all pt-BR or pob then they're all the same.

 

C'mon Luke... I took some time to do those tests above, please read carefully, and understand that they're not all pob and pt-BR.

- I have nothing "default" or "forced", don't like those concepts.

- at first the folder had "en" , "eng" , "fr" , "pob" , "por" , "pt-br" , "pt-BR" and he ALWAYS ended up chosing the first of them alphabetically.. no matter my preferred language in settings.

- If I re-do all the tests only using "en" , "fr" and "pt-BR" , you'll see that he'l choose "en", because "e" comes first.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...