From 5a2d1459f2bb463f931a34f52fbc927f8c832502 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 27 Jun 2009 12:03:48 +0000 Subject: [PATCH] * always use main title in anidb scraper again, because the official English title doesn't meet most peoples expectations in many cases --- .../sourceforge/filebot/web/AnidbClient.java | 17 +++++---------- .../filebot/web/AnidbClientTest.java | 21 +++++++++++-------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/source/net/sourceforge/filebot/web/AnidbClient.java b/source/net/sourceforge/filebot/web/AnidbClient.java index c9d07b59..ae72f769 100644 --- a/source/net/sourceforge/filebot/web/AnidbClient.java +++ b/source/net/sourceforge/filebot/web/AnidbClient.java @@ -17,18 +17,18 @@ import java.util.logging.Logger; import javax.swing.Icon; -import net.sourceforge.filebot.ResourceManager; - import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.SAXException; +import net.sourceforge.filebot.ResourceManager; + public class AnidbClient implements EpisodeListProvider { private static final String host = "anidb.net"; - + @Override public String getName() { return "AniDB"; @@ -97,15 +97,8 @@ public class AnidbClient implements EpisodeListProvider { protected String selectTitle(Document animePage) { - // prefer official english title - String title = selectOfficialTitle(animePage, "english"); - - if (title.isEmpty()) { - // fallback: extract name from header (e.g. "Anime: Naruto") - title = selectString("//H1", animePage).replaceFirst("Anime:\\s*", "");; - } - - return title; + // extract name from header (e.g. "Anime: Naruto") + return selectString("//H1", animePage).replaceFirst("Anime:\\s*", ""); } diff --git a/test/net/sourceforge/filebot/web/AnidbClientTest.java b/test/net/sourceforge/filebot/web/AnidbClientTest.java index c8ad4141..65216cd3 100644 --- a/test/net/sourceforge/filebot/web/AnidbClientTest.java +++ b/test/net/sourceforge/filebot/web/AnidbClientTest.java @@ -24,16 +24,17 @@ public class AnidbClientTest { */ private static HyperLink twelvekingdomsSearchResult; - + @BeforeClass public static void setUpBeforeClass() throws Exception { monsterSearchResult = new HyperLink("Monster", new URL("http://anidb.net/perl-bin/animedb.pl?show=anime&aid=1539")); twelvekingdomsSearchResult = new HyperLink("Juuni Kokuki", new URL("http://anidb.net/a26")); } + private AnidbClient anidb = new AnidbClient(); - + @Test public void search() throws Exception { List results = anidb.search("one piece"); @@ -81,7 +82,7 @@ public class AnidbClientTest { HyperLink result = (HyperLink) results.get(0); - assertEquals("The Twelve Kingdoms", result.getName()); + assertEquals("Juuni Kokuki", result.getName()); assertEquals("http://anidb.net/a26", result.getURL().toString()); } @@ -109,7 +110,7 @@ public class AnidbClientTest { Episode first = list.get(0); - assertEquals("The Twelve Kingdoms", first.getSeriesName()); + assertEquals("Juuni Kokuki", first.getSeriesName()); assertEquals("Shadow of the Moon, The Sea of Shadow - Chapter 1", first.getTitle()); assertEquals("1", first.getEpisode()); assertEquals(null, first.getSeason()); @@ -124,11 +125,13 @@ public class AnidbClientTest { @Test public void selectTitle() throws Exception { - // use official english title - assertEquals("Banner of the Stars", anidb.selectTitle(getHtmlDocument(new URL("http://anidb.net/a4")))); - - // official english title not available -> use main title - assertEquals("Turn A Gundam", anidb.selectTitle(getHtmlDocument(new URL("http://anidb.net/a916")))); + assertEquals("Seikai no Senki", anidb.selectTitle(getHtmlDocument(new URL("http://anidb.net/a4")))); + } + + + @Test + public void selectEnglishTitle() throws Exception { + assertEquals("Banner of the Stars", anidb.selectOfficialTitle(getHtmlDocument(new URL("http://anidb.net/a4")), "English")); }