mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 08:18:52 -05:00
* provide link in OpenSubtitlesClient
* refactoring
This commit is contained in:
parent
c9bc001a9c
commit
d0faaad55a
@ -105,24 +105,21 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
||||
String text = searchTextField.getText().trim();
|
||||
Language language = languageModel.getSelectedItem();
|
||||
|
||||
// null or proper language name
|
||||
String languageName = (language == ALL_LANGUAGES ? null : language.getName());
|
||||
|
||||
return new SubtitleRequestProcessor(new SubtitleRequest(provider, text, languageName));
|
||||
return new SubtitleRequestProcessor(new SubtitleRequest(provider, text, language));
|
||||
}
|
||||
|
||||
|
||||
protected static class SubtitleRequest extends Request {
|
||||
|
||||
private final SubtitleProvider provider;
|
||||
private final String languageName;
|
||||
private final Language language;
|
||||
|
||||
|
||||
public SubtitleRequest(SubtitleProvider provider, String searchText, String languageName) {
|
||||
public SubtitleRequest(SubtitleProvider provider, String searchText, Language language) {
|
||||
super(searchText);
|
||||
|
||||
this.provider = provider;
|
||||
this.languageName = languageName;
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +129,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
||||
|
||||
|
||||
public String getLanguageName() {
|
||||
return languageName;
|
||||
return language == ALL_LANGUAGES ? null : language.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,8 +71,18 @@ public class OpenSubtitlesClient implements SubtitleProvider {
|
||||
|
||||
@Override
|
||||
public URI getSubtitleListLink(SearchResult searchResult, String languageName) {
|
||||
//TODO provide link
|
||||
return null;
|
||||
MovieDescriptor movie = (MovieDescriptor) searchResult;
|
||||
String sublanguageid = "all";
|
||||
|
||||
if (languageName != null) {
|
||||
try {
|
||||
sublanguageid = getSubLanguageID(languageName);
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return URI.create(String.format("http://www.opensubtitles.org/en/search/imdbid-%d/sublanguageid-%s", movie.getImdbId(), sublanguageid));
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,6 +11,7 @@ import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import net.sourceforge.tuned.ByteBufferOutputStream;
|
||||
import net.sourceforge.tuned.FileUtilities;
|
||||
|
||||
|
||||
/**
|
||||
@ -85,7 +86,7 @@ public class OpenSubtitlesSubtitleDescriptor implements SubtitleDescriptor {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getProperty(Property.MovieReleaseName);
|
||||
return FileUtilities.getNameWithoutExtension(getProperty(Property.SubFileName));
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,8 +141,7 @@ public class OpenSubtitlesXmlRpc {
|
||||
subtitles.add(new OpenSubtitlesSubtitleDescriptor(Property.asEnumMap(subtitleData)));
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
// if the response is an error message, generic types won't match
|
||||
throw new XmlRpcException("Illegal response: " + response.toString());
|
||||
// error response, no subtitles, ignore
|
||||
}
|
||||
|
||||
return subtitles;
|
||||
|
Loading…
Reference in New Issue
Block a user