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
223a82deb5
commit
a513cf556a
@ -158,6 +158,12 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
||||
}
|
||||
|
||||
if (type == 1) {
|
||||
// adjust for forced absolute numbering (if possible)
|
||||
if (sortOrder == SortOrder.AbsoluteAirdate && airdate != null) {
|
||||
// use airdate as absolute episode number
|
||||
number = airdate.getYear() * 1_00_00 + airdate.getMonth() * 1_00 + airdate.getDay();
|
||||
}
|
||||
|
||||
episodes.add(new Episode(animeTitle, null, number, title, number, null, airdate, id, new SeriesInfo(seriesInfo))); // normal episode, no seasons for anime
|
||||
} else {
|
||||
episodes.add(new Episode(animeTitle, null, null, title, null, number, airdate, id, new SeriesInfo(seriesInfo))); // special episode
|
||||
|
@ -187,7 +187,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor
|
||||
Integer episodeNumber = getInteger(it, "airedEpisodeNumber");
|
||||
Integer seasonNumber = getInteger(it, "airedSeason");
|
||||
|
||||
// use preferred numbering if possible
|
||||
// adjust for forced absolute numbering (if possible)
|
||||
if (sortOrder == SortOrder.DVD) {
|
||||
Integer dvdSeasonNumber = getInteger(it, "dvdSeason");
|
||||
Integer dvdEpisodeNumber = getInteger(it, "dvdEpisodeNumber");
|
||||
@ -198,8 +198,12 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor
|
||||
episodeNumber = dvdEpisodeNumber;
|
||||
}
|
||||
} else if (sortOrder == SortOrder.Absolute && absoluteNumber != null && absoluteNumber > 0) {
|
||||
episodeNumber = absoluteNumber;
|
||||
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();
|
||||
}
|
||||
|
||||
if (seasonNumber == null || seasonNumber > 0) {
|
||||
|
@ -87,7 +87,7 @@ public class TheTVDBClientTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEpisodeListNumbering() throws Exception {
|
||||
public void getEpisodeListNumberingDVD() throws Exception {
|
||||
List<Episode> list = db.getEpisodeList(firefly, SortOrder.DVD, Locale.ENGLISH);
|
||||
|
||||
Episode first = list.get(0);
|
||||
@ -100,6 +100,20 @@ public class TheTVDBClientTest {
|
||||
assertEquals("2002-12-20", first.getAirdate().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEpisodeListNumberingAbsoluteAirdate() throws Exception {
|
||||
List<Episode> list = db.getEpisodeList(firefly, SortOrder.AbsoluteAirdate, Locale.ENGLISH);
|
||||
|
||||
Episode first = list.get(0);
|
||||
assertEquals("Firefly", first.getSeriesName());
|
||||
assertEquals("2002-09-20", first.getSeriesInfo().getStartDate().toString());
|
||||
assertEquals("The Train Job", first.getTitle());
|
||||
assertEquals("20020920", first.getEpisode().toString());
|
||||
assertEquals(null, first.getSeason());
|
||||
assertEquals("2", first.getAbsolute().toString());
|
||||
assertEquals("2002-09-20", first.getAirdate().toString());
|
||||
}
|
||||
|
||||
public void getEpisodeListLink() {
|
||||
assertEquals("http://www.thetvdb.com/?tab=seasonall&id=78874", db.getEpisodeListLink(firefly).toString());
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class TheTVDBClientV1Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEpisodeListNumbering() throws Exception {
|
||||
public void getEpisodeListNumberingDVD() throws Exception {
|
||||
List<Episode> list = db.getEpisodeList(firefly, SortOrder.DVD, Locale.ENGLISH);
|
||||
|
||||
Episode first = list.get(0);
|
||||
@ -97,6 +97,20 @@ public class TheTVDBClientV1Test {
|
||||
assertEquals("297999", first.getId().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEpisodeListNumberingAbsoluteAirdate() throws Exception {
|
||||
List<Episode> list = db.getEpisodeList(firefly, SortOrder.AbsoluteAirdate, Locale.ENGLISH);
|
||||
|
||||
Episode first = list.get(0);
|
||||
assertEquals("Firefly", first.getSeriesName());
|
||||
assertEquals("2002-09-20", first.getSeriesInfo().getStartDate().toString());
|
||||
assertEquals("The Train Job", first.getTitle());
|
||||
assertEquals("20020920", first.getEpisode().toString());
|
||||
assertEquals(null, first.getSeason());
|
||||
assertEquals("2", first.getAbsolute().toString());
|
||||
assertEquals("2002-09-20", first.getAirdate().toString());
|
||||
}
|
||||
|
||||
public void getEpisodeListLink() {
|
||||
assertEquals("http://www.thetvdb.com/?tab=seasonall&id=78874", db.getEpisodeListLink(firefly).toString());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user