* save subtitle with ISO3 language code
This commit is contained in:
parent
8571962e61
commit
116262fbea
|
@ -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);
|
||||
|
|
|
@ -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(","));
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue