+ added support for SeriesStartDate
This commit is contained in:
parent
010519c537
commit
ced6f4e9af
|
@ -65,7 +65,7 @@ public class MediaBindingBean {
|
|||
@Define("y")
|
||||
public Integer getYear() {
|
||||
if (infoObject instanceof Episode)
|
||||
return getEpisode().airdate().getYear();
|
||||
return getEpisode().getSeriesStartDate().getYear();
|
||||
if (infoObject instanceof Movie)
|
||||
return getMovie().getYear();
|
||||
|
||||
|
@ -97,6 +97,12 @@ public class MediaBindingBean {
|
|||
}
|
||||
|
||||
|
||||
@Define("startdate")
|
||||
public Date startdate() {
|
||||
return getEpisode().getSeriesStartDate();
|
||||
}
|
||||
|
||||
|
||||
@Define("absolute")
|
||||
public Integer getAbsoluteEpisodeNumber() {
|
||||
return getEpisode().getAbsolute();
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
parameter.exclude: ^StreamKind|Count$
|
||||
|
||||
# preview expressions (keys are tagged so they can be sorted alphabetically)
|
||||
expressions: n,s,e,t,y,airdate,absolute,special,imdb,episode,movie,vc,ac,cf,vf,af,resolution,source,group,crc32,fn,ext,file,pi,pn,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language
|
||||
expressions: n,y,s,e,t,airdate,startdate,absolute,special,imdb,episode,movie,vc,ac,cf,vf,af,resolution,source,group,crc32,fn,ext,file,pi,pn,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language
|
||||
|
|
|
@ -95,7 +95,6 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
|||
if (name != null) {
|
||||
// normalize
|
||||
name = name.toLowerCase();
|
||||
|
||||
float similarity = metric.getSimilarity(name, query);
|
||||
|
||||
if (similarity > 0.5 || name.contains(query)) {
|
||||
|
@ -149,7 +148,8 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
|||
// get anime page as xml
|
||||
Document dom = getDocument(url);
|
||||
|
||||
// select main title
|
||||
// select main title and anime start date
|
||||
Date seriesStartDate = Date.parse(selectString("//startdate", dom), "yyyy-MM-dd");
|
||||
String animeTitle = selectString("//titles/title[@type='official' and @lang='" + language.getLanguage() + "']", dom);
|
||||
if (animeTitle.isEmpty()) {
|
||||
animeTitle = selectString("//titles/title[@type='main']", dom);
|
||||
|
@ -162,15 +162,14 @@ public class AnidbClient extends AbstractEpisodeListProvider {
|
|||
|
||||
// ignore special episodes
|
||||
if (number != null) {
|
||||
Date airdate = Date.parse(getTextContent("airdate", node), "yyyy-MM-dd");
|
||||
String title = selectString(".//title[@lang='" + language.getLanguage() + "']", node);
|
||||
if (title.isEmpty()) { // English language fall-back
|
||||
title = selectString(".//title[@lang='en']", node);
|
||||
}
|
||||
|
||||
String airdate = getTextContent("airdate", node);
|
||||
|
||||
// no seasons for anime
|
||||
episodes.add(new Episode(animeTitle, null, number, title, number, null, Date.parse(airdate, "yyyy-MM-dd")));
|
||||
episodes.add(new Episode(animeTitle, seriesStartDate, null, number, title, number, null, airdate));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class Date implements Serializable {
|
|||
return year == other.year && month == other.month && day == other.day;
|
||||
}
|
||||
|
||||
return false;
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import java.util.Arrays;
|
|||
public class Episode implements Serializable {
|
||||
|
||||
private String seriesName;
|
||||
private Date seriesStartDate;
|
||||
|
||||
private Integer season;
|
||||
private Integer episode;
|
||||
private String title;
|
||||
|
@ -28,13 +30,14 @@ public class Episode implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public Episode(String seriesName, Integer season, Integer episode, String title) {
|
||||
this(seriesName, season, episode, title, null, null, null);
|
||||
public Episode(String seriesName, Date seriesStartDate, Integer season, Integer episode, String title) {
|
||||
this(seriesName, seriesStartDate, season, episode, title, null, null, null);
|
||||
}
|
||||
|
||||
|
||||
public Episode(String seriesName, Integer season, Integer episode, String title, Integer absolute, Integer special, Date airdate) {
|
||||
public Episode(String seriesName, Date seriesStartDate, Integer season, Integer episode, String title, Integer absolute, Integer special, Date airdate) {
|
||||
this.seriesName = seriesName;
|
||||
this.seriesStartDate = seriesStartDate;
|
||||
this.season = season;
|
||||
this.episode = episode;
|
||||
this.title = title;
|
||||
|
@ -49,6 +52,11 @@ public class Episode implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public Date getSeriesStartDate() {
|
||||
return seriesStartDate;
|
||||
}
|
||||
|
||||
|
||||
public Integer getEpisode() {
|
||||
return episode;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class EpisodeFormat extends Format {
|
|||
|
||||
// did parse input
|
||||
pos.setIndex(source.length());
|
||||
return new Episode(name, season, episode, title, season == null ? episode : null, special, airdate);
|
||||
return new Episode(name, null, season, episode, title, season == null ? episode : null, special, airdate);
|
||||
}
|
||||
|
||||
// failed to parse input
|
||||
|
|
|
@ -46,9 +46,7 @@ public class IMDbClient extends AbstractEpisodeListProvider {
|
|||
|
||||
@Override
|
||||
public List<SearchResult> search(String query, Locale locale) throws IOException, SAXException {
|
||||
|
||||
URL searchUrl = new URL("http", host, "/find?s=tt&q=" + URLEncoder.encode(query, "UTF-8"));
|
||||
|
||||
Document dom = getHtmlDocument(openConnection(searchUrl));
|
||||
|
||||
List<Node> nodes = selectNodes("//TABLE//A[following-sibling::SMALL[contains(.,'series')]]", dom);
|
||||
|
@ -85,6 +83,7 @@ public class IMDbClient extends AbstractEpisodeListProvider {
|
|||
Document dom = getHtmlDocument(openConnection(getEpisodeListLink(searchResult).toURL()));
|
||||
|
||||
String seriesName = normalizeName(selectString("//H1/A", dom));
|
||||
Date year = new Date(((Movie) searchResult).getYear(), 0, 0);
|
||||
|
||||
List<Node> nodes = selectNodes("//TABLE//H3/A[preceding-sibling::text()]", dom);
|
||||
|
||||
|
@ -98,9 +97,9 @@ public class IMDbClient extends AbstractEpisodeListProvider {
|
|||
Integer episode = numberScanner.nextInt();
|
||||
|
||||
// e.g. 20 May 2003
|
||||
String airdate = selectString("./following::STRONG", node);
|
||||
Date airdate = Date.parse(selectString("./following::STRONG", node), "dd MMMMM yyyyy");
|
||||
|
||||
episodes.add(new Episode(seriesName, season, episode, title, null, null, Date.parse(airdate, "dd MMMMM yyyyy")));
|
||||
episodes.add(new Episode(seriesName, year, season, episode, title, null, null, airdate));
|
||||
}
|
||||
|
||||
return episodes;
|
||||
|
|
|
@ -72,6 +72,7 @@ public class TVRageClient extends AbstractEpisodeListProvider {
|
|||
Document dom = getDocument(episodeListUrl);
|
||||
|
||||
String seriesName = selectString("Show/name", dom);
|
||||
Date seriesStartDate = Date.parse(selectString("//started", dom), "MMM/dd/yyyy");
|
||||
|
||||
List<Episode> episodes = new ArrayList<Episode>(25);
|
||||
List<Episode> specials = new ArrayList<Episode>(5);
|
||||
|
@ -89,10 +90,10 @@ public class TVRageClient extends AbstractEpisodeListProvider {
|
|||
// handle as special episode
|
||||
seasonNumber = getIntegerContent("season", node);
|
||||
int specialNumber = filterBySeason(specials, seasonNumber).size() + 1;
|
||||
specials.add(new Episode(seriesName, seasonNumber, null, title, null, specialNumber, airdate));
|
||||
specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, title, null, specialNumber, airdate));
|
||||
} else {
|
||||
// handle as normal episode
|
||||
episodes.add(new Episode(seriesName, seasonNumber, episodeNumber, title, null, null, airdate));
|
||||
episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, title, null, null, airdate));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
|||
|
||||
// we could get the series name from the search result, but the language may not match the given parameter
|
||||
String seriesName = selectString("Data/Series/SeriesName", seriesRecord);
|
||||
Date seriesStartDate = Date.parse(selectString("Data/Series/FirstAired", seriesRecord), "yyyy-MM-dd");
|
||||
|
||||
List<Node> nodes = selectNodes("Data/Episode", seriesRecord);
|
||||
|
||||
|
@ -150,10 +151,10 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
|||
}
|
||||
|
||||
Integer specialNumber = filterBySeason(specials, seasonNumber).size() + 1;
|
||||
specials.add(new Episode(seriesName, seasonNumber, null, episodeName, null, specialNumber, airdate));
|
||||
specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, episodeName, null, specialNumber, airdate));
|
||||
} else {
|
||||
// handle as normal episode
|
||||
episodes.add(new Episode(seriesName, seasonNumber, episodeNumber, episodeName, absoluteNumber, null, airdate));
|
||||
episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, episodeName, absoluteNumber, null, airdate));
|
||||
}
|
||||
|
||||
if (episodeNumber == 1) {
|
||||
|
|
|
@ -106,6 +106,11 @@ public final class WebRequest {
|
|||
}
|
||||
|
||||
|
||||
public static ByteBuffer fetch(URL resource) throws IOException {
|
||||
return fetch(resource, 0, null);
|
||||
}
|
||||
|
||||
|
||||
public static ByteBuffer fetchIfModified(URL resource, long ifModifiedSince) throws IOException {
|
||||
return fetch(resource, ifModifiedSince, null);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class AnidbClientTest {
|
|||
}
|
||||
|
||||
|
||||
private AnidbClient anidb = new AnidbClient("filebot", 1);
|
||||
private AnidbClient anidb = new AnidbClient("filebot", 2);
|
||||
|
||||
|
||||
@Test
|
||||
|
@ -83,6 +83,7 @@ public class AnidbClientTest {
|
|||
Episode first = list.get(0);
|
||||
|
||||
assertEquals("Monster", first.getSeriesName());
|
||||
assertEquals("2004-04-07", first.getSeriesStartDate().toString());
|
||||
assertEquals("Herr Dr. Tenma", first.getTitle());
|
||||
assertEquals("1", first.getEpisode().toString());
|
||||
assertEquals("1", first.getAbsolute().toString());
|
||||
|
@ -100,6 +101,7 @@ public class AnidbClientTest {
|
|||
Episode first = list.get(0);
|
||||
|
||||
assertEquals("The Twelve Kingdoms", first.getSeriesName());
|
||||
assertEquals("2002-04-09", first.getSeriesStartDate().toString());
|
||||
assertEquals("Shadow of the Moon, The Sea of Shadow - Chapter 1", first.getTitle());
|
||||
assertEquals("1", first.getEpisode().toString());
|
||||
assertEquals("1", first.getAbsolute().toString());
|
||||
|
@ -120,6 +122,7 @@ public class AnidbClientTest {
|
|||
|
||||
Episode last = list.get(73);
|
||||
assertEquals("モンスター", last.getSeriesName());
|
||||
assertEquals("2004-04-07", last.getSeriesStartDate().toString());
|
||||
assertEquals("本当の怪物", last.getTitle());
|
||||
assertEquals("74", last.getEpisode().toString());
|
||||
assertEquals("74", last.getAbsolute().toString());
|
||||
|
|
|
@ -71,6 +71,7 @@ public class IMDbClientTest {
|
|||
Episode first = list.get(0);
|
||||
|
||||
assertEquals("Buffy the Vampire Slayer", first.getSeriesName());
|
||||
assertEquals("1997-00-00", first.getSeriesStartDate().toString());
|
||||
assertEquals("Unaired Pilot", first.getTitle());
|
||||
assertEquals("0", first.getEpisode().toString());
|
||||
assertEquals("1", first.getSeason().toString());
|
||||
|
@ -79,6 +80,7 @@ public class IMDbClientTest {
|
|||
Episode last = list.get(144);
|
||||
|
||||
assertEquals("Buffy the Vampire Slayer", last.getSeriesName());
|
||||
assertEquals("1997-00-00", first.getSeriesStartDate().toString());
|
||||
assertEquals("Chosen", last.getTitle());
|
||||
assertEquals("22", last.getEpisode().toString());
|
||||
assertEquals("7", last.getSeason().toString());
|
||||
|
@ -95,6 +97,7 @@ public class IMDbClientTest {
|
|||
Episode first = list.get(0);
|
||||
|
||||
assertEquals("Mushi-Shi", first.getSeriesName());
|
||||
assertEquals("2005-00-00", first.getSeriesStartDate().toString());
|
||||
assertEquals("Midori no za", first.getTitle());
|
||||
assertEquals("1", first.getEpisode().toString());
|
||||
assertEquals("1", first.getSeason().toString());
|
||||
|
|
|
@ -43,6 +43,7 @@ public class TVRageClientTest {
|
|||
Episode chosen = list.get(21);
|
||||
|
||||
assertEquals("Buffy the Vampire Slayer", chosen.getSeriesName());
|
||||
assertEquals("2002-04-09", chosen.getSeriesStartDate().toString());
|
||||
assertEquals("Chosen", chosen.getTitle());
|
||||
assertEquals("22", chosen.getEpisode().toString());
|
||||
assertEquals("7", chosen.getSeason().toString());
|
||||
|
|
|
@ -38,19 +38,14 @@ public class TheTVDBClientTest {
|
|||
|
||||
@Test
|
||||
public void searchGerman() throws Exception {
|
||||
List<SearchResult> results = thetvdb.search("buffy", Locale.GERMAN);
|
||||
List<SearchResult> results = thetvdb.search("Buffy the Vampire Slayer", Locale.GERMAN);
|
||||
|
||||
assertEquals(4, results.size());
|
||||
assertEquals(2, results.size());
|
||||
|
||||
TheTVDBSearchResult first = (TheTVDBSearchResult) results.get(0);
|
||||
|
||||
assertEquals("Buffy", first.getName());
|
||||
assertEquals("Buffy the Vampire Slayer", first.getName());
|
||||
assertEquals(70327, first.getSeriesId());
|
||||
|
||||
TheTVDBSearchResult second = (TheTVDBSearchResult) results.get(1);
|
||||
|
||||
assertEquals("Buffy the Vampire Slayer", second.getName());
|
||||
assertEquals(70327, second.getSeriesId());
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,6 +58,7 @@ public class TheTVDBClientTest {
|
|||
// check ordinary episode
|
||||
Episode first = list.get(0);
|
||||
assertEquals("Buffy the Vampire Slayer", first.getSeriesName());
|
||||
assertEquals("1997-03-10", first.getSeriesStartDate().toString());
|
||||
assertEquals("Welcome to the Hellmouth (1)", first.getTitle());
|
||||
assertEquals("1", first.getEpisode().toString());
|
||||
assertEquals("1", first.getSeason().toString());
|
||||
|
@ -90,6 +86,7 @@ public class TheTVDBClientTest {
|
|||
Episode first = list.get(0);
|
||||
|
||||
assertEquals("Wonderfalls", first.getSeriesName());
|
||||
assertEquals("2004-03-12", first.getSeriesStartDate().toString());
|
||||
assertEquals("Wax Lion", first.getTitle());
|
||||
assertEquals("1", first.getEpisode().toString());
|
||||
assertEquals("1", first.getSeason().toString());
|
||||
|
@ -106,6 +103,7 @@ public class TheTVDBClientTest {
|
|||
|
||||
Episode first = list.get(0);
|
||||
assertEquals("Firefly", first.getSeriesName());
|
||||
assertEquals("2002-09-20", first.getSeriesStartDate().toString());
|
||||
assertEquals("Serenity", first.getTitle());
|
||||
assertEquals("1", first.getEpisode().toString());
|
||||
assertEquals("1", first.getSeason().toString());
|
||||
|
|
|
@ -119,6 +119,11 @@
|
|||
<td>series/movie name</td>
|
||||
<td>Dark Angel</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>y</td>
|
||||
<td>series/movie year</td>
|
||||
<td>2009</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>s</td>
|
||||
<td>season number</td>
|
||||
|
@ -134,11 +139,6 @@
|
|||
<td>episode title</td>
|
||||
<td>Labyrinth</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>y</td>
|
||||
<td>episode/movie year</td>
|
||||
<td>2009</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>airdate</td>
|
||||
<td>episode airdate</td>
|
||||
|
|
Loading…
Reference in New Issue