Check if file name matches a language name (e.g. English.srt)

This commit is contained in:
Reinhard Pointner 2016-09-08 16:27:45 +08:00
parent 81d9b6a2f6
commit 0472084dc7
2 changed files with 11 additions and 1 deletions

View File

@ -120,8 +120,12 @@ public class ReleaseInfo {
if (languageTag == null) {
languageTag = getSubtitleLanguageTagPattern(getDefaultLanguageMap().keySet());
}
String lang = matchLast(languageTag, null, name);
return lang == null ? null : getDefaultLanguageMap().get(lang);
if (lang != null) {
return getDefaultLanguageMap().get(lang);
}
return null;
}
private Pattern categoryTag;

View File

@ -444,6 +444,12 @@ public final class SubtitleUtilities {
return Language.getLanguage(languageTag);
}
// check if file name matches a language name (e.g. English.srt)
Language languageName = Language.findLanguage(getName(file));
if (languageName != null) {
return languageName;
}
// detect language from subtitle text content
MemoryFile data = new MemoryFile(file.getName(), ByteBuffer.wrap(readFile(file)));
List<DetectedLanguage> options = detectSubtitleLanguage(data);