I added method to convert language string (being 2char code "en", 3char code "eng" or full language name "english") to 2char code: pieh@4b9cc5d
And helper method to extract language and name from filename: pieh@5789502
What I do there is specify few regexpes to match lang and name and try to pick up best from all matches. Fact that we know if string that is recognized as lang part is actual language (testing if we can convert it to 2char code) makes this pretty accurate. Builtin regexpes would propably need more love - not regexp wizard here.
I think that I could also add either white list for stream names (f.e. "Directors Commentary" as white list entry) to further increase accuracy of matches. Regexpes and white list name entries would be adjustable via advancedsettings.xml.
Added infolabel is on pike's request.
Here's example of how lang/name extraction is currently performing using my test case:
Util::ScanForExternalSubtitles: Searching for subtitles...
CUtil::ScanForExternalSubtitles: found subtitle file smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.Closed-caption.txt
CUtil::ScanForExternalSubtitles: found subtitle file smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.directors-comments-en.txt
CUtil::ScanForExternalSubtitles: found subtitle file smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.en.name_stuff.txt
CUtil::ScanForExternalSubtitles: found subtitle file smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.it.txt
CUtil::ScanForExternalSubtitles: found subtitle file smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.some_name.txt
CUtil::ScanForExternalSubtitles: found subtitle file smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.Spanish.txt
CUtil::ScanForExternalSubtitles: found subtitle file smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.txt
CUtil::ScanForExternalSubtitles: END (total time: 18 ms)
CUtil::GetExternalStreamNameAndLangFromFilename - Language = 'cc' / Name = 'Closed Caption' from smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.Closed-caption.txt
CUtil::GetExternalStreamNameAndLangFromFilename - Language = 'en' / Name = 'directors-comments' from smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.directors-comments-en.txt
CUtil::GetExternalStreamNameAndLangFromFilename - Language = 'en' / Name = 'name_stuff' from smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.en.name_stuff.txt
CUtil::GetExternalStreamNameAndLangFromFilename - Language = 'it' / Name = 'Italiano' from smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.it.txt
CUtil::GetExternalStreamNameAndLangFromFilename - Language = '' / Name = 'some_name' from smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.some_name.txt
CUtil::GetExternalStreamNameAndLangFromFilename - Language = 'es' / Name = 'Espanol' from smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.Spanish.txt
CUtil::GetExternalStreamNameAndLangFromFilename - Language = '' / Name = 'The.Dummy.Video.720p.X264.txt' from smb://KOMPUS/Videos/Dummy/The.Dummy.Video.720p.X264.txt
add subtitles extension list and allow to remove it using URIUtils::R…
add method converting language string to 2char code
passed language string could be either other code or full language name
add CUtil::GetExternalStreamNameAndLangFromFilename method to extract…
… stream language and name from filename
use CUtil::GetExternalStreamNameAndLangFromFilename to determine exte…
…rnal subtitles's language and name
dvdplayer: update current video settings when changing setting subtit…
…les stream to be sure we keep it synced (similiar to what we already do when we show/hide subtitles)
add VideoPlayer.SubtitlesLanguage infolabel that returns full languag…
…e name of current subtitles, "unknown" localized string or empty string if subtitles are disabled or video isn't playing currently
If i see it right it "only" provides the language as a guilabel. So worst thing that could happen when something is wrong here is that it dosn't show the right label for the subtitle right?
Didn't review the whole regexp stuff and so on, but in general it looks good to me.
It wouln't act as infolabel only - determined language could be used to select external subtitles with prefered subtitles language feature. I didn't test yet if that actually work (but assuming that we add external subtitles before we select prefered subtitles it should work out of the box as we use stream language there). Was hoping to get some feedback about language/name extraction approach before i do more work on it.
Is there any progress on this? Will it be merged into Frodo Final?
We are in feature freeze, this certainly won't be merged before Frodo Final. There wasn't any progress on this since I opened PR, there is still TO-DO entry to code.
@pieh - you think you find some time to prepare this for the upcoming merge window? And could changes in this PR probably be used to fix audio and subtitle selection for blurays @Montellese ? This is currently not working.
I will try to do some work on it, but can't promise anything ... Not sure if this has anything in common with bluray subtitles/audio (this PR will only try to extract language from external subtitle filename, I don't think bluray keep subtitles/audio tracks in seperate files?)
@pieh I talked with @Montellese about it in IRC a couple days ago and without looking at the reason for the bug in detail he said he could imagine that blurays use different language strings/labels and that this might be the reason for the auto-selection he implemented to fail. So with your CLangCodeExpander::ConvertToTwoCharCode this issue probably could be fixed (if it's the actual cause). That's why I pinged Montellese.
The priority selection gets skipped for dvds (not sure about blurays).
The relevant piece of code is:
void CDVDPlayer::OpenDefaultStreams(bool reset)
// bypass for DVDs. The DVD Navigator has already dictated which streams to open.
Question for 13-gotham: with this, external subtitles will be considered a new stream? Will the video database have a new column to indicate that a movie/tv-show has a external subtitle? If so, skins can offer image labels and or filter to movies/tv-show that has subtitles.
@pieh any news about this? Since blacks Video language script (http://forum.xbmc.org/showthread.php?tid=155693) gets include into skins, ext. subs language might rise on the wanted list. I've opened a pr to your repo some time ago proposing to store the info in the db. with that blacks script should work out of the box.
What's the status on this?