mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-26 09:48:56 -05:00
* {lang} binding returns Language object now because Locale has compatibility issues with the various standards
This commit is contained in:
parent
b9f76c407c
commit
b2b0610579
@ -3,6 +3,7 @@ package net.sourceforge.filebot;
|
|||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.*;
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -10,7 +11,7 @@ import java.util.Locale;
|
|||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Language {
|
public class Language implements Serializable {
|
||||||
|
|
||||||
private final String iso2;
|
private final String iso2;
|
||||||
private final String iso3;
|
private final String iso3;
|
||||||
@ -40,10 +41,10 @@ public class Language {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return iso3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale toLocale() {
|
public Locale getLocale() {
|
||||||
return new Locale(getCode());
|
return new Locale(getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,15 +87,15 @@ public class Language {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Language getLanguage(Locale locale) {
|
public static Language getLanguage(Locale locale) {
|
||||||
if (locale == null)
|
if (locale != null) {
|
||||||
return null;
|
|
||||||
|
|
||||||
String code = locale.getLanguage();
|
String code = locale.getLanguage();
|
||||||
for (Language it : availableLanguages()) {
|
for (Language it : availableLanguages()) {
|
||||||
if (it.getISO2().equals(code) || it.getISO3().equals(code)) {
|
if (it.getISO2().equals(code) || it.getISO3().equals(code)) {
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new Language(code, locale.getISO3Language(), locale.getDisplayName(Locale.ENGLISH));
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
ExpressionFormat format = (formatExpression != null) ? new ExpressionFormat(formatExpression) : null;
|
ExpressionFormat format = (formatExpression != null) ? new ExpressionFormat(formatExpression) : null;
|
||||||
ExpressionFilter filter = (filterExpression != null) ? new ExpressionFilter(filterExpression) : null;
|
ExpressionFilter filter = (filterExpression != null) ? new ExpressionFilter(filterExpression) : null;
|
||||||
File outputDir = (output != null && output.length() > 0) ? new File(output).getAbsoluteFile() : null;
|
File outputDir = (output != null && output.length() > 0) ? new File(output).getAbsoluteFile() : null;
|
||||||
Locale locale = getLanguage(lang).toLocale();
|
Locale locale = getLanguage(lang).getLocale();
|
||||||
ConflictAction conflictAction = ConflictAction.forName(conflict);
|
ConflictAction conflictAction = ConflictAction.forName(conflict);
|
||||||
|
|
||||||
if (getEpisodeListProvider(db) != null) {
|
if (getEpisodeListProvider(db) != null) {
|
||||||
@ -683,12 +683,12 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
if (query == null) {
|
if (query == null) {
|
||||||
try {
|
try {
|
||||||
List<File> videoFiles = filter(files, VIDEO_FILES);
|
List<File> videoFiles = filter(files, VIDEO_FILES);
|
||||||
querySet.addAll(detectSeriesNames(videoFiles, language.toLocale()));
|
querySet.addAll(detectSeriesNames(videoFiles, language.getLocale()));
|
||||||
|
|
||||||
// auto-detect movie names
|
// auto-detect movie names
|
||||||
for (File f : videoFiles) {
|
for (File f : videoFiles) {
|
||||||
if (!isEpisode(f.getName(), false)) {
|
if (!isEpisode(f.getName(), false)) {
|
||||||
for (Movie movie : detectMovie(f, null, null, language.toLocale(), strict)) {
|
for (Movie movie : detectMovie(f, null, null, language.getLocale(), strict)) {
|
||||||
querySet.add(movie.getName());
|
querySet.add(movie.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1039,7 +1039,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
|
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
|
||||||
EpisodeListProvider service = (db == null) ? TheTVDB : getEpisodeListProvider(db);
|
EpisodeListProvider service = (db == null) ? TheTVDB : getEpisodeListProvider(db);
|
||||||
SortOrder sortOrder = SortOrder.forName(sortOrderName);
|
SortOrder sortOrder = SortOrder.forName(sortOrderName);
|
||||||
Locale locale = getLanguage(languageName).toLocale();
|
Locale locale = getLanguage(languageName).getLocale();
|
||||||
|
|
||||||
SearchResult hit = selectSearchResult(query, service.search(query, locale), false).get(0);
|
SearchResult hit = selectSearchResult(query, service.search(query, locale), false).get(0);
|
||||||
List<String> episodes = new ArrayList<String>();
|
List<String> episodes = new ArrayList<String>();
|
||||||
|
@ -27,6 +27,7 @@ import java.util.SortedSet;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import net.sourceforge.filebot.Cache;
|
import net.sourceforge.filebot.Cache;
|
||||||
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.MediaTypes;
|
import net.sourceforge.filebot.MediaTypes;
|
||||||
import net.sourceforge.filebot.WebServices;
|
import net.sourceforge.filebot.WebServices;
|
||||||
import net.sourceforge.filebot.hash.HashType;
|
import net.sourceforge.filebot.hash.HashType;
|
||||||
@ -420,13 +421,13 @@ public class MediaBindingBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Define("lang")
|
@Define("lang")
|
||||||
public Locale detectSubtitleLanguage() throws Exception {
|
public Language detectSubtitleLanguage() throws Exception {
|
||||||
// make sure media file is defined
|
// make sure media file is defined
|
||||||
checkMediaFile();
|
checkMediaFile();
|
||||||
|
|
||||||
Locale languageSuffix = releaseInfo.getLanguageSuffix(FileUtilities.getName(mediaFile));
|
Locale languageSuffix = releaseInfo.getLanguageSuffix(FileUtilities.getName(mediaFile));
|
||||||
if (languageSuffix != null)
|
if (languageSuffix != null)
|
||||||
return languageSuffix;
|
return Language.getLanguage(languageSuffix);
|
||||||
|
|
||||||
// require subtitle file
|
// require subtitle file
|
||||||
if (!SUBTITLE_FILES.accept(mediaFile)) {
|
if (!SUBTITLE_FILES.accept(mediaFile)) {
|
||||||
@ -445,7 +446,7 @@ public class MediaBindingBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try statistical language detection
|
// try statistical language detection
|
||||||
return WebServices.OpenSubtitles.detectLanguage(readFile(mediaFile));
|
return Language.getLanguage(WebServices.OpenSubtitles.detectLanguage(readFile(mediaFile)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Define("actors")
|
@Define("actors")
|
||||||
|
@ -98,7 +98,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
|
|||||||
String text = searchTextField.getText().trim();
|
String text = searchTextField.getText().trim();
|
||||||
int season = seasonSpinnerModel.getSeason();
|
int season = seasonSpinnerModel.getSeason();
|
||||||
SortOrder order = (SortOrder) sortOrderComboBox.getSelectedItem();
|
SortOrder order = (SortOrder) sortOrderComboBox.getSelectedItem();
|
||||||
Locale language = languageComboBox.getModel().getSelectedItem().toLocale();
|
Locale language = languageComboBox.getModel().getSelectedItem().getLocale();
|
||||||
|
|
||||||
return new EpisodeListRequestProcessor(new EpisodeListRequest(provider, text, season, order, language));
|
return new EpisodeListRequestProcessor(new EpisodeListRequest(provider, text, season, order, language));
|
||||||
};
|
};
|
||||||
|
@ -708,7 +708,7 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
try {
|
try {
|
||||||
mapping.setState(SubtitleMapping.Status.Uploading);
|
mapping.setState(SubtitleMapping.Status.Uploading);
|
||||||
|
|
||||||
database.uploadSubtitle(mapping.getIdentity(), mapping.getLanguage().toLocale(), mapping.getVideo(), mapping.getSubtitle());
|
database.uploadSubtitle(mapping.getIdentity(), mapping.getLanguage().getLocale(), mapping.getVideo(), mapping.getSubtitle());
|
||||||
mapping.setState(SubtitleMapping.Status.UploadComplete);
|
mapping.setState(SubtitleMapping.Status.UploadComplete);
|
||||||
|
|
||||||
Analytics.trackEvent(database.getName(), "UploadSubtitle", mapping.getLanguage().getName(), 1);
|
Analytics.trackEvent(database.getName(), "UploadSubtitle", mapping.getLanguage().getName(), 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user