1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-17 23:05:03 -05:00

* save subtitle with ISO3 language code

This commit is contained in:
Reinhard Pointner 2011-11-24 17:52:11 +00:00
parent 8571962e61
commit 116262fbea
3 changed files with 19 additions and 14 deletions

View File

@ -403,7 +403,7 @@ public class CmdlineOperations implements CmdlineInterface {
try {
collector.addAll(service.getName(), lookupSubtitleByFileName(service, querySet, language, collector.remainingVideos()));
} catch (RuntimeException e) {
CLILogger.warning(format("Search for [%s] failed: %s", query, e.getMessage()));
CLILogger.warning(format("Search for [%s] failed: %s", querySet, e.getMessage()));
}
}
}
@ -464,6 +464,7 @@ public class CmdlineOperations implements CmdlineInterface {
// subtitle filename is based on movie filename
String name = getName(movieFile);
String lang = Language.getISO3LanguageCodeByName(descriptor.getLanguageName());
String ext = getExtension(subtitleFile.getName());
ByteBuffer data = subtitleFile.getData();
@ -476,7 +477,7 @@ public class CmdlineOperations implements CmdlineInterface {
data = exportSubtitles(subtitleFile, outputFormat, 0, outputEncoding);
}
File destination = new File(movieFile.getParentFile(), name + "." + ext);
File destination = new File(movieFile.getParentFile(), String.format("%s.%s.%s", name, lang, ext));
CLILogger.config(format("Writing [%s] to [%s]", subtitleFile.getName(), destination.getName()));
writeFile(data, destination);

View File

@ -93,6 +93,21 @@ public class Language {
}
public static String getISO3LanguageCodeByName(String languageName) {
Language language = Language.getLanguageByName(languageName);
if (language != null) {
try {
return new Locale(language.getCode()).getISO3Language();
} catch (Exception e) {
return language.getCode();
}
}
// we won't get here, but just in case
return languageName.replaceAll("\\W", "");
}
public static List<Language> availableLanguages() {
ResourceBundle bundle = ResourceBundle.getBundle(Language.class.getName());
return getLanguages(bundle.getString("languages.all").split(","));

View File

@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ExecutorService;
@ -614,17 +613,7 @@ class VideoHashSubtitleDownloadDialog extends JDialog {
public String getLanguage() {
Language language = Language.getLanguageByName(subtitle.getLanguageName());
if (language != null) {
try {
return new Locale(language.getCode()).getISO3Language();
} catch (Exception e) {
return language.getCode();
}
}
// we won't get here, but just in case
return subtitle.getLanguageName().replaceAll("\\W", "");
return Language.getISO3LanguageCodeByName(subtitle.getLanguageName());
}