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) {
|
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
|
episodes.add(new Episode(animeTitle, null, number, title, number, null, airdate, id, new SeriesInfo(seriesInfo))); // normal episode, no seasons for anime
|
||||||
} else {
|
} else {
|
||||||
episodes.add(new Episode(animeTitle, null, null, title, null, number, airdate, id, new SeriesInfo(seriesInfo))); // special episode
|
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 episodeNumber = getInteger(it, "airedEpisodeNumber");
|
||||||
Integer seasonNumber = getInteger(it, "airedSeason");
|
Integer seasonNumber = getInteger(it, "airedSeason");
|
||||||
|
|
||||||
// use preferred numbering if possible
|
// adjust for forced absolute numbering (if possible)
|
||||||
if (sortOrder == SortOrder.DVD) {
|
if (sortOrder == SortOrder.DVD) {
|
||||||
Integer dvdSeasonNumber = getInteger(it, "dvdSeason");
|
Integer dvdSeasonNumber = getInteger(it, "dvdSeason");
|
||||||
Integer dvdEpisodeNumber = getInteger(it, "dvdEpisodeNumber");
|
Integer dvdEpisodeNumber = getInteger(it, "dvdEpisodeNumber");
|
||||||
|
@ -198,8 +198,12 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor
|
||||||
episodeNumber = dvdEpisodeNumber;
|
episodeNumber = dvdEpisodeNumber;
|
||||||
}
|
}
|
||||||
} else if (sortOrder == SortOrder.Absolute && absoluteNumber != null && absoluteNumber > 0) {
|
} else if (sortOrder == SortOrder.Absolute && absoluteNumber != null && absoluteNumber > 0) {
|
||||||
episodeNumber = absoluteNumber;
|
|
||||||
seasonNumber = null;
|
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) {
|
if (seasonNumber == null || seasonNumber > 0) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class TheTVDBClientTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListNumbering() throws Exception {
|
public void getEpisodeListNumberingDVD() throws Exception {
|
||||||
List<Episode> list = db.getEpisodeList(firefly, SortOrder.DVD, Locale.ENGLISH);
|
List<Episode> list = db.getEpisodeList(firefly, SortOrder.DVD, Locale.ENGLISH);
|
||||||
|
|
||||||
Episode first = list.get(0);
|
Episode first = list.get(0);
|
||||||
|
@ -100,6 +100,20 @@ public class TheTVDBClientTest {
|
||||||
assertEquals("2002-12-20", first.getAirdate().toString());
|
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() {
|
public void getEpisodeListLink() {
|
||||||
assertEquals("http://www.thetvdb.com/?tab=seasonall&id=78874", db.getEpisodeListLink(firefly).toString());
|
assertEquals("http://www.thetvdb.com/?tab=seasonall&id=78874", db.getEpisodeListLink(firefly).toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class TheTVDBClientV1Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEpisodeListNumbering() throws Exception {
|
public void getEpisodeListNumberingDVD() throws Exception {
|
||||||
List<Episode> list = db.getEpisodeList(firefly, SortOrder.DVD, Locale.ENGLISH);
|
List<Episode> list = db.getEpisodeList(firefly, SortOrder.DVD, Locale.ENGLISH);
|
||||||
|
|
||||||
Episode first = list.get(0);
|
Episode first = list.get(0);
|
||||||
|
@ -97,6 +97,20 @@ public class TheTVDBClientV1Test {
|
||||||
assertEquals("297999", first.getId().toString());
|
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() {
|
public void getEpisodeListLink() {
|
||||||
assertEquals("http://www.thetvdb.com/?tab=seasonall&id=78874", db.getEpisodeListLink(firefly).toString());
|
assertEquals("http://www.thetvdb.com/?tab=seasonall&id=78874", db.getEpisodeListLink(firefly).toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue