xbmc/xbmc — pull request #1365 by pieh (2012-09-04 10:03:30+00:00)
Title: Add subtitles language and name extraction from filename and VideoPlayer.SubtitlesLanguage infolabel

I added method to convert language string (being 2char code "en", 3char code "eng" or full language name "english") to 2char code: https://github.com/pieh/xbmc/commit/4b9cc5daded526d70ec2def1fae4aeedb83bb65f

And helper method to extract language and name from filename: https://github.com/pieh/xbmc/commit/5789502a521d6bfee6897926fb7f7fe9c6ce0a86
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.

TO-DO?
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
```