Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
Potential Subtitle Handling Bug
#16
The damage occurs here:

https://github.com/xbmc/xbmc/blob/Matrix....cpp#L2112

Scans the string from left to right.

1st loop: info.language is empty
              langTmp = "Back"

2nd loop: info.language is empty
              LangTmp = "to"
              if statement on line 2119 is met
              info.language = "tor"
Reply
#17
Know next to nothing regarding C++ but I think I fixed it.

https://github.com/JDRIVO/xbmc/blob/Matr...c/Util.cpp

Image
 
Code:
2021-12-05 18:01:08.875 T:1880    DEBUG <general>: CUtil::GetExternalStreamDetailsFromFilename - Language = 'eng' / Name = 'Back to the Future Part III (1990) (External)' / Flag = '0' from C:\Users\Jay\Documents\strm\movies\Back to the Future Part III (1990).eng.srt
Reply
#18
i'd probably suggest more like this:
https://github.com/matthuisman/xbmc/comm...0054d5edb3
(i haven't compiled to test)

As going backwards, you would want to check for the flags first, then the language.
Also, just prepending the name stops you from needing the "count" variable.
Reply
#19
I'll try it out and let you know. I think the for loop should stop scanning for languages in the string when the year in the string appears. Otherwise, the possibility of incorrect language identification is still present. If no language is identified up to that point maybe default to the user's default language in case they have forgotten to append the language to the subtitles filename or set the language to unknown.
Reply
#20
And some other ideas:

Optional parameters for setSubtitles:
1. Video name: Pass the video name so that it can be removed from the subtitles string to improve match accuracy
2. Name preference of subtitles as shown in the GUI: either as only the language detected or the subtitles filename
Reply
#21
Matt, yours compiles. Just need to change the for loop creation code to this:

Code:
for (std::vector<std::string>::reverse_iterator it = tokens.rbegin(); it != tokens.rend(); ++it)

Otherwise it won't compile.
Reply
#22
oh right - good catch.
updated commit: https://github.com/matthuisman/xbmc/comm...4552eee48a
Did it work as intended?
Reply
#23
@matthuisman confirming your code solves the problem. Just may want to double-check that the identified flag number is correct as I don't know what "flag" refers to and the old and new code produce the same flag number.
 
New:
Code:
2021-12-11 11:42:47.264 T:6912    DEBUG <general>: CUtil::GetExternalStreamDetailsFromFilename - Language = 'eng' / Name = 'Back to the Future Part III (1990) [tt0099088] (External)' / Flag = '0' from C:\Users\Jay\Documents\strm\movies\Back to the Future Part III (1990) [tt0099088] English.srt

Old:
Code:
2021-12-11 11:57:47.644 T:9404    DEBUG <general>: CUtil::GetExternalStreamDetailsFromFilename - Language = 'ton' / Name = 'Back the Future Part III (1990) [tt0099088] English (External)' / Flag = '0' from C:\Users\Jay\Documents\strm\movies\Back to the Future Part III (1990) [tt0099088] English.srt

New:
Code:
2021-12-11 11:43:05.448 T:4748    DEBUG <general>: CUtil::GetExternalStreamDetailsFromFilename - Language = 'eng' / Name = 'No Time to Die (2021) (External)' / Flag = '64' from C:\Users\Jay\Documents\strm\movies\No Time to Die (2021) English Forced.srt

Old:
Code:
2021-12-11 11:48:06.175 T:13508   DEBUG <general>: CUtil::GetExternalStreamDetailsFromFilename - Language = 'nor' / Name = 'Time to Die (2021) English (External)' / Flag = '64' from C:\Users\Jay\Documents\strm\movies\No Time to Die (2021) English Forced.srt
Reply
#24
The flag relates to forced and or default.
64 is decimal of the hex flag for forced (0x0040)
Reply
#25
Understood. Cheers for the insight. Would you mind creating a pull request? Seems the devs gave up on this thread.
Reply
#26
PR opened here:
https://github.com/xbmc/xbmc/pull/20666
Reply
#27
Champ, cheers boss.
Reply
#28
@SEIKT
the commit is in latest 20 nightly now
http://mirrors.kodi.tv/nightlies/windows...er-x64.exe 

I noticed li.setSubtitles(['D:\\Back to the Future Part III (1990).eng.srt']) seems to not work on Kodi 20 but does in Kodi 19.
I tried earlier nightly builds (1st dcember) to make sure it wasnt that PR that caused it and same issue.
On Kodi 20, I need to browse for the subtitle.
Doing that I could confirm the language is then detected correctly

Found the issue with setSubtitles and have new PR to fix that:
https://github.com/xbmc/xbmc/pull/20671

In the meantime, you can just do li.setSubtitles([None, 'D:\\Back to the Future Part III (1990).eng.srt']) to test
Reply
#29
Don't we still have a problem that the requirement is to get the filename of the video item and strip that from the subtitle filename prior to  parsing for the language?  What this has done is better, but I think in the case of No Time To Die.chs.srt for example, chs isn't recognized by Kodi (unless added by user in advancedsettings) so instead of getting language "unknown" it will still return "Norwegian".  (I use chs as example as it seems to be a common work around for limitations of using ISO 639 language codes.)

scott s.
.
Reply
#30
That is way out of scope of this issue.
You'd need to make your own PR adding more language codes etc
Reply

Logout Mark Read Team Forum Stats Members Help
Potential Subtitle Handling Bug0