From 57df9b1fbced95103cfc791cd55331f0e6dabc12 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 25 Jul 2009 13:36:29 +0000 Subject: [PATCH] * adapt tv.com scraper to site changes --- source/net/sourceforge/filebot/web/TVDotComClient.java | 8 +++----- test/net/sourceforge/filebot/web/TVDotComClientTest.java | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/source/net/sourceforge/filebot/web/TVDotComClient.java b/source/net/sourceforge/filebot/web/TVDotComClient.java index aa6d0899..e92b17e1 100644 --- a/source/net/sourceforge/filebot/web/TVDotComClient.java +++ b/source/net/sourceforge/filebot/web/TVDotComClient.java @@ -62,16 +62,14 @@ public class TVDotComClient implements EpisodeListProvider { Document dom = getHtmlDocument(searchUrl); - List nodes = selectNodes("//*[@class='title']//descendant-or-self::A", dom); + List searchResults = new ArrayList(); - List searchResults = new ArrayList(nodes.size()); - - for (Node node : nodes) { + for (Node node : selectNodes("//H2/A", dom)) { String title = getTextContent(node); String href = getAttribute("href", node); try { - URL episodeGuideLocation = new URL(href.replaceAll("summary\\.html\\?.*", "episode.html")); + URL episodeGuideLocation = new URL(href.replaceAll("summary[.]html[?].*", "episode.html")); searchResults.add(new HyperLink(title, episodeGuideLocation)); } catch (MalformedURLException e) { Logger.getLogger(getClass().getName()).log(Level.WARNING, "Invalid href: " + href, e); diff --git a/test/net/sourceforge/filebot/web/TVDotComClientTest.java b/test/net/sourceforge/filebot/web/TVDotComClientTest.java index f444d042..68daee04 100644 --- a/test/net/sourceforge/filebot/web/TVDotComClientTest.java +++ b/test/net/sourceforge/filebot/web/TVDotComClientTest.java @@ -26,10 +26,10 @@ public class TVDotComClientTest { @Test public void search() throws Exception { - List results = tvdotcom.search("Buffy"); + List results = tvdotcom.search("buffy the vampire slayer"); // if this fails, there is probably a problem with the xpath query - assertEquals(10, results.size()); + assertEquals(4, results.size()); HyperLink result = (HyperLink) results.get(0);