From 5fef14bedd01b3bcfbc3d8859fe0e77a3bab094a Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 13 Jan 2013 03:15:05 +0000 Subject: [PATCH] * fix imdb scraper issues --- source/net/sourceforge/filebot/web/IMDbClient.java | 2 +- test/net/sourceforge/filebot/web/IMDbClientTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/net/sourceforge/filebot/web/IMDbClient.java b/source/net/sourceforge/filebot/web/IMDbClient.java index e3b7d3b0..b6cbb1bf 100644 --- a/source/net/sourceforge/filebot/web/IMDbClient.java +++ b/source/net/sourceforge/filebot/web/IMDbClient.java @@ -85,7 +85,7 @@ public class IMDbClient implements MovieIdentificationService { if (name.startsWith("\"")) continue; - String year = node.getNextSibling().getTextContent().replaceAll("[\\p{Punct}\\p{Space}]+", ""); // remove non-number characters + String year = node.getNextSibling().getTextContent().trim().replaceFirst("^\\(I\\)", "").replaceAll("[\\p{Punct}\\p{Space}]+", ""); // remove non-number characters String href = getAttribute("href", node); results.add(new Movie(name, Integer.parseInt(year), getImdbId(href), -1)); diff --git a/test/net/sourceforge/filebot/web/IMDbClientTest.java b/test/net/sourceforge/filebot/web/IMDbClientTest.java index 739d6d55..e0be9188 100644 --- a/test/net/sourceforge/filebot/web/IMDbClientTest.java +++ b/test/net/sourceforge/filebot/web/IMDbClientTest.java @@ -70,6 +70,17 @@ public class IMDbClientTest { } + @Test + public void searchMovie6() throws Exception { + List results = imdb.searchMovie("Drive 2011", null); + Movie movie = results.get(0); + + assertEquals("Drive", movie.getName()); + assertEquals(2011, movie.getYear()); + assertEquals(780504, movie.getImdbId(), 0); + } + + @Test public void searchMovieRedirect() throws Exception { List results = imdb.searchMovie("(500) Days of Summer (2009)", null);