Kodi Community Forum
Potential Subtitle Handling Bug - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: Potential Subtitle Handling Bug (/showthread.php?tid=365802)

Pages: 1 2 3


Potential Subtitle Handling Bug - SEIKT - 2021-12-03

My English subtitles for the movie: No Time to Die (2020) are being registered as Norwegian subs. The filename of the subtitles is: No Time to Die (2020) English.srt

The cause of this is clear. The language code for Norwegian is "no" and "No" is at the start of the string of the movie title.

The only solution to this issue I have found is storing the movie and subtitles in their own folder and naming the subtitles as: English.srt


RE: Potential Subtitle Handling Bug - scott967 - 2021-12-03

(2021-12-03, 04:00)SEIKT Wrote: My English subtitles for the movie: No Time to Die (2020) are being registered as Norwegian subs. The filename of the subtitles is: No Time to Die (2020) English.srt

The cause of this is clear. The language code for Norwegian is "no" and "No" is at the start of the string of the movie title.

The only solution to this issue I have found is storing the movie and subtitles in their own folder and naming the subtitles as: English.srt
Reviewing the code at Util.cpp, I do not believe that is the cause.  The first thing the filename parser does for srt is remove the movie name.  (Confirmed testing on Kodi 19.3)

Could you provide a debug log showing you playing this movie?

scott s.
.


RE: Potential Subtitle Handling Bug - Karellen - 2021-12-03

(2021-12-03, 04:00)SEIKT Wrote: The filename of the subtitles is: No Time to Die (2020) English.srt
I think you named it wrong.

Try... No Time to Die (2020).eng.srt

https://forum.kodi.tv/showthread.php?tid=210069&pid=2861861#pid2861861


RE: Potential Subtitle Handling Bug - SEIKT - 2021-12-03

Should mention I am passing the subtitles path to a listitem via the setSubtitles method.

Here is the relevant info from the log. I tried the naming convention as you suggested Karellen, the issue persists.

2021-12-03 15:23:36.802 T:14324   DEBUG <general>: CUtil::GetExternalStreamDetailsFromFilename - Language = 'nor' / Name = 'Time to Die (2021) English (External)' / Flag = '0' from C:\Users\Jay\Documents\strm\movies\No Time to Die (2021) English.srt


RE: Potential Subtitle Handling Bug - SEIKT - 2021-12-03

Here is another example of English Back the Future Part III subs being registered as Tongan. Seems to be because "to" is in the title - "to" is being extracted from the title.

2021-12-03 15:53:17.703 T:15444   DEBUG <general>: CUtil::GetExternalStreamDetailsFromFilename - Language = 'ton' / Name = 'Back the Future Part III (1990) eng (External)' / Flag = '0' from C:\Users\Jay\Documents\strm\movies\Back to the Future Part III (1990).eng.srt


RE: Potential Subtitle Handling Bug - Klojum - 2021-12-03

(2021-12-03, 06:32)SEIKT Wrote: Should mention I am passing the subtitles path to a listitem via the setSubtitles method.

Which part of that method?
- You mean you set a single path for all subtitle files?
- What about your preferred subtitle language?
- The language(s) to be searched for when downloading?

I have both your movies, and they are (always) handled with the correct subtitle language.

Best if you give us your full debug log (wiki) (via a pastebin-method please) instead of just single lines, otherwise this thread will take months...


RE: Potential Subtitle Handling Bug - SEIKT - 2021-12-03

Unsure what you mean by which part of the method. For clarity sake this is an example of how subtitles are set:
 
Code:
item = xbmcgui.ListItem(path="http://localhost:{}/play".format(serverPort))
item.setSubtitles(["C:\\Users\\Jay\\Documents\\strm\\movies\\Back to the Future Part III (1990).eng.srt"])

What about your preferred subtitle language - English
The language(s) to be searched for when downloading - English

Here is the log
https://paste.kodi.tv/wavadasoge.kodi


RE: Potential Subtitle Handling Bug - Karellen - 2021-12-03

@SEIKT

I cannot replicate your issue. See from line 2872 in my log... https://paste.kodi.tv/ohoqifiqim.kodi where the subtitle file is correctly identified.


RE: Potential Subtitle Handling Bug - jjd-uk - 2021-12-03

Going by that log you have strm files that point to your movie files which are stored on Google drive, I assume that's what's happening as the gdrive addon seems to be called. Is behaviour any different if you have both the movie file and subtitle file locally in the same folder so the use of strm's & Google drive is eliminated?


RE: Potential Subtitle Handling Bug - SEIKT - 2021-12-03

I experimented with a local file using this code.
 
Code:
import sys
import glob
import xbmcgui
import xbmcplugin


filePath = xbmc.getInfoLabel("ListItem.FileNameAndPath")
subtitles = glob.glob(glob.escape(filePath.replace(".strm", "")) + "*srt")
xbmc.log("the subtitles are " + str(subtitles), xbmc.LOGERROR)

filePath = filePath.replace(".strm", ".mp4")
item = xbmcgui.ListItem(path=filePath)
item.setSubtitles(subtitles)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)


Subtitles don't appear in the selection. But it seems they were correctly identified as English at one stage according to the log.

https://paste.kodi.tv/dadaxukivi.kodi


RE: Potential Subtitle Handling Bug - SEIKT - 2021-12-03

I omitted the setSubtitles function, subtitles are still detected. I think the ScanForExternalSubtitles call is what is identifying the correct subtitle language.
 
Code:
import sys
import glob
import xbmcgui
import xbmcplugin


filePath = xbmc.getInfoLabel("ListItem.FileNameAndPath")
filePath = filePath.replace(".strm", ".mp4")
item = xbmcgui.ListItem(path=filePath)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)

https://paste.kodi.tv/axusinomap.kodi


RE: Potential Subtitle Handling Bug - SEIKT - 2021-12-03

Here's code you can try yourself.
 
Code:
import sys
import xbmcgui
import xbmcplugin


item = xbmcgui.ListItem(path="https://media.istockphoto.com/videos/old-ghetto-wires-4k-video-id1295601772")
item.setSubtitles(["C:\\Users\\Jay\\Documents\\strm\\movies\\Back to the Future Part III (1990).eng.srt"])
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)

ScanForExternalSubtitles doesn't get called when the path isn't to a local file. Something strange behind the scenes is going on with setSubtitles.

https://paste.kodi.tv/uvilefesas.kodi


RE: Potential Subtitle Handling Bug - matthuisman - 2021-12-03

Maybe the Kodi code just needs to scan the filename backwards when looking for language as set subtitle wouldn't know the movie name to remove from the subtitle name.b


RE: Potential Subtitle Handling Bug - Karellen - 2021-12-03

@CastagnaIT ^^


RE: Potential Subtitle Handling Bug - scott967 - 2021-12-04

The only thing I can see is in the original log, the filename of the sub seems to be correct based on
cpp:
CLog::Log(LOGDEBUG, "%s - Language = '%s' / Name = '%s' / Flag = '%u' from %s",
             __FUNCTION__, info.language.c_str(), info.name.c_str(), info.flag, CURL::GetRedacted(associatedFile).c_str());

results in
Code:
 CUtil::GetExternalStreamDetailsFromFilename - Language = 'nor' / Name = 'Time to Die (2021) eng (External)' / Flag = '0' from C:\Users\Jay\Documents\strm\movies\No Time to Die (2021).eng.srt

Which tells me that the movie name passed into the function isn't matching for some reason.  The thing that popped into my head was a problem of homoglyph, or something like Turkish I/i casing problem but that doesn't seem likely here.

scott s.
.