+ added support for SeriesStartDate

This commit is contained in:
Reinhard Pointner 2011-10-01 04:08:46 +00:00
parent 010519c537
commit ced6f4e9af
15 changed files with 58 additions and 34 deletions

View File

@ -65,7 +65,7 @@ public class MediaBindingBean {
@Define("y") @Define("y")
public Integer getYear() { public Integer getYear() {
if (infoObject instanceof Episode) if (infoObject instanceof Episode)
return getEpisode().airdate().getYear(); return getEpisode().getSeriesStartDate().getYear();
if (infoObject instanceof Movie) if (infoObject instanceof Movie)
return getMovie().getYear(); return getMovie().getYear();
@ -97,6 +97,12 @@ public class MediaBindingBean {
} }
@Define("startdate")
public Date startdate() {
return getEpisode().getSeriesStartDate();
}
@Define("absolute") @Define("absolute")
public Integer getAbsoluteEpisodeNumber() { public Integer getAbsoluteEpisodeNumber() {
return getEpisode().getAbsolute(); return getEpisode().getAbsolute();

View File

@ -2,4 +2,4 @@
parameter.exclude: ^StreamKind|Count$ parameter.exclude: ^StreamKind|Count$
# preview expressions (keys are tagged so they can be sorted alphabetically) # 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

View File

@ -95,7 +95,6 @@ public class AnidbClient extends AbstractEpisodeListProvider {
if (name != null) { if (name != null) {
// normalize // normalize
name = name.toLowerCase(); name = name.toLowerCase();
float similarity = metric.getSimilarity(name, query); float similarity = metric.getSimilarity(name, query);
if (similarity > 0.5 || name.contains(query)) { if (similarity > 0.5 || name.contains(query)) {
@ -149,7 +148,8 @@ public class AnidbClient extends AbstractEpisodeListProvider {
// get anime page as xml // get anime page as xml
Document dom = getDocument(url); 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); String animeTitle = selectString("//titles/title[@type='official' and @lang='" + language.getLanguage() + "']", dom);
if (animeTitle.isEmpty()) { if (animeTitle.isEmpty()) {
animeTitle = selectString("//titles/title[@type='main']", dom); animeTitle = selectString("//titles/title[@type='main']", dom);
@ -162,15 +162,14 @@ public class AnidbClient extends AbstractEpisodeListProvider {
// ignore special episodes // ignore special episodes
if (number != null) { if (number != null) {
Date airdate = Date.parse(getTextContent("airdate", node), "yyyy-MM-dd");
String title = selectString(".//title[@lang='" + language.getLanguage() + "']", node); String title = selectString(".//title[@lang='" + language.getLanguage() + "']", node);
if (title.isEmpty()) { // English language fall-back if (title.isEmpty()) { // English language fall-back
title = selectString(".//title[@lang='en']", node); title = selectString(".//title[@lang='en']", node);
} }
String airdate = getTextContent("airdate", node);
// no seasons for anime // 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));
} }
} }

View File

@ -56,7 +56,7 @@ public class Date implements Serializable {
return year == other.year && month == other.month && day == other.day; return year == other.year && month == other.month && day == other.day;
} }
return false; return super.equals(obj);
} }

View File

@ -9,6 +9,8 @@ import java.util.Arrays;
public class Episode implements Serializable { public class Episode implements Serializable {
private String seriesName; private String seriesName;
private Date seriesStartDate;
private Integer season; private Integer season;
private Integer episode; private Integer episode;
private String title; private String title;
@ -28,13 +30,14 @@ public class Episode implements Serializable {
} }
public Episode(String seriesName, Integer season, Integer episode, String title) { public Episode(String seriesName, Date seriesStartDate, Integer season, Integer episode, String title) {
this(seriesName, season, episode, title, null, null, null); 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.seriesName = seriesName;
this.seriesStartDate = seriesStartDate;
this.season = season; this.season = season;
this.episode = episode; this.episode = episode;
this.title = title; this.title = title;
@ -49,6 +52,11 @@ public class Episode implements Serializable {
} }
public Date getSeriesStartDate() {
return seriesStartDate;
}
public Integer getEpisode() { public Integer getEpisode() {
return episode; return episode;
} }

View File

@ -94,7 +94,7 @@ public class EpisodeFormat extends Format {
// did parse input // did parse input
pos.setIndex(source.length()); 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 // failed to parse input

View File

@ -46,9 +46,7 @@ public class IMDbClient extends AbstractEpisodeListProvider {
@Override @Override
public List<SearchResult> search(String query, Locale locale) throws IOException, SAXException { 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")); URL searchUrl = new URL("http", host, "/find?s=tt&q=" + URLEncoder.encode(query, "UTF-8"));
Document dom = getHtmlDocument(openConnection(searchUrl)); Document dom = getHtmlDocument(openConnection(searchUrl));
List<Node> nodes = selectNodes("//TABLE//A[following-sibling::SMALL[contains(.,'series')]]", dom); 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())); Document dom = getHtmlDocument(openConnection(getEpisodeListLink(searchResult).toURL()));
String seriesName = normalizeName(selectString("//H1/A", dom)); 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); List<Node> nodes = selectNodes("//TABLE//H3/A[preceding-sibling::text()]", dom);
@ -98,9 +97,9 @@ public class IMDbClient extends AbstractEpisodeListProvider {
Integer episode = numberScanner.nextInt(); Integer episode = numberScanner.nextInt();
// e.g. 20 May 2003 // 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; return episodes;

View File

@ -72,6 +72,7 @@ public class TVRageClient extends AbstractEpisodeListProvider {
Document dom = getDocument(episodeListUrl); Document dom = getDocument(episodeListUrl);
String seriesName = selectString("Show/name", dom); 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> episodes = new ArrayList<Episode>(25);
List<Episode> specials = new ArrayList<Episode>(5); List<Episode> specials = new ArrayList<Episode>(5);
@ -89,10 +90,10 @@ public class TVRageClient extends AbstractEpisodeListProvider {
// handle as special episode // handle as special episode
seasonNumber = getIntegerContent("season", node); seasonNumber = getIntegerContent("season", node);
int specialNumber = filterBySeason(specials, seasonNumber).size() + 1; 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 { } else {
// handle as normal episode // 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));
} }
} }

View File

@ -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 // 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); 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); List<Node> nodes = selectNodes("Data/Episode", seriesRecord);
@ -150,10 +151,10 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
} }
Integer specialNumber = filterBySeason(specials, seasonNumber).size() + 1; 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 { } else {
// handle as normal episode // 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) { if (episodeNumber == 1) {

View File

@ -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 { public static ByteBuffer fetchIfModified(URL resource, long ifModifiedSince) throws IOException {
return fetch(resource, ifModifiedSince, null); return fetch(resource, ifModifiedSince, null);
} }

View File

@ -41,7 +41,7 @@ public class AnidbClientTest {
} }
private AnidbClient anidb = new AnidbClient("filebot", 1); private AnidbClient anidb = new AnidbClient("filebot", 2);
@Test @Test
@ -83,6 +83,7 @@ public class AnidbClientTest {
Episode first = list.get(0); Episode first = list.get(0);
assertEquals("Monster", first.getSeriesName()); assertEquals("Monster", first.getSeriesName());
assertEquals("2004-04-07", first.getSeriesStartDate().toString());
assertEquals("Herr Dr. Tenma", first.getTitle()); assertEquals("Herr Dr. Tenma", first.getTitle());
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getAbsolute().toString()); assertEquals("1", first.getAbsolute().toString());
@ -100,6 +101,7 @@ public class AnidbClientTest {
Episode first = list.get(0); Episode first = list.get(0);
assertEquals("The Twelve Kingdoms", first.getSeriesName()); 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("Shadow of the Moon, The Sea of Shadow - Chapter 1", first.getTitle());
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getAbsolute().toString()); assertEquals("1", first.getAbsolute().toString());
@ -120,6 +122,7 @@ public class AnidbClientTest {
Episode last = list.get(73); Episode last = list.get(73);
assertEquals("モンスター", last.getSeriesName()); assertEquals("モンスター", last.getSeriesName());
assertEquals("2004-04-07", last.getSeriesStartDate().toString());
assertEquals("本当の怪物", last.getTitle()); assertEquals("本当の怪物", last.getTitle());
assertEquals("74", last.getEpisode().toString()); assertEquals("74", last.getEpisode().toString());
assertEquals("74", last.getAbsolute().toString()); assertEquals("74", last.getAbsolute().toString());

View File

@ -71,6 +71,7 @@ public class IMDbClientTest {
Episode first = list.get(0); Episode first = list.get(0);
assertEquals("Buffy the Vampire Slayer", first.getSeriesName()); assertEquals("Buffy the Vampire Slayer", first.getSeriesName());
assertEquals("1997-00-00", first.getSeriesStartDate().toString());
assertEquals("Unaired Pilot", first.getTitle()); assertEquals("Unaired Pilot", first.getTitle());
assertEquals("0", first.getEpisode().toString()); assertEquals("0", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());
@ -79,6 +80,7 @@ public class IMDbClientTest {
Episode last = list.get(144); Episode last = list.get(144);
assertEquals("Buffy the Vampire Slayer", last.getSeriesName()); assertEquals("Buffy the Vampire Slayer", last.getSeriesName());
assertEquals("1997-00-00", first.getSeriesStartDate().toString());
assertEquals("Chosen", last.getTitle()); assertEquals("Chosen", last.getTitle());
assertEquals("22", last.getEpisode().toString()); assertEquals("22", last.getEpisode().toString());
assertEquals("7", last.getSeason().toString()); assertEquals("7", last.getSeason().toString());
@ -95,6 +97,7 @@ public class IMDbClientTest {
Episode first = list.get(0); Episode first = list.get(0);
assertEquals("Mushi-Shi", first.getSeriesName()); assertEquals("Mushi-Shi", first.getSeriesName());
assertEquals("2005-00-00", first.getSeriesStartDate().toString());
assertEquals("Midori no za", first.getTitle()); assertEquals("Midori no za", first.getTitle());
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());

View File

@ -43,6 +43,7 @@ public class TVRageClientTest {
Episode chosen = list.get(21); Episode chosen = list.get(21);
assertEquals("Buffy the Vampire Slayer", chosen.getSeriesName()); assertEquals("Buffy the Vampire Slayer", chosen.getSeriesName());
assertEquals("2002-04-09", chosen.getSeriesStartDate().toString());
assertEquals("Chosen", chosen.getTitle()); assertEquals("Chosen", chosen.getTitle());
assertEquals("22", chosen.getEpisode().toString()); assertEquals("22", chosen.getEpisode().toString());
assertEquals("7", chosen.getSeason().toString()); assertEquals("7", chosen.getSeason().toString());

View File

@ -38,19 +38,14 @@ public class TheTVDBClientTest {
@Test @Test
public void searchGerman() throws Exception { 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); TheTVDBSearchResult first = (TheTVDBSearchResult) results.get(0);
assertEquals("Buffy", first.getName()); assertEquals("Buffy the Vampire Slayer", first.getName());
assertEquals(70327, first.getSeriesId()); 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 // check ordinary episode
Episode first = list.get(0); Episode first = list.get(0);
assertEquals("Buffy the Vampire Slayer", first.getSeriesName()); assertEquals("Buffy the Vampire Slayer", first.getSeriesName());
assertEquals("1997-03-10", first.getSeriesStartDate().toString());
assertEquals("Welcome to the Hellmouth (1)", first.getTitle()); assertEquals("Welcome to the Hellmouth (1)", first.getTitle());
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());
@ -90,6 +86,7 @@ public class TheTVDBClientTest {
Episode first = list.get(0); Episode first = list.get(0);
assertEquals("Wonderfalls", first.getSeriesName()); assertEquals("Wonderfalls", first.getSeriesName());
assertEquals("2004-03-12", first.getSeriesStartDate().toString());
assertEquals("Wax Lion", first.getTitle()); assertEquals("Wax Lion", first.getTitle());
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());
@ -106,6 +103,7 @@ public class TheTVDBClientTest {
Episode first = list.get(0); Episode first = list.get(0);
assertEquals("Firefly", first.getSeriesName()); assertEquals("Firefly", first.getSeriesName());
assertEquals("2002-09-20", first.getSeriesStartDate().toString());
assertEquals("Serenity", first.getTitle()); assertEquals("Serenity", first.getTitle());
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());

View File

@ -119,6 +119,11 @@
<td>series/movie name</td> <td>series/movie name</td>
<td>Dark Angel</td> <td>Dark Angel</td>
</tr> </tr>
<tr>
<td>y</td>
<td>series/movie year</td>
<td>2009</td>
</tr>
<tr> <tr>
<td>s</td> <td>s</td>
<td>season number</td> <td>season number</td>
@ -134,11 +139,6 @@
<td>episode title</td> <td>episode title</td>
<td>Labyrinth</td> <td>Labyrinth</td>
</tr> </tr>
<tr>
<td>y</td>
<td>episode/movie year</td>
<td>2009</td>
</tr>
<tr> <tr>
<td>airdate</td> <td>airdate</td>
<td>episode airdate</td> <td>episode airdate</td>