From 5feaffb7c603975cb8fc755ca0d6de4c5042e8cc Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 4 Dec 2009 00:24:35 +0000 Subject: [PATCH] * adapt to site changes --- source/net/sourceforge/filebot/web/AnidbClient.java | 7 ++++++- source/net/sourceforge/filebot/web/WebRequest.java | 6 +++--- test/net/sourceforge/filebot/web/IMDbClientTest.java | 2 +- .../filebot/web/SubsceneSubtitleClientTest.java | 4 ++-- test/net/sourceforge/filebot/web/TMDbClientTest.java | 8 ++++---- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/source/net/sourceforge/filebot/web/AnidbClient.java b/source/net/sourceforge/filebot/web/AnidbClient.java index 73aff807..5e0fc1ac 100644 --- a/source/net/sourceforge/filebot/web/AnidbClient.java +++ b/source/net/sourceforge/filebot/web/AnidbClient.java @@ -11,6 +11,7 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.net.URLConnection; import java.util.AbstractList; import java.util.ArrayList; import java.util.Arrays; @@ -127,8 +128,12 @@ public class AnidbClient implements EpisodeListProvider { // ignore } + // set request headers to resemble an ajax request + URLConnection connection = url.openConnection(); + connection.setRequestProperty("X-LControl", "x-no-cache"); + // get anime page as xml - Document dom = getDocument(url); + Document dom = getDocument(connection); // select main title String animeTitle = selectString("//title[@type='main']", dom); diff --git a/source/net/sourceforge/filebot/web/WebRequest.java b/source/net/sourceforge/filebot/web/WebRequest.java index 06feae44..39a744a1 100644 --- a/source/net/sourceforge/filebot/web/WebRequest.java +++ b/source/net/sourceforge/filebot/web/WebRequest.java @@ -76,12 +76,12 @@ public final class WebRequest { public static Document getDocument(URL url) throws IOException, SAXException { - return getDocument(new InputSource(getReader(url.openConnection()))); + return getDocument(url.openConnection()); } - public static Document getDocument(InputStream inputStream) throws SAXException, IOException, ParserConfigurationException { - return getDocument(new InputSource(inputStream)); + public static Document getDocument(URLConnection connection) throws IOException, SAXException { + return getDocument(new InputSource(getReader(connection))); } diff --git a/test/net/sourceforge/filebot/web/IMDbClientTest.java b/test/net/sourceforge/filebot/web/IMDbClientTest.java index c6c28660..0b08d8e9 100644 --- a/test/net/sourceforge/filebot/web/IMDbClientTest.java +++ b/test/net/sourceforge/filebot/web/IMDbClientTest.java @@ -24,7 +24,7 @@ public class IMDbClientTest { assertEquals(2004, movie.getYear()); assertEquals(407362, movie.getImdbId(), 0); - assertEquals(6, results.size(), 0); + assertEquals(7, results.size(), 0); } diff --git a/test/net/sourceforge/filebot/web/SubsceneSubtitleClientTest.java b/test/net/sourceforge/filebot/web/SubsceneSubtitleClientTest.java index 8434d04e..b3aaf89b 100644 --- a/test/net/sourceforge/filebot/web/SubsceneSubtitleClientTest.java +++ b/test/net/sourceforge/filebot/web/SubsceneSubtitleClientTest.java @@ -50,11 +50,11 @@ public class SubsceneSubtitleClientTest { public void searchResultPageRedirect() throws Exception { List results = subscene.search("firefly"); - assertEquals(1, results.size()); + assertEquals(2, results.size()); HyperLink result = (HyperLink) results.get(0); - assertEquals("Firefly - The Complete Series", result.getName()); + assertEquals("Firefly - The Complete Series (2002)", result.getName()); assertEquals("http://subscene.com/Firefly-The-Complete-Series/subtitles-20008.aspx", result.getURL().toString()); } diff --git a/test/net/sourceforge/filebot/web/TMDbClientTest.java b/test/net/sourceforge/filebot/web/TMDbClientTest.java index 6530eb49..96dacc4e 100644 --- a/test/net/sourceforge/filebot/web/TMDbClientTest.java +++ b/test/net/sourceforge/filebot/web/TMDbClientTest.java @@ -28,12 +28,12 @@ public class TMDbClientTest { @Test public void searchByHash() throws Exception { - List results = tmdb.getMovies("Hash.getInfo", "d7aa0275cace4410"); + List results = tmdb.getMovies("Hash.getInfo", "2bba5c34b007153b"); MovieDescriptor movie = results.get(0); - assertEquals("Iron Man", movie.getName()); - assertEquals(2008, movie.getYear()); - assertEquals(371746, movie.getImdbId()); + assertEquals("Season 1", movie.getName()); + assertEquals(2002, movie.getYear()); + assertEquals(303461, movie.getImdbId()); }