parent
c9bc001a9c
commit
d0faaad55a
|
@ -105,24 +105,21 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
||||||
String text = searchTextField.getText().trim();
|
String text = searchTextField.getText().trim();
|
||||||
Language language = languageModel.getSelectedItem();
|
Language language = languageModel.getSelectedItem();
|
||||||
|
|
||||||
// null or proper language name
|
return new SubtitleRequestProcessor(new SubtitleRequest(provider, text, language));
|
||||||
String languageName = (language == ALL_LANGUAGES ? null : language.getName());
|
|
||||||
|
|
||||||
return new SubtitleRequestProcessor(new SubtitleRequest(provider, text, languageName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static class SubtitleRequest extends Request {
|
protected static class SubtitleRequest extends Request {
|
||||||
|
|
||||||
private final SubtitleProvider provider;
|
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);
|
super(searchText);
|
||||||
|
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.languageName = languageName;
|
this.language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,7 +129,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
||||||
|
|
||||||
|
|
||||||
public String getLanguageName() {
|
public String getLanguageName() {
|
||||||
return languageName;
|
return language == ALL_LANGUAGES ? null : language.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,18 @@ public class OpenSubtitlesClient implements SubtitleProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getSubtitleListLink(SearchResult searchResult, String languageName) {
|
public URI getSubtitleListLink(SearchResult searchResult, String languageName) {
|
||||||
//TODO provide link
|
MovieDescriptor movie = (MovieDescriptor) searchResult;
|
||||||
return null;
|
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 java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import net.sourceforge.tuned.ByteBufferOutputStream;
|
import net.sourceforge.tuned.ByteBufferOutputStream;
|
||||||
|
import net.sourceforge.tuned.FileUtilities;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,7 +86,7 @@ public class OpenSubtitlesSubtitleDescriptor implements SubtitleDescriptor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
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)));
|
subtitles.add(new OpenSubtitlesSubtitleDescriptor(Property.asEnumMap(subtitleData)));
|
||||||
}
|
}
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
// if the response is an error message, generic types won't match
|
// error response, no subtitles, ignore
|
||||||
throw new XmlRpcException("Illegal response: " + response.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return subtitles;
|
return subtitles;
|
||||||
|
|
Loading…
Reference in New Issue