* only allow movies, no osts, specials, episodes, etc
This commit is contained in:
parent
8a0e7e5fdd
commit
b228f44ea0
|
@ -71,7 +71,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
|
|||
movie = grabMovieName(movieFiles[i], locale, autodetect, movie);
|
||||
|
||||
if (movie != null) {
|
||||
Analytics.trackEvent(service.getName(), "SearchMovie", movie.getName(), 1);
|
||||
Analytics.trackEvent(service.getName(), "SearchMovie", movie.toString(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,17 +131,22 @@ public class OpenSubtitlesXmlRpc {
|
|||
Pattern pattern = Pattern.compile("(.+)[(](\\d{4})([/]I+)?[)]");
|
||||
|
||||
for (Map<String, String> movie : movieData) {
|
||||
// match movie name and movie year from search result
|
||||
Matcher matcher = pattern.matcher(movie.get("title"));
|
||||
|
||||
if (matcher.find()) {
|
||||
try {
|
||||
String imdbid = movie.get("id");
|
||||
if (!imdbid.matches("\\d{1,7}"))
|
||||
throw new IllegalArgumentException("Illegal IMDbID");
|
||||
|
||||
// match movie name and movie year from search result
|
||||
Matcher matcher = pattern.matcher(movie.get("title"));
|
||||
if (!matcher.find())
|
||||
throw new IllegalArgumentException("Illegal title");
|
||||
|
||||
String name = matcher.group(1).trim();
|
||||
int year = Integer.parseInt(matcher.group(2));
|
||||
int imdbid = Integer.parseInt(movie.get("id"));
|
||||
|
||||
movies.add(new Movie(name, year, imdbid));
|
||||
} else {
|
||||
Logger.getLogger(OpenSubtitlesXmlRpc.class.getName()).log(Level.WARNING, "Error parsing title: " + movie);
|
||||
movies.add(new Movie(name, year, Integer.parseInt(imdbid)));
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(OpenSubtitlesXmlRpc.class.getName()).log(Level.WARNING, String.format("Ignore movie %s: %s", movie, e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,15 @@ public class OpenSubtitlesXmlRpcTest {
|
|||
}
|
||||
|
||||
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void searchOST() throws Exception {
|
||||
List<Movie> list = xmlrpc.searchMoviesOnIMDB("Linkin.Park.New.Divide.1280-720p.Transformers.Revenge.of.the.Fallen.ost");
|
||||
|
||||
// seek to OST entry, expect to fail
|
||||
for (int i = 0; !list.get(i).getName().contains("Linkin.Park"); i++);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getSubtitleListEnglish() throws Exception {
|
||||
List<OpenSubtitlesSubtitleDescriptor> list = xmlrpc.searchSubtitles(361256, "eng");
|
||||
|
|
Loading…
Reference in New Issue