* adapt to site changes

This commit is contained in:
Reinhard Pointner 2009-12-04 00:24:35 +00:00
parent 7a77530a06
commit 5feaffb7c6
5 changed files with 16 additions and 11 deletions

View File

@ -11,6 +11,7 @@ import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.util.AbstractList; import java.util.AbstractList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -127,8 +128,12 @@ public class AnidbClient implements EpisodeListProvider {
// ignore // 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 // get anime page as xml
Document dom = getDocument(url); Document dom = getDocument(connection);
// select main title // select main title
String animeTitle = selectString("//title[@type='main']", dom); String animeTitle = selectString("//title[@type='main']", dom);

View File

@ -76,12 +76,12 @@ public final class WebRequest {
public static Document getDocument(URL url) throws IOException, SAXException { 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 { public static Document getDocument(URLConnection connection) throws IOException, SAXException {
return getDocument(new InputSource(inputStream)); return getDocument(new InputSource(getReader(connection)));
} }

View File

@ -24,7 +24,7 @@ public class IMDbClientTest {
assertEquals(2004, movie.getYear()); assertEquals(2004, movie.getYear());
assertEquals(407362, movie.getImdbId(), 0); assertEquals(407362, movie.getImdbId(), 0);
assertEquals(6, results.size(), 0); assertEquals(7, results.size(), 0);
} }

View File

@ -50,11 +50,11 @@ public class SubsceneSubtitleClientTest {
public void searchResultPageRedirect() throws Exception { public void searchResultPageRedirect() throws Exception {
List<SearchResult> results = subscene.search("firefly"); List<SearchResult> results = subscene.search("firefly");
assertEquals(1, results.size()); assertEquals(2, results.size());
HyperLink result = (HyperLink) results.get(0); 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()); assertEquals("http://subscene.com/Firefly-The-Complete-Series/subtitles-20008.aspx", result.getURL().toString());
} }

View File

@ -28,12 +28,12 @@ public class TMDbClientTest {
@Test @Test
public void searchByHash() throws Exception { public void searchByHash() throws Exception {
List<MovieDescriptor> results = tmdb.getMovies("Hash.getInfo", "d7aa0275cace4410"); List<MovieDescriptor> results = tmdb.getMovies("Hash.getInfo", "2bba5c34b007153b");
MovieDescriptor movie = results.get(0); MovieDescriptor movie = results.get(0);
assertEquals("Iron Man", movie.getName()); assertEquals("Season 1", movie.getName());
assertEquals(2008, movie.getYear()); assertEquals(2002, movie.getYear());
assertEquals(371746, movie.getImdbId()); assertEquals(303461, movie.getImdbId());
} }