mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-10 06:20:27 -04:00
access episode list and find minimum airdate if necessary
This commit is contained in:
parent
dc1b8a41a0
commit
103dd239c2
@ -2,7 +2,6 @@ package net.filebot.format;
|
|||||||
|
|
||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.*;
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
import static java.util.Collections.sort;
|
|
||||||
import static java.util.stream.Collectors.*;
|
import static java.util.stream.Collectors.*;
|
||||||
import static net.filebot.Logging.*;
|
import static net.filebot.Logging.*;
|
||||||
import static net.filebot.MediaTypes.*;
|
import static net.filebot.MediaTypes.*;
|
||||||
@ -125,9 +124,9 @@ public class MediaBindingBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Define("y")
|
@Define("y")
|
||||||
public Integer getYear() {
|
public Integer getYear() throws Exception {
|
||||||
if (infoObject instanceof Episode)
|
if (infoObject instanceof Episode)
|
||||||
return getEpisode().getSeriesInfo().getStartDate().getYear();
|
return getStartDate().getYear();
|
||||||
if (infoObject instanceof Movie)
|
if (infoObject instanceof Movie)
|
||||||
return getMovie().getYear();
|
return getMovie().getYear();
|
||||||
|
|
||||||
@ -138,9 +137,8 @@ public class MediaBindingBean {
|
|||||||
public String getNameWithYear() {
|
public String getNameWithYear() {
|
||||||
String n = getName();
|
String n = getName();
|
||||||
try {
|
try {
|
||||||
String y = String.format(" (%d)", getYear());
|
|
||||||
|
|
||||||
// account for TV Shows that contain the year in the series name, e.g. Doctor Who (2005)
|
// account for TV Shows that contain the year in the series name, e.g. Doctor Who (2005)
|
||||||
|
String y = String.format(" (%d)", getYear());
|
||||||
return n.endsWith(y) ? n : n + y;
|
return n.endsWith(y) ? n : n + y;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// default to {n} if {y} is undefined
|
// default to {n} if {y} is undefined
|
||||||
@ -260,8 +258,16 @@ public class MediaBindingBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Define("startdate")
|
@Define("startdate")
|
||||||
public SimpleDate getStartDate() {
|
public SimpleDate getStartDate() throws Exception {
|
||||||
return getEpisode().getSeriesInfo().getStartDate();
|
SimpleDate startdate = getEpisode().getSeriesInfo().getStartDate();
|
||||||
|
|
||||||
|
// use series metadata startdate if possible
|
||||||
|
if (startdate != null) {
|
||||||
|
return startdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// access episode list and find minimum airdate if necessary
|
||||||
|
return getEpisodeList().stream().filter(e -> isRegular(e)).map(Episode::getAirdate).filter(Objects::nonNull).min(SimpleDate::compareTo).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Define("absolute")
|
@Define("absolute")
|
||||||
@ -1343,7 +1349,7 @@ public class MediaBindingBean {
|
|||||||
keys.add(e.getTitle());
|
keys.add(e.getTitle());
|
||||||
}
|
}
|
||||||
} else if (infoObject instanceof Movie) {
|
} else if (infoObject instanceof Movie) {
|
||||||
keys.add(getYear());
|
keys.add(getMovie().getYear());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user