Introduce "Absolute Airdate Order" to improve support for "Match by Airdate Number (e.g. 20161231)" and "Match by Episode Title" kind of use case
This commit is contained in:
parent
04e8691553
commit
223a82deb5
|
@ -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<String> 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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue