* parse specials from anidb episode data

This commit is contained in:
Reinhard Pointner 2013-05-06 08:21:20 +00:00
parent 011f4e82c0
commit fc1c8a26e2
3 changed files with 18 additions and 6 deletions

View File

@ -121,18 +121,22 @@ public class AnidbClient extends AbstractEpisodeListProvider {
List<Episode> episodes = new ArrayList<Episode>(25); List<Episode> episodes = new ArrayList<Episode>(25);
for (Node node : selectNodes("//episode", dom)) { for (Node node : selectNodes("//episode", dom)) {
Integer number = getIntegerContent("epno", node); Node epno = getChild("epno", node);
int number = Integer.parseInt(getTextContent(epno).replaceAll("\\D", ""));
int type = Integer.parseInt(getAttribute("type", epno));
// ignore special episodes if (type == 1 || type == 2) {
if (number != null) {
Date airdate = Date.parse(getTextContent("airdate", node), "yyyy-MM-dd"); Date airdate = Date.parse(getTextContent("airdate", node), "yyyy-MM-dd");
String title = selectString(".//title[@lang='" + language.getLanguage() + "']", node); String title = selectString(".//title[@lang='" + language.getLanguage() + "']", node);
if (title.isEmpty()) { // English language fall-back if (title.isEmpty()) { // English language fall-back
title = selectString(".//title[@lang='en']", node); title = selectString(".//title[@lang='en']", node);
} }
// no seasons for anime if (type == 1) {
episodes.add(new Episode(animeTitle, seriesStartDate, null, number, title, number, null, airdate)); episodes.add(new Episode(animeTitle, seriesStartDate, null, number, title, number, null, airdate)); // normal episode, no seasons for anime
} else {
episodes.add(new Episode(animeTitle, seriesStartDate, null, null, title, null, number, airdate)); // special episode
}
} }
} }

View File

@ -54,7 +54,11 @@ public class EpisodeFormat extends Format {
} }
} else { } else {
// episode, but no season // episode, but no season
sb.append(" - ").append(episodeNumber); if (episode.getEpisode() != null) {
sb.append(" - ").append(episodeNumber);
} else if (includeSpecial && episode.getSpecial() != null) {
sb.append(" - ").append("Special " + episode.getSpecial());
}
} }
sb.append(" - ").append(episode.getTitle()); sb.append(" - ").append(episode.getTitle());

View File

@ -60,6 +60,10 @@ public final class EpisodeUtilities {
if (diff != 0) if (diff != 0)
return diff; return diff;
diff = compareValue(a.getSpecial(), b.getSpecial());
if (diff != 0)
return diff;
return compareValue(a.getTitle(), b.getTitle()); return compareValue(a.getTitle(), b.getTitle());
} }