1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 08:48:51 -05:00

* update & enable OpenSubtitles GuessMovie RPC method again

This commit is contained in:
Reinhard Pointner 2015-11-06 19:44:55 +00:00
parent e80c9d855a
commit 4a95aaf029
2 changed files with 19 additions and 26 deletions

View File

@ -94,21 +94,18 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
@Override @Override
public List<SubtitleSearchResult> guess(String tag) throws Exception { public List<SubtitleSearchResult> guess(String tag) throws Exception {
// !!! XML-RPC CURRENTLY METHOD BROKEN !!! List<SubtitleSearchResult> subtitles = getCache().getSearchResult("guess", tag);
return emptyList(); if (subtitles != null) {
return subtitles;
}
// List<SubtitleSearchResult> subtitles = getCache().getSearchResult("guess", tag); // require login
// if (subtitles != null) { login();
// return subtitles;
// } subtitles = xmlrpc.guessMovie(singleton(tag)).getOrDefault(tag, emptyList());
//
// // require login getCache().putSearchResult("guess", tag, subtitles);
// login(); return subtitles;
//
// subtitles = xmlrpc.guessMovie(singleton(tag)).getOrDefault(tag, emptyList());
//
// getCache().putSearchResult("guess", tag, subtitles);
// return subtitles;
} }
@Override @Override

View File

@ -233,31 +233,27 @@ public class OpenSubtitlesXmlRpc {
return subHashMap; return subHashMap;
} }
@Deprecated
public Map<String, List<SubtitleSearchResult>> guessMovie(Collection<String> tags) throws XmlRpcFault { public Map<String, List<SubtitleSearchResult>> guessMovie(Collection<String> tags) throws XmlRpcFault {
Map<String, List<SubtitleSearchResult>> results = new HashMap<String, List<SubtitleSearchResult>>(); Map<String, List<SubtitleSearchResult>> results = new HashMap<String, List<SubtitleSearchResult>>();
Map<?, ?> response = invoke("GuessMovie", token, tags); Map<?, ?> response = invoke("GuessMovieFromString", token, tags);
Object payload = response.get("data"); Object payload = response.get("data");
if (payload instanceof Map) { if (payload instanceof Map) {
Map<String, List<Map<String, ?>>> guessMovieData = (Map<String, List<Map<String, ?>>>) payload; Map<String, Map<String, Map<String, ?>>> dataByTag = (Map<String, Map<String, Map<String, ?>>>) payload;
for (String tag : tags) { for (String tag : tags) {
List<SubtitleSearchResult> value = new ArrayList<>(); List<SubtitleSearchResult> value = new ArrayList<SubtitleSearchResult>();
Map<String, Map<String, ?>> data = dataByTag.get(tag);
List<Map<String, ?>> matches = guessMovieData.get(tag); if (data != null) {
if (matches != null) { Map<String, ?> match = data.get("BestGuess");
for (Map<String, ?> match : matches) { if (match != null) {
String name = String.valueOf(match.get("MovieName")); String name = String.valueOf(match.get("MovieName"));
String kind = String.valueOf(match.get("MovieKind")); String kind = String.valueOf(match.get("MovieKind"));
int imdbid = Integer.parseInt(String.valueOf(match.get("IDMovieIMDB"))); int imdbid = Integer.parseInt(String.valueOf(match.get("IDMovieIMDB")));
int year = Integer.parseInt(String.valueOf(match.get("MovieYear"))); int year = Integer.parseInt(String.valueOf(match.get("MovieYear")));
int score = Integer.parseInt(String.valueOf(match.get("score"))); value.add(new SubtitleSearchResult(imdbid, name, year, kind, -1));
value.add(new SubtitleSearchResult(imdbid, name, year, kind, score));
} }
} }
results.put(tag, value); results.put(tag, value);
} }
} }