From 223a82deb5b906d3b3c1833da05137106c1d23ee Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 17 Feb 2017 20:28:21 +0800 Subject: [PATCH] Introduce "Absolute Airdate Order" to improve support for "Match by Airdate Number (e.g. 20161231)" and "Match by Episode Title" kind of use case --- source/net/filebot/web/SortOrder.java | 15 ++++++++++++--- source/net/filebot/web/TheTVDBClientV1.java | 14 ++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/source/net/filebot/web/SortOrder.java b/source/net/filebot/web/SortOrder.java index 7f449574..dc340663 100644 --- a/source/net/filebot/web/SortOrder.java +++ b/source/net/filebot/web/SortOrder.java @@ -7,11 +7,20 @@ import java.util.List; public enum SortOrder { - Airdate, DVD, Absolute; + Airdate, DVD, Absolute, AbsoluteAirdate; @Override public String toString() { - return name() + " Order"; + switch (this) { + case Airdate: + return "Airdate Order"; + case DVD: + return "DVD Order"; + case Absolute: + return "Absolute Order"; + default: + return "Absolute Airdate Order"; + } } public static List names() { @@ -25,7 +34,7 @@ public enum SortOrder { } } - throw new IllegalArgumentException("Illegal SortOrder: " + name); + throw new IllegalArgumentException(String.format("%s not in %s", name, names())); } } diff --git a/source/net/filebot/web/TheTVDBClientV1.java b/source/net/filebot/web/TheTVDBClientV1.java index f80d831c..e55b74d3 100644 --- a/source/net/filebot/web/TheTVDBClientV1.java +++ b/source/net/filebot/web/TheTVDBClientV1.java @@ -179,12 +179,14 @@ public class TheTVDBClientV1 extends AbstractEpisodeListProvider implements Artw Integer specialNumber = (episodeNumber != null) ? episodeNumber : filterBySeason(specials, seasonNumber).size() + 1; specials.add(new Episode(seriesInfo.getName(), seasonNumber, null, episodeName, absoluteNumber, specialNumber, airdate, id, new SeriesInfo(seriesInfo))); } else { - // adjust for absolute numbering if possible - if (sortOrder == SortOrder.Absolute) { - if (absoluteNumber != null && absoluteNumber > 0) { - episodeNumber = absoluteNumber; - seasonNumber = null; - } + // adjust for forced absolute numbering (if possible) + if (sortOrder == SortOrder.Absolute && absoluteNumber != null && absoluteNumber > 0) { + seasonNumber = null; + episodeNumber = absoluteNumber; + } else if (sortOrder == SortOrder.AbsoluteAirdate && airdate != null) { + // use airdate as absolute episode number + seasonNumber = null; + episodeNumber = airdate.getYear() * 1_00_00 + airdate.getMonth() * 1_00 + airdate.getDay(); } // handle as normal episode