+ store series info with each episode object and add new bindings {series} {primaryTitle} and {json} for debugging the info object

This commit is contained in:
Reinhard Pointner 2013-07-13 10:01:33 +00:00
parent 99a6eb916e
commit e771cf39a5
21 changed files with 335 additions and 308 deletions

View File

@ -23,6 +23,7 @@ import java.util.logging.Logger;
import net.sourceforge.filebot.media.MediaDetection; import net.sourceforge.filebot.media.MediaDetection;
import net.sourceforge.filebot.web.AcoustID; import net.sourceforge.filebot.web.AcoustID;
import net.sourceforge.filebot.web.AnidbClient; import net.sourceforge.filebot.web.AnidbClient;
import net.sourceforge.filebot.web.AnidbSearchResult;
import net.sourceforge.filebot.web.EpisodeListProvider; import net.sourceforge.filebot.web.EpisodeListProvider;
import net.sourceforge.filebot.web.FanartTV; import net.sourceforge.filebot.web.FanartTV;
import net.sourceforge.filebot.web.ID3Lookup; import net.sourceforge.filebot.web.ID3Lookup;
@ -37,6 +38,7 @@ import net.sourceforge.filebot.web.SubtitleProvider;
import net.sourceforge.filebot.web.TMDbClient; import net.sourceforge.filebot.web.TMDbClient;
import net.sourceforge.filebot.web.TVRageClient; import net.sourceforge.filebot.web.TVRageClient;
import net.sourceforge.filebot.web.TheTVDBClient; import net.sourceforge.filebot.web.TheTVDBClient;
import net.sourceforge.filebot.web.TheTVDBSearchResult;
import net.sourceforge.filebot.web.VideoHashSubtitleService; import net.sourceforge.filebot.web.VideoHashSubtitleService;

View File

@ -35,16 +35,21 @@ import net.sourceforge.filebot.media.MetaAttributes;
import net.sourceforge.filebot.mediainfo.MediaInfo; import net.sourceforge.filebot.mediainfo.MediaInfo;
import net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind; import net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind;
import net.sourceforge.filebot.similarity.SimilarityComparator; import net.sourceforge.filebot.similarity.SimilarityComparator;
import net.sourceforge.filebot.web.AnidbSearchResult;
import net.sourceforge.filebot.web.AudioTrack; import net.sourceforge.filebot.web.AudioTrack;
import net.sourceforge.filebot.web.Date; import net.sourceforge.filebot.web.Date;
import net.sourceforge.filebot.web.Episode; import net.sourceforge.filebot.web.Episode;
import net.sourceforge.filebot.web.Movie; import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.MoviePart; import net.sourceforge.filebot.web.MoviePart;
import net.sourceforge.filebot.web.MultiEpisode; import net.sourceforge.filebot.web.MultiEpisode;
import net.sourceforge.filebot.web.SearchResult;
import net.sourceforge.filebot.web.SortOrder; import net.sourceforge.filebot.web.SortOrder;
import net.sourceforge.filebot.web.TheTVDBSearchResult;
import net.sourceforge.tuned.FileUtilities; import net.sourceforge.tuned.FileUtilities;
import net.sourceforge.tuned.FileUtilities.ExtensionFileFilter; import net.sourceforge.tuned.FileUtilities.ExtensionFileFilter;
import com.cedarsoftware.util.io.JsonWriter;
public class MediaBindingBean { public class MediaBindingBean {
@ -153,7 +158,7 @@ public class MediaBindingBean {
@Define("d") @Define("d")
public Object getReleaseDate() { public Object getReleaseDate() {
if (infoObject instanceof Episode) { if (infoObject instanceof Episode) {
return getEpisode().airdate(); return getEpisode().getAirdate();
} }
if (infoObject instanceof Movie) { if (infoObject instanceof Movie) {
return getMetaInfo().getProperty("released"); return getMetaInfo().getProperty("released");
@ -169,7 +174,7 @@ public class MediaBindingBean {
@Define("airdate") @Define("airdate")
public Date airdate() { public Date airdate() {
return getEpisode().airdate(); return getEpisode().getAirdate();
} }
@ -191,6 +196,27 @@ public class MediaBindingBean {
} }
@Define("series")
public SearchResult getSeriesObject() {
return getEpisode().getSeries();
}
@Define("primaryTitle")
public String getOfficialTitle() throws Exception {
System.out.println(getSeriesObject());
if (getSeriesObject() instanceof TheTVDBSearchResult) {
return WebServices.TheTVDB.getSeriesInfo((TheTVDBSearchResult) getSeriesObject(), Locale.ENGLISH).getName();
}
if (getSeriesObject() instanceof AnidbSearchResult) {
return ((AnidbSearchResult) getSeriesObject()).getPrimaryTitle();
}
// default to original search result
return getSeriesObject().getName();
}
@Define("tmdbid") @Define("tmdbid")
public String getTmdbId() throws Exception { public String getTmdbId() throws Exception {
int tmdbid = getMovie().getTmdbId(); int tmdbid = getMovie().getTmdbId();
@ -682,6 +708,12 @@ public class MediaBindingBean {
} }
@Define("json")
public String getInfoObjectDump() throws Exception {
return JsonWriter.objectToJson(infoObject);
}
private File getInferredMediaFile() { private File getInferredMediaFile() {
// make sure media file is defined // make sure media file is defined
checkMediaFile(); checkMediaFile();

View File

@ -52,14 +52,14 @@ import net.sourceforge.filebot.similarity.SequenceMatchSimilarity;
import net.sourceforge.filebot.similarity.SeriesNameMatcher; import net.sourceforge.filebot.similarity.SeriesNameMatcher;
import net.sourceforge.filebot.similarity.SimilarityComparator; import net.sourceforge.filebot.similarity.SimilarityComparator;
import net.sourceforge.filebot.similarity.SimilarityMetric; import net.sourceforge.filebot.similarity.SimilarityMetric;
import net.sourceforge.filebot.web.AnidbClient.AnidbSearchResult; import net.sourceforge.filebot.web.AnidbSearchResult;
import net.sourceforge.filebot.web.Date; import net.sourceforge.filebot.web.Date;
import net.sourceforge.filebot.web.Episode; import net.sourceforge.filebot.web.Episode;
import net.sourceforge.filebot.web.Movie; import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.MovieIdentificationService; import net.sourceforge.filebot.web.MovieIdentificationService;
import net.sourceforge.filebot.web.SearchResult; import net.sourceforge.filebot.web.SearchResult;
import net.sourceforge.filebot.web.TheTVDBClient.SeriesInfo; import net.sourceforge.filebot.web.TheTVDBClient.SeriesInfo;
import net.sourceforge.filebot.web.TheTVDBClient.TheTVDBSearchResult; import net.sourceforge.filebot.web.TheTVDBSearchResult;
public class MediaDetection { public class MediaDetection {
@ -1007,8 +1007,8 @@ public class MediaDetection {
try { try {
if (model instanceof Episode) { if (model instanceof Episode) {
Episode episode = (Episode) model; Episode episode = (Episode) model;
if (episode.airdate() != null) { if (episode.getAirdate() != null) {
xattr.setCreationDate(episode.airdate().getTimeStamp()); xattr.setCreationDate(episode.getAirdate().getTimeStamp());
} }
} else if (model instanceof Movie) { } else if (model instanceof Movie) {
Movie movie = (Movie) model; Movie movie = (Movie) model;

View File

@ -33,10 +33,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import net.sourceforge.filebot.web.AnidbClient.AnidbSearchResult; import net.sourceforge.filebot.web.AnidbSearchResult;
import net.sourceforge.filebot.web.CachedResource; import net.sourceforge.filebot.web.CachedResource;
import net.sourceforge.filebot.web.Movie; import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.TheTVDBClient.TheTVDBSearchResult; import net.sourceforge.filebot.web.TheTVDBSearchResult;
import net.sourceforge.tuned.ByteBufferInputStream; import net.sourceforge.tuned.ByteBufferInputStream;
@ -357,7 +357,7 @@ public class ReleaseInfo {
if (englishTitle.isEmpty() || englishTitle.equals(primaryTitle)) { if (englishTitle.isEmpty() || englishTitle.equals(primaryTitle)) {
anime.add(new AnidbSearchResult(aid, primaryTitle, null)); anime.add(new AnidbSearchResult(aid, primaryTitle, null));
} else { } else {
anime.add(new AnidbSearchResult(aid, primaryTitle, singletonMap("en", englishTitle))); anime.add(new AnidbSearchResult(aid, primaryTitle, englishTitle));
} }
} }

View File

@ -92,7 +92,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
Episode episode = (Episode) object; Episode episode = (Episode) object;
// use airdate from episode // use airdate from episode
return episode.airdate(); return episode.getAirdate();
} }
Date result = transformCache.get(object); Date result = transformCache.get(object);
@ -454,7 +454,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
public long getTimeStamp(Object object) { public long getTimeStamp(Object object) {
if (object instanceof Episode) { if (object instanceof Episode) {
try { try {
long ts = ((Episode) object).airdate().getTimeStamp(); long ts = ((Episode) object).getAirdate().getTimeStamp();
// big penalty for episodes not yet aired // big penalty for episodes not yet aired
if (ts > System.currentTimeMillis()) { if (ts > System.currentTimeMillis()) {

View File

@ -4,7 +4,7 @@ episode.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 name,
movie.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 name, <b>y</b> \u2026 year</html> movie.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 name, <b>y</b> \u2026 year</html>
music.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 album artist, <b>t</b> \u2026 title, <b>album</b> \u2026 album, <b>pi</b> \u2026 track</html> music.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 album artist, <b>t</b> \u2026 title, <b>album</b> \u2026 album, <b>pi</b> \u2026 track</html>
episode.sample: {"@type":"net.sourceforge.filebot.web.Episode","seriesName":"Firefly","seriesStartDate":{"year":2002,"month":9,"day":20},"season":1,"episode":1,"title":"Serenity","absolute":1,"special":null,"airdate":{"year":2002,"month":12,"day":20}} episode.sample: {"@type":"net.sourceforge.filebot.web.Episode","seriesName":"Firefly","seriesStartDate":{"year":2002,"month":9,"day":20},"season":1,"episode":1,"title":"Serenity","absolute":1,"special":null,"airdate":{"year":2002,"month":12,"day":20},"series":{"@type":"net.sourceforge.filebot.web.TheTVDBSearchResult","seriesId":78874,"name":"Firefly"}}
movie.sample: {"@type":"net.sourceforge.filebot.web.MoviePart","partIndex":1,"partCount":2,"year":2009,"imdbId":-1,"tmdbId":19995,"name":"Avatar"} movie.sample: {"@type":"net.sourceforge.filebot.web.MoviePart","partIndex":1,"partCount":2,"year":2009,"imdbId":-1,"tmdbId":19995,"name":"Avatar"}
music.sample: {"@type":"net.sourceforge.filebot.web.AudioTrack","artist":"Leona Lewis","title":"I See You","album":"Avatar","albumArtist":"James Horner","trackTitle":null,"albumReleaseDate":{"year":2009,"month":12,"day":11},"mediumIndex":1,"mediumCount":1,"trackIndex":14,"trackCount":14} music.sample: {"@type":"net.sourceforge.filebot.web.AudioTrack","artist":"Leona Lewis","title":"I See You","album":"Avatar","albumArtist":"James Horner","trackTitle":null,"albumReleaseDate":{"year":2009,"month":12,"day":11},"mediumIndex":1,"mediumCount":1,"trackIndex":14,"trackCount":14}

View File

@ -133,9 +133,9 @@ public class AnidbClient extends AbstractEpisodeListProvider {
} }
if (type == 1) { if (type == 1) {
episodes.add(new Episode(animeTitle, seriesStartDate, null, number, title, number, null, airdate)); // normal episode, no seasons for anime episodes.add(new Episode(animeTitle, seriesStartDate, null, number, title, number, null, airdate, searchResult)); // normal episode, no seasons for anime
} else { } else {
episodes.add(new Episode(animeTitle, seriesStartDate, null, null, title, null, number, airdate)); // special episode episodes.add(new Episode(animeTitle, seriesStartDate, null, null, title, null, number, airdate, searchResult)); // special episode
} }
} }
} }
@ -224,74 +224,11 @@ public class AnidbClient extends AbstractEpisodeListProvider {
localizedTitles.putAll(officialTitleMap.get(entry.getKey())); // primarily use official title if available localizedTitles.putAll(officialTitleMap.get(entry.getKey())); // primarily use official title if available
} }
anime.add(new AnidbSearchResult(entry.getKey(), entry.getValue(), localizedTitles)); anime.add(new AnidbSearchResult(entry.getKey(), entry.getValue(), localizedTitles.get("en")));
} }
// populate cache // populate cache
return cache.putSearchResult(null, Locale.ROOT, anime); return cache.putSearchResult(null, Locale.ROOT, anime);
} }
public static class AnidbSearchResult extends SearchResult {
protected int aid;
protected String primaryTitle; // one per anime
protected Map<String, String> officialTitle; // one per language
protected AnidbSearchResult() {
// used by serializer
}
public AnidbSearchResult(int aid, String primaryTitle, Map<String, String> officialTitle) {
this.aid = aid;
this.primaryTitle = primaryTitle;
this.officialTitle = officialTitle;
}
public int getAnimeId() {
return aid;
}
@Override
public String getName() {
return primaryTitle;
}
public String getPrimaryTitle() {
return primaryTitle;
}
public String getEnglishTitle() {
return officialTitle != null ? officialTitle.get("en") : null;
}
public String getOfficialTitle(String key) {
return officialTitle != null ? officialTitle.get(key) : null;
}
@Override
public int hashCode() {
return aid;
}
@Override
public boolean equals(Object object) {
if (object instanceof AnidbSearchResult) {
AnidbSearchResult other = (AnidbSearchResult) object;
return this.aid == other.aid;
}
return false;
}
}
} }

View File

@ -0,0 +1,65 @@
package net.sourceforge.filebot.web;
public class AnidbSearchResult extends SearchResult {
protected int aid;
protected String primaryTitle; // one per anime
protected String englishTitle; // one per language
protected AnidbSearchResult() {
// used by serializer
}
public AnidbSearchResult(int aid, String primaryTitle, String englishTitle) {
this.aid = aid;
this.primaryTitle = primaryTitle;
this.englishTitle = englishTitle;
}
public int getId() {
return aid;
}
public int getAnimeId() {
return aid;
}
@Override
public String getName() {
return primaryTitle;
}
public String getPrimaryTitle() {
return primaryTitle;
}
public String getEnglishTitle() {
return englishTitle;
}
@Override
public int hashCode() {
return aid;
}
@Override
public boolean equals(Object object) {
if (object instanceof AnidbSearchResult) {
AnidbSearchResult other = (AnidbSearchResult) object;
return this.aid == other.aid;
}
return false;
}
}

View File

@ -24,6 +24,9 @@ public class Episode implements Serializable {
// episode airdate // episode airdate
private Date airdate; private Date airdate;
// original series descriptor
private SearchResult series;
protected Episode() { protected Episode() {
// used by serializer // used by serializer
@ -31,16 +34,16 @@ public class Episode implements Serializable {
public Episode(Episode obj) { public Episode(Episode obj) {
this(obj.seriesName, obj.seriesStartDate, obj.season, obj.episode, obj.title, obj.absolute, obj.special, obj.airdate); this(obj.seriesName, obj.seriesStartDate, obj.season, obj.episode, obj.title, obj.absolute, obj.special, obj.airdate, obj.series);
} }
public Episode(String seriesName, Date seriesStartDate, Integer season, Integer episode, String title) { public Episode(String seriesName, Date seriesStartDate, Integer season, Integer episode, String title, SearchResult series) {
this(seriesName, seriesStartDate, season, episode, title, null, null, null); this(seriesName, seriesStartDate, season, episode, title, null, null, null, series);
} }
public Episode(String seriesName, Date seriesStartDate, 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, SearchResult series) {
this.seriesName = seriesName; this.seriesName = seriesName;
this.seriesStartDate = seriesStartDate; this.seriesStartDate = seriesStartDate;
this.season = season; this.season = season;
@ -49,6 +52,7 @@ public class Episode implements Serializable {
this.absolute = absolute; this.absolute = absolute;
this.special = special; this.special = special;
this.airdate = airdate; this.airdate = airdate;
this.series = series;
} }
@ -87,11 +91,16 @@ public class Episode implements Serializable {
} }
public Date airdate() { public Date getAirdate() {
return airdate; return airdate;
} }
public SearchResult getSeries() {
return series;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof Episode) { if (obj instanceof Episode) {

View File

@ -63,8 +63,8 @@ public class EpisodeFormat extends Format {
sb.append(" - ").append(episode.getTitle()); sb.append(" - ").append(episode.getTitle());
if (includeAirdate && episode.airdate() != null) { if (includeAirdate && episode.getAirdate() != null) {
sb.append(" [").append(episode.airdate().format("yyyy-MM-dd")).append("]"); sb.append(" [").append(episode.getAirdate().format("yyyy-MM-dd")).append("]");
} }
return sb; return sb;
@ -195,7 +195,7 @@ public class EpisodeFormat extends Format {
// did parse input // did parse input
pos.setIndex(source.length()); pos.setIndex(source.length());
return new Episode(name, null, season, episode, title, season == null ? episode : null, special, airdate); return new Episode(name, null, season, episode, title, season == null ? episode : null, special, airdate, null);
} }
// failed to parse input // failed to parse input

View File

@ -143,7 +143,7 @@ public class SerienjunkiesClient extends AbstractEpisodeListProvider {
title = ""; title = "";
} }
episodes.add(new Episode(seriesName, series.getStartDate(), season, episode, title, i + 1, null, airdate)); episodes.add(new Episode(seriesName, series.getStartDate(), season, episode, title, i + 1, null, airdate, searchResult));
} }
// make sure episodes are in ordered correctly // make sure episodes are in ordered correctly
@ -175,76 +175,4 @@ public class SerienjunkiesClient extends AbstractEpisodeListProvider {
return URI.create(String.format("http://www.serienjunkies.de/%s/alle-serien-staffeln.html", ((SerienjunkiesSearchResult) searchResult).getLink())); return URI.create(String.format("http://www.serienjunkies.de/%s/alle-serien-staffeln.html", ((SerienjunkiesSearchResult) searchResult).getLink()));
} }
public static class SerienjunkiesSearchResult extends SearchResult {
protected int sid;
protected String link;
protected String mainTitle;
protected String germanTitle;
protected Date startDate;
protected SerienjunkiesSearchResult() {
// used by serializer
}
public SerienjunkiesSearchResult(int sid, String link, String mainTitle, String germanTitle, Date startDate) {
this.sid = sid;
this.link = link;
this.mainTitle = mainTitle;
this.germanTitle = germanTitle;
this.startDate = startDate;
}
@Override
public String getName() {
return germanTitle != null ? germanTitle : mainTitle; // prefer German title
}
public int getSeriesId() {
return sid;
}
public String getLink() {
return link;
}
public String getMainTitle() {
return mainTitle;
}
public String getGermanTitle() {
return germanTitle;
}
public Date getStartDate() {
return startDate;
}
@Override
public int hashCode() {
return sid;
}
@Override
public boolean equals(Object object) {
if (object instanceof SerienjunkiesSearchResult) {
SerienjunkiesSearchResult other = (SerienjunkiesSearchResult) object;
return this.sid == other.sid;
}
return false;
}
}
} }

View File

@ -0,0 +1,79 @@
package net.sourceforge.filebot.web;
public class SerienjunkiesSearchResult extends SearchResult {
protected int sid;
protected String link;
protected String mainTitle;
protected String germanTitle;
protected Date startDate;
protected SerienjunkiesSearchResult() {
// used by serializer
}
public SerienjunkiesSearchResult(int sid, String link, String mainTitle, String germanTitle, Date startDate) {
this.sid = sid;
this.link = link;
this.mainTitle = mainTitle;
this.germanTitle = germanTitle;
this.startDate = startDate;
}
public int getId() {
return sid;
}
@Override
public String getName() {
return germanTitle != null ? germanTitle : mainTitle; // prefer German title
}
public int getSeriesId() {
return sid;
}
public String getLink() {
return link;
}
public String getMainTitle() {
return mainTitle;
}
public String getGermanTitle() {
return germanTitle;
}
public Date getStartDate() {
return startDate;
}
@Override
public int hashCode() {
return sid;
}
@Override
public boolean equals(Object object) {
if (object instanceof SerienjunkiesSearchResult) {
SerienjunkiesSearchResult other = (SerienjunkiesSearchResult) object;
return this.sid == other.sid;
}
return false;
}
}

View File

@ -92,7 +92,7 @@ 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, seriesStartDate, seasonNumber, null, title, null, specialNumber, airdate)); specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, title, null, specialNumber, airdate, searchResult));
} else { } else {
// handle as normal episode // handle as normal episode
if (sortOrder == SortOrder.Absolute) { if (sortOrder == SortOrder.Absolute) {
@ -100,7 +100,7 @@ public class TVRageClient extends AbstractEpisodeListProvider {
seasonNumber = null; seasonNumber = null;
} }
episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, title, null, null, airdate)); episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, title, null, null, airdate, searchResult));
} }
} }
@ -116,50 +116,4 @@ public class TVRageClient extends AbstractEpisodeListProvider {
return URI.create(((TVRageSearchResult) searchResult).getLink() + "/episode_list/all"); return URI.create(((TVRageSearchResult) searchResult).getLink() + "/episode_list/all");
} }
public static class TVRageSearchResult extends SearchResult {
protected int showId;
protected String link;
protected TVRageSearchResult() {
// used by serializer
}
public TVRageSearchResult(String name, int showId, String link) {
super(name);
this.showId = showId;
this.link = link;
}
public int getSeriesId() {
return showId;
}
public String getLink() {
return link;
}
@Override
public int hashCode() {
return showId;
}
@Override
public boolean equals(Object object) {
if (object instanceof TVRageSearchResult) {
TVRageSearchResult other = (TVRageSearchResult) object;
return this.showId == other.showId;
}
return false;
}
}
} }

View File

@ -0,0 +1,53 @@
package net.sourceforge.filebot.web;
public class TVRageSearchResult extends SearchResult {
protected int showId;
protected String link;
protected TVRageSearchResult() {
// used by serializer
}
public TVRageSearchResult(String name, int showId, String link) {
super(name);
this.showId = showId;
this.link = link;
}
public int getId() {
return showId;
}
public int getSeriesId() {
return showId;
}
public String getLink() {
return link;
}
@Override
public int hashCode() {
return showId;
}
@Override
public boolean equals(Object object) {
if (object instanceof TVRageSearchResult) {
TVRageSearchResult other = (TVRageSearchResult) object;
return this.showId == other.showId;
}
return false;
}
}

View File

@ -159,7 +159,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
// use given episode number as special number or count specials by ourselves // use given episode number as special number or count specials by ourselves
Integer specialNumber = (episodeNumber != null) ? episodeNumber : filterBySeason(specials, seasonNumber).size() + 1; Integer specialNumber = (episodeNumber != null) ? episodeNumber : filterBySeason(specials, seasonNumber).size() + 1;
specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, episodeName, null, specialNumber, airdate)); specials.add(new Episode(seriesName, seriesStartDate, seasonNumber, null, episodeName, null, specialNumber, airdate, searchResult));
} else { } else {
// handle as normal episode // handle as normal episode
if (sortOrder == SortOrder.Absolute) { if (sortOrder == SortOrder.Absolute) {
@ -176,7 +176,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
} }
} }
episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, episodeName, absoluteNumber, null, airdate)); episodes.add(new Episode(seriesName, seriesStartDate, seasonNumber, episodeNumber, episodeName, absoluteNumber, null, airdate, searchResult));
} }
} }
@ -339,45 +339,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
} }
public static class TheTVDBSearchResult extends SearchResult {
protected int seriesId;
protected TheTVDBSearchResult() {
// used by serializer
}
public TheTVDBSearchResult(String seriesName, int seriesId) {
super(seriesName);
this.seriesId = seriesId;
}
public int getSeriesId() {
return seriesId;
}
@Override
public int hashCode() {
return seriesId;
}
@Override
public boolean equals(Object object) {
if (object instanceof TheTVDBSearchResult) {
TheTVDBSearchResult other = (TheTVDBSearchResult) object;
return this.seriesId == other.seriesId;
}
return false;
}
}
protected static enum MirrorType { protected static enum MirrorType {
XML(1), BANNER(2), ZIP(4), SEARCH(1); XML(1), BANNER(2), ZIP(4), SEARCH(1);
@ -457,26 +418,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
public static class SeriesInfo implements Serializable { public static class SeriesInfo implements Serializable {
public static enum SeriesProperty { public static enum SeriesProperty {
id, id, Actors, Airs_DayOfWeek, Airs_Time, ContentRating, FirstAired, Genre, IMDB_ID, Language, Network, Overview, Rating, RatingCount, Runtime, SeriesName, Status, BannerMirror, banner, fanart, poster
Actors,
Airs_DayOfWeek,
Airs_Time,
ContentRating,
FirstAired,
Genre,
IMDB_ID,
Language,
Network,
Overview,
Rating,
RatingCount,
Runtime,
SeriesName,
Status,
BannerMirror,
banner,
fanart,
poster
} }
protected Map<SeriesProperty, String> fields; protected Map<SeriesProperty, String> fields;
@ -746,19 +688,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
public static class BannerDescriptor implements Serializable { public static class BannerDescriptor implements Serializable {
public static enum BannerProperty { public static enum BannerProperty {
id, id, BannerMirror, BannerPath, BannerType, BannerType2, Season, Colors, Language, Rating, RatingCount, SeriesName, ThumbnailPath, VignettePath
BannerMirror,
BannerPath,
BannerType,
BannerType2,
Season,
Colors,
Language,
Rating,
RatingCount,
SeriesName,
ThumbnailPath,
VignettePath
} }
protected Map<BannerProperty, String> fields; protected Map<BannerProperty, String> fields;

View File

@ -0,0 +1,46 @@
package net.sourceforge.filebot.web;
public class TheTVDBSearchResult extends SearchResult {
protected int seriesId;
protected TheTVDBSearchResult() {
// used by serializer
}
public TheTVDBSearchResult(String seriesName, int seriesId) {
super(seriesName);
this.seriesId = seriesId;
}
public int getId() {
return seriesId;
}
public int getSeriesId() {
return seriesId;
}
@Override
public int hashCode() {
return seriesId;
}
@Override
public boolean equals(Object object) {
if (object instanceof TheTVDBSearchResult) {
TheTVDBSearchResult other = (TheTVDBSearchResult) object;
return this.seriesId == other.seriesId;
}
return false;
}
}

View File

@ -9,21 +9,17 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Test;
import net.sourceforge.filebot.similarity.EpisodeMetrics;
import net.sourceforge.filebot.similarity.Match;
import net.sourceforge.filebot.similarity.Matcher;
import net.sourceforge.filebot.similarity.SimilarityMetric;
import net.sourceforge.filebot.web.Date; import net.sourceforge.filebot.web.Date;
import net.sourceforge.filebot.web.Episode; import net.sourceforge.filebot.web.Episode;
import org.junit.Test;
public class EpisodeMetricsTest { public class EpisodeMetricsTest {
@Test @Test
public void substringMetrics() { public void substringMetrics() {
Episode eY1T1 = new Episode("Doctor Who", new Date(2005, 0, 0), 1, 1, "Rose"); Episode eY1T1 = new Episode("Doctor Who", new Date(2005, 0, 0), 1, 1, "Rose", null);
// Episode eY2T2 = new Episode("Doctor Who", new Date(1963, 0, 0), 1, 1, "An Unearthly Child"); // Episode eY2T2 = new Episode("Doctor Who", new Date(1963, 0, 0), 1, 1, "An Unearthly Child");
File fY1T1 = new File("Doctor Who (2005)/Doctor Who - 1x01 - Rose"); File fY1T1 = new File("Doctor Who (2005)/Doctor Who - 1x01 - Rose");
File fY2T2 = new File("Doctor Who (1963)/Doctor Who - 1x01 - An Unearthly Child"); File fY2T2 = new File("Doctor Who (1963)/Doctor Who - 1x01 - An Unearthly Child");
@ -32,25 +28,25 @@ public class EpisodeMetricsTest {
assertEquals(2.0 / 3, SubstringFields.getSimilarity(eY1T1, fY2T2), 0.01); assertEquals(2.0 / 3, SubstringFields.getSimilarity(eY1T1, fY2T2), 0.01);
} }
@Test @Test
public void nameIgnoreEmbeddedChecksum() { public void nameIgnoreEmbeddedChecksum() {
assertEquals(1, Name.getSimilarity("test", "test [EF62DF13]"), 0); assertEquals(1, Name.getSimilarity("test", "test [EF62DF13]"), 0);
} }
@Test @Test
public void numericIgnoreEmbeddedChecksum() { public void numericIgnoreEmbeddedChecksum() {
assertEquals(1, Numeric.getSimilarity("S01E02", "Season 1, Episode 2 [00A01E02]"), 0); assertEquals(1, Numeric.getSimilarity("S01E02", "Season 1, Episode 2 [00A01E02]"), 0);
} }
@Test @Test
public void normalizeFile() { public void normalizeFile() {
assertEquals("abc", EpisodeMetrics.normalizeObject(new File("/folder/abc[EF62DF13].txt"))); assertEquals("abc", EpisodeMetrics.normalizeObject(new File("/folder/abc[EF62DF13].txt")));
} }
@Test @Test
public void matcherLevel2() throws Exception { public void matcherLevel2() throws Exception {
List<File> files = new ArrayList<File>(); List<File> files = new ArrayList<File>();
@ -58,8 +54,8 @@ public class EpisodeMetricsTest {
files.add(new File("Greek/Greek - S01E19 - No Campus for Old Rules")); files.add(new File("Greek/Greek - S01E19 - No Campus for Old Rules"));
files.add(new File("Veronica Mars - Season 1/Veronica Mars [1x19] Hot Dogs")); files.add(new File("Veronica Mars - Season 1/Veronica Mars [1x19] Hot Dogs"));
episodes.add(new Episode("Veronica Mars", null, 1, 19, "Hot Dogs")); episodes.add(new Episode("Veronica Mars", null, 1, 19, "Hot Dogs", null));
episodes.add(new Episode("Greek", null, 1, 19, "No Campus for Old Rules")); episodes.add(new Episode("Greek", null, 1, 19, "No Campus for Old Rules", null));
SimilarityMetric[] metrics = new SimilarityMetric[] { EpisodeIdentifier, SubstringFields }; SimilarityMetric[] metrics = new SimilarityMetric[] { EpisodeIdentifier, SubstringFields };
List<Match<File, Episode>> m = new Matcher<File, Episode>(files, episodes, true, metrics).match(); List<Match<File, Episode>> m = new Matcher<File, Episode>(files, episodes, true, metrics).match();

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import net.sf.ehcache.CacheManager; import net.sf.ehcache.CacheManager;
import net.sourceforge.filebot.web.AnidbClient.AnidbSearchResult;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -86,7 +85,7 @@ public class AnidbClientTest {
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getAbsolute().toString()); assertEquals("1", first.getAbsolute().toString());
assertEquals(null, first.getSeason()); assertEquals(null, first.getSeason());
assertEquals("2004-04-07", first.airdate().toString()); assertEquals("2004-04-07", first.getAirdate().toString());
} }
@ -104,7 +103,7 @@ public class AnidbClientTest {
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getAbsolute().toString()); assertEquals("1", first.getAbsolute().toString());
assertEquals(null, first.getSeason()); assertEquals(null, first.getSeason());
assertEquals("2002-04-09", first.airdate().toString()); assertEquals("2002-04-09", first.getAirdate().toString());
} }
@ -125,7 +124,7 @@ public class AnidbClientTest {
assertEquals("74", last.getEpisode().toString()); assertEquals("74", last.getEpisode().toString());
assertEquals("74", last.getAbsolute().toString()); assertEquals("74", last.getAbsolute().toString());
assertEquals(null, last.getSeason()); assertEquals(null, last.getSeason());
assertEquals("2005-09-28", last.airdate().toString()); assertEquals("2005-09-28", last.getAirdate().toString());
} }

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import net.sf.ehcache.CacheManager; import net.sf.ehcache.CacheManager;
import net.sourceforge.filebot.web.SerienjunkiesClient.SerienjunkiesSearchResult;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -46,7 +45,7 @@ public class SerienjunkiesClientTest {
assertEquals("1", eps.getEpisode().toString()); assertEquals("1", eps.getEpisode().toString());
assertEquals("1", eps.getSeason().toString()); assertEquals("1", eps.getSeason().toString());
assertEquals("1", eps.getAbsolute().toString()); assertEquals("1", eps.getAbsolute().toString());
assertEquals("2005-03-27", eps.airdate().toString()); assertEquals("2005-03-27", eps.getAirdate().toString());
} }

View File

@ -8,7 +8,6 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import net.sourceforge.filebot.web.TVRageClient.TVRageSearchResult;
public class TVRageClientTest { public class TVRageClientTest {
@ -48,7 +47,7 @@ public class TVRageClientTest {
assertEquals("22", chosen.getEpisode().toString()); assertEquals("22", chosen.getEpisode().toString());
assertEquals("7", chosen.getSeason().toString()); assertEquals("7", chosen.getSeason().toString());
assertEquals(null, chosen.getAbsolute()); assertEquals(null, chosen.getAbsolute());
assertEquals("2003-05-20", chosen.airdate().toString()); assertEquals("2003-05-20", chosen.getAirdate().toString());
} }
@ -65,7 +64,7 @@ public class TVRageClientTest {
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());
assertEquals(null, first.getAbsolute()); assertEquals(null, first.getAbsolute());
assertEquals("1997-03-10", first.airdate().toString()); assertEquals("1997-03-10", first.getAirdate().toString());
} }

View File

@ -14,7 +14,6 @@ import net.sf.ehcache.CacheManager;
import net.sourceforge.filebot.web.TheTVDBClient.BannerDescriptor; import net.sourceforge.filebot.web.TheTVDBClient.BannerDescriptor;
import net.sourceforge.filebot.web.TheTVDBClient.MirrorType; import net.sourceforge.filebot.web.TheTVDBClient.MirrorType;
import net.sourceforge.filebot.web.TheTVDBClient.SeriesInfo; import net.sourceforge.filebot.web.TheTVDBClient.SeriesInfo;
import net.sourceforge.filebot.web.TheTVDBClient.TheTVDBSearchResult;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -67,7 +66,7 @@ public class TheTVDBClientTest {
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());
assertEquals("1", first.getAbsolute().toString()); assertEquals("1", first.getAbsolute().toString());
assertEquals("1997-03-10", first.airdate().toString()); assertEquals("1997-03-10", first.getAirdate().toString());
// check special episode // check special episode
Episode last = list.get(list.size() - 1); Episode last = list.get(list.size() - 1);
@ -77,7 +76,7 @@ public class TheTVDBClientTest {
assertEquals(null, last.getEpisode()); assertEquals(null, last.getEpisode());
assertEquals(null, last.getAbsolute()); assertEquals(null, last.getAbsolute());
assertEquals("1", last.getSpecial().toString()); assertEquals("1", last.getSpecial().toString());
assertEquals(null, last.airdate()); assertEquals(null, last.getAirdate());
} }
@ -93,7 +92,7 @@ public class TheTVDBClientTest {
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());
assertEquals(null, first.getAbsolute()); // should be "1" but data has not yet been entered assertEquals(null, first.getAbsolute()); // should be "1" but data has not yet been entered
assertEquals("2004-03-12", first.airdate().toString()); assertEquals("2004-03-12", first.getAirdate().toString());
} }
@ -108,7 +107,7 @@ public class TheTVDBClientTest {
assertEquals("1", first.getEpisode().toString()); assertEquals("1", first.getEpisode().toString());
assertEquals("1", first.getSeason().toString()); assertEquals("1", first.getSeason().toString());
assertEquals("1", first.getAbsolute().toString()); assertEquals("1", first.getAbsolute().toString());
assertEquals("2002-12-20", first.airdate().toString()); assertEquals("2002-12-20", first.getAirdate().toString());
} }