* always use main title in anidb scraper again, because the official English title doesn't meet most peoples expectations in many cases

This commit is contained in:
Reinhard Pointner 2009-06-27 12:03:48 +00:00
parent 98ddfafe43
commit 5a2d1459f2
2 changed files with 17 additions and 21 deletions

View File

@ -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*", "");
}

View File

@ -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<SearchResult> 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"));
}