* 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:
parent
98ddfafe43
commit
5a2d1459f2
|
@ -17,12 +17,12 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
|
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
|
|
||||||
|
|
||||||
public class AnidbClient implements EpisodeListProvider {
|
public class AnidbClient implements EpisodeListProvider {
|
||||||
|
|
||||||
|
@ -97,15 +97,8 @@ public class AnidbClient implements EpisodeListProvider {
|
||||||
|
|
||||||
|
|
||||||
protected String selectTitle(Document animePage) {
|
protected String selectTitle(Document animePage) {
|
||||||
// prefer official english title
|
// extract name from header (e.g. "Anime: Naruto")
|
||||||
String title = selectOfficialTitle(animePage, "english");
|
return selectString("//H1", animePage).replaceFirst("Anime:\\s*", "");
|
||||||
|
|
||||||
if (title.isEmpty()) {
|
|
||||||
// fallback: extract name from header (e.g. "Anime: Naruto")
|
|
||||||
title = selectString("//H1", animePage).replaceFirst("Anime:\\s*", "");;
|
|
||||||
}
|
|
||||||
|
|
||||||
return title;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class AnidbClientTest {
|
||||||
twelvekingdomsSearchResult = new HyperLink("Juuni Kokuki", new URL("http://anidb.net/a26"));
|
twelvekingdomsSearchResult = new HyperLink("Juuni Kokuki", new URL("http://anidb.net/a26"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AnidbClient anidb = new AnidbClient();
|
private AnidbClient anidb = new AnidbClient();
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ public class AnidbClientTest {
|
||||||
|
|
||||||
HyperLink result = (HyperLink) results.get(0);
|
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());
|
assertEquals("http://anidb.net/a26", result.getURL().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ public class AnidbClientTest {
|
||||||
|
|
||||||
Episode first = list.get(0);
|
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("Shadow of the Moon, The Sea of Shadow - Chapter 1", first.getTitle());
|
||||||
assertEquals("1", first.getEpisode());
|
assertEquals("1", first.getEpisode());
|
||||||
assertEquals(null, first.getSeason());
|
assertEquals(null, first.getSeason());
|
||||||
|
@ -124,11 +125,13 @@ public class AnidbClientTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectTitle() throws Exception {
|
public void selectTitle() throws Exception {
|
||||||
// use official english title
|
assertEquals("Seikai no Senki", anidb.selectTitle(getHtmlDocument(new URL("http://anidb.net/a4"))));
|
||||||
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"))));
|
@Test
|
||||||
|
public void selectEnglishTitle() throws Exception {
|
||||||
|
assertEquals("Banner of the Stars", anidb.selectOfficialTitle(getHtmlDocument(new URL("http://anidb.net/a4")), "English"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue