From fc1c8a26e2ef088512b54f26fc910ffdf2500a2a Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 6 May 2013 08:21:20 +0000 Subject: [PATCH] * parse specials from anidb episode data --- .../net/sourceforge/filebot/web/AnidbClient.java | 14 +++++++++----- .../net/sourceforge/filebot/web/EpisodeFormat.java | 6 +++++- .../sourceforge/filebot/web/EpisodeUtilities.java | 4 ++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/source/net/sourceforge/filebot/web/AnidbClient.java b/source/net/sourceforge/filebot/web/AnidbClient.java index d19eaf71..de8bef83 100644 --- a/source/net/sourceforge/filebot/web/AnidbClient.java +++ b/source/net/sourceforge/filebot/web/AnidbClient.java @@ -121,18 +121,22 @@ public class AnidbClient extends AbstractEpisodeListProvider { List episodes = new ArrayList(25); 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 (number != null) { + if (type == 1 || type == 2) { Date airdate = Date.parse(getTextContent("airdate", node), "yyyy-MM-dd"); String title = selectString(".//title[@lang='" + language.getLanguage() + "']", node); if (title.isEmpty()) { // English language fall-back title = selectString(".//title[@lang='en']", node); } - // no seasons for anime - episodes.add(new Episode(animeTitle, seriesStartDate, null, number, title, number, null, airdate)); + if (type == 1) { + 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 + } } } diff --git a/source/net/sourceforge/filebot/web/EpisodeFormat.java b/source/net/sourceforge/filebot/web/EpisodeFormat.java index 8646f14a..dfae85c8 100644 --- a/source/net/sourceforge/filebot/web/EpisodeFormat.java +++ b/source/net/sourceforge/filebot/web/EpisodeFormat.java @@ -54,7 +54,11 @@ public class EpisodeFormat extends Format { } } else { // 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()); diff --git a/source/net/sourceforge/filebot/web/EpisodeUtilities.java b/source/net/sourceforge/filebot/web/EpisodeUtilities.java index f746f6a6..3ec7b230 100644 --- a/source/net/sourceforge/filebot/web/EpisodeUtilities.java +++ b/source/net/sourceforge/filebot/web/EpisodeUtilities.java @@ -60,6 +60,10 @@ public final class EpisodeUtilities { if (diff != 0) return diff; + diff = compareValue(a.getSpecial(), b.getSpecial()); + if (diff != 0) + return diff; + return compareValue(a.getTitle(), b.getTitle()); }