+ experimental support for alias titles
This commit is contained in:
parent
b4b4cf2e9b
commit
1058484593
|
@ -1,18 +1,26 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.format;
|
package net.sourceforge.filebot.format;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.sort;
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.singleton;
|
||||||
import static net.sourceforge.filebot.MediaTypes.*;
|
import static net.sourceforge.filebot.MediaTypes.SUBTITLE_FILES;
|
||||||
import static net.sourceforge.filebot.Settings.*;
|
import static net.sourceforge.filebot.MediaTypes.VIDEO_FILES;
|
||||||
import static net.sourceforge.filebot.format.Define.*;
|
import static net.sourceforge.filebot.Settings.useExtendedFileAttributes;
|
||||||
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
|
import static net.sourceforge.filebot.format.Define.undefined;
|
||||||
import static net.sourceforge.filebot.media.MediaDetection.*;
|
import static net.sourceforge.filebot.hash.VerificationUtilities.computeHash;
|
||||||
import static net.sourceforge.filebot.similarity.Normalization.*;
|
import static net.sourceforge.filebot.hash.VerificationUtilities.getEmbeddedChecksum;
|
||||||
import static net.sourceforge.filebot.web.EpisodeFormat.*;
|
import static net.sourceforge.filebot.hash.VerificationUtilities.getHashFromVerificationFile;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.filebot.media.MediaDetection.releaseInfo;
|
||||||
import static net.sourceforge.tuned.StringUtilities.*;
|
import static net.sourceforge.filebot.media.MediaDetection.stripReleaseInfo;
|
||||||
|
import static net.sourceforge.filebot.similarity.Normalization.removeTrailingBrackets;
|
||||||
|
import static net.sourceforge.filebot.web.EpisodeFormat.SeasonEpisode;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.filter;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.hasExtension;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.isDerived;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.listFiles;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.readFile;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.replacePathSeparators;
|
||||||
|
import static net.sourceforge.tuned.StringUtilities.join;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -50,7 +58,6 @@ import net.sourceforge.tuned.FileUtilities.ExtensionFileFilter;
|
||||||
|
|
||||||
import com.cedarsoftware.util.io.JsonWriter;
|
import com.cedarsoftware.util.io.JsonWriter;
|
||||||
|
|
||||||
|
|
||||||
public class MediaBindingBean {
|
public class MediaBindingBean {
|
||||||
|
|
||||||
private final Object infoObject;
|
private final Object infoObject;
|
||||||
|
@ -60,21 +67,18 @@ public class MediaBindingBean {
|
||||||
private MediaInfo mediaInfo;
|
private MediaInfo mediaInfo;
|
||||||
private Object metaInfo;
|
private Object metaInfo;
|
||||||
|
|
||||||
|
|
||||||
public MediaBindingBean(Object infoObject, File mediaFile, Map<File, Object> context) {
|
public MediaBindingBean(Object infoObject, File mediaFile, Map<File, Object> context) {
|
||||||
this.infoObject = infoObject;
|
this.infoObject = infoObject;
|
||||||
this.mediaFile = mediaFile;
|
this.mediaFile = mediaFile;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define(undefined)
|
@Define(undefined)
|
||||||
public <T> T undefined() {
|
public <T> T undefined() {
|
||||||
// omit expressions that depend on undefined values
|
// omit expressions that depend on undefined values
|
||||||
throw new RuntimeException("undefined");
|
throw new RuntimeException("undefined");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("n")
|
@Define("n")
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (infoObject instanceof Episode)
|
if (infoObject instanceof Episode)
|
||||||
|
@ -87,7 +91,6 @@ public class MediaBindingBean {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("y")
|
@Define("y")
|
||||||
public Integer getYear() {
|
public Integer getYear() {
|
||||||
if (infoObject instanceof Episode)
|
if (infoObject instanceof Episode)
|
||||||
|
@ -100,19 +103,16 @@ public class MediaBindingBean {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("s")
|
@Define("s")
|
||||||
public Integer getSeasonNumber() {
|
public Integer getSeasonNumber() {
|
||||||
return getEpisode().getSeason();
|
return getEpisode().getSeason();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("e")
|
@Define("e")
|
||||||
public Integer getEpisodeNumber() {
|
public Integer getEpisodeNumber() {
|
||||||
return getEpisode().getEpisode();
|
return getEpisode().getEpisode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("es")
|
@Define("es")
|
||||||
public List<Integer> getEpisodeNumbers() {
|
public List<Integer> getEpisodeNumbers() {
|
||||||
List<Integer> n = new ArrayList<Integer>();
|
List<Integer> n = new ArrayList<Integer>();
|
||||||
|
@ -122,19 +122,16 @@ public class MediaBindingBean {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("sxe")
|
@Define("sxe")
|
||||||
public String getSxE() {
|
public String getSxE() {
|
||||||
return SeasonEpisode.formatSxE(getEpisode());
|
return SeasonEpisode.formatSxE(getEpisode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("s00e00")
|
@Define("s00e00")
|
||||||
public String getS00E00() {
|
public String getS00E00() {
|
||||||
return SeasonEpisode.formatS00E00(getEpisode());
|
return SeasonEpisode.formatS00E00(getEpisode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("t")
|
@Define("t")
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
if (infoObject instanceof AudioTrack) {
|
if (infoObject instanceof AudioTrack) {
|
||||||
|
@ -154,7 +151,6 @@ public class MediaBindingBean {
|
||||||
return join(title, " & ");
|
return join(title, " & ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("d")
|
@Define("d")
|
||||||
public Object getReleaseDate() {
|
public Object getReleaseDate() {
|
||||||
if (infoObject instanceof Episode) {
|
if (infoObject instanceof Episode) {
|
||||||
|
@ -171,50 +167,62 @@ public class MediaBindingBean {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("airdate")
|
@Define("airdate")
|
||||||
public Date airdate() {
|
public Date airdate() {
|
||||||
return getEpisode().getAirdate();
|
return getEpisode().getAirdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("startdate")
|
@Define("startdate")
|
||||||
public Date startdate() {
|
public Date startdate() {
|
||||||
return getEpisode().getSeriesStartDate();
|
return getEpisode().getSeriesStartDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("absolute")
|
@Define("absolute")
|
||||||
public Integer getAbsoluteEpisodeNumber() {
|
public Integer getAbsoluteEpisodeNumber() {
|
||||||
return getEpisode().getAbsolute();
|
return getEpisode().getAbsolute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("special")
|
@Define("special")
|
||||||
public Integer getSpecialNumber() {
|
public Integer getSpecialNumber() {
|
||||||
return getEpisode().getSpecial();
|
return getEpisode().getSpecial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("series")
|
@Define("series")
|
||||||
public SearchResult getSeriesObject() {
|
public SearchResult getSeriesObject() {
|
||||||
return getEpisode().getSeries();
|
return getEpisode().getSeries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Define("alias")
|
||||||
|
public List<String> getAliasNames() {
|
||||||
|
if (infoObject instanceof Movie) {
|
||||||
|
return asList(getMovie().getAliasNames());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (infoObject instanceof Episode) {
|
||||||
|
return asList(getSeriesObject().getAliasNames());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Define("primaryTitle")
|
@Define("primaryTitle")
|
||||||
public String getPrimaryTitle() throws Exception {
|
public String getPrimaryTitle() throws Exception {
|
||||||
|
if (infoObject instanceof Movie) {
|
||||||
|
return WebServices.TMDb.getMovieInfo(getMovie(), Locale.ENGLISH).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (infoObject instanceof Episode) {
|
||||||
if (getSeriesObject() instanceof TheTVDBSearchResult) {
|
if (getSeriesObject() instanceof TheTVDBSearchResult) {
|
||||||
return WebServices.TheTVDB.getSeriesInfo((TheTVDBSearchResult) getSeriesObject(), Locale.ENGLISH).getName();
|
return WebServices.TheTVDB.getSeriesInfo((TheTVDBSearchResult) getSeriesObject(), Locale.ENGLISH).getName();
|
||||||
}
|
}
|
||||||
if (getSeriesObject() instanceof AnidbSearchResult) {
|
if (getSeriesObject() instanceof AnidbSearchResult) {
|
||||||
return ((AnidbSearchResult) getSeriesObject()).getPrimaryTitle();
|
return ((AnidbSearchResult) getSeriesObject()).getPrimaryTitle();
|
||||||
}
|
}
|
||||||
|
return getSeriesObject().getName(); // default to original search result
|
||||||
// default to original search result
|
|
||||||
return getSeriesObject().getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Define("tmdbid")
|
@Define("tmdbid")
|
||||||
public String getTmdbId() throws Exception {
|
public String getTmdbId() throws Exception {
|
||||||
|
@ -232,7 +240,6 @@ public class MediaBindingBean {
|
||||||
return String.valueOf(tmdbid);
|
return String.valueOf(tmdbid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("imdbid")
|
@Define("imdbid")
|
||||||
public String getImdbId() throws Exception {
|
public String getImdbId() throws Exception {
|
||||||
int imdbid = getMovie().getImdbId();
|
int imdbid = getMovie().getImdbId();
|
||||||
|
@ -249,7 +256,6 @@ public class MediaBindingBean {
|
||||||
return String.format("tt%07d", imdbid);
|
return String.format("tt%07d", imdbid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("vc")
|
@Define("vc")
|
||||||
public String getVideoCodec() {
|
public String getVideoCodec() {
|
||||||
// e.g. XviD, x264, DivX 5, MPEG-4 Visual, AVC, etc.
|
// e.g. XviD, x264, DivX 5, MPEG-4 Visual, AVC, etc.
|
||||||
|
@ -259,7 +265,6 @@ public class MediaBindingBean {
|
||||||
return new Scanner(codec).next();
|
return new Scanner(codec).next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("ac")
|
@Define("ac")
|
||||||
public String getAudioCodec() {
|
public String getAudioCodec() {
|
||||||
// e.g. AC-3, DTS, AAC, Vorbis, MP3, etc.
|
// e.g. AC-3, DTS, AAC, Vorbis, MP3, etc.
|
||||||
|
@ -269,7 +274,6 @@ public class MediaBindingBean {
|
||||||
return codec.replaceAll("\\p{Punct}", "");
|
return codec.replaceAll("\\p{Punct}", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("cf")
|
@Define("cf")
|
||||||
public String getContainerFormat() {
|
public String getContainerFormat() {
|
||||||
// container format extensions (e.g. avi, mkv mka mks, OGG, etc.)
|
// container format extensions (e.g. avi, mkv mka mks, OGG, etc.)
|
||||||
|
@ -279,7 +283,6 @@ public class MediaBindingBean {
|
||||||
return new Scanner(extensions).next().toLowerCase();
|
return new Scanner(extensions).next().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("vf")
|
@Define("vf")
|
||||||
public String getVideoFormat() {
|
public String getVideoFormat() {
|
||||||
int width = Integer.parseInt(getMediaInfo(StreamKind.Video, 0, "Width"));
|
int width = Integer.parseInt(getMediaInfo(StreamKind.Video, 0, "Width"));
|
||||||
|
@ -301,7 +304,6 @@ public class MediaBindingBean {
|
||||||
return null; // video too small
|
return null; // video too small
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("hpi")
|
@Define("hpi")
|
||||||
public String getExactVideoFormat() {
|
public String getExactVideoFormat() {
|
||||||
String height = getMediaInfo(StreamKind.Video, 0, "Height");
|
String height = getMediaInfo(StreamKind.Video, 0, "Height");
|
||||||
|
@ -314,7 +316,6 @@ public class MediaBindingBean {
|
||||||
return height + Character.toLowerCase(scanType.charAt(0));
|
return height + Character.toLowerCase(scanType.charAt(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("af")
|
@Define("af")
|
||||||
public String getAudioChannels() {
|
public String getAudioChannels() {
|
||||||
String channels = getMediaInfo(StreamKind.Audio, 0, "Channel(s)");
|
String channels = getMediaInfo(StreamKind.Audio, 0, "Channel(s)");
|
||||||
|
@ -326,7 +327,6 @@ public class MediaBindingBean {
|
||||||
return channels + "ch";
|
return channels + "ch";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("resolution")
|
@Define("resolution")
|
||||||
public String getVideoResolution() {
|
public String getVideoResolution() {
|
||||||
List<Integer> dim = getDimension();
|
List<Integer> dim = getDimension();
|
||||||
|
@ -338,7 +338,6 @@ public class MediaBindingBean {
|
||||||
return join(dim, "x");
|
return join(dim, "x");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("ws")
|
@Define("ws")
|
||||||
public String getWidescreen() {
|
public String getWidescreen() {
|
||||||
List<Integer> dim = getDimension();
|
List<Integer> dim = getDimension();
|
||||||
|
@ -347,7 +346,6 @@ public class MediaBindingBean {
|
||||||
return (float) dim.get(0) / dim.get(1) > 1.37f ? "ws" : null;
|
return (float) dim.get(0) / dim.get(1) > 1.37f ? "ws" : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("sdhd")
|
@Define("sdhd")
|
||||||
public String getVideoDefinitionCategory() {
|
public String getVideoDefinitionCategory() {
|
||||||
List<Integer> dim = getDimension();
|
List<Integer> dim = getDimension();
|
||||||
|
@ -356,7 +354,6 @@ public class MediaBindingBean {
|
||||||
return dim.get(0) >= 1280 || dim.get(1) >= 720 ? "HD" : "SD";
|
return dim.get(0) >= 1280 || dim.get(1) >= 720 ? "HD" : "SD";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("dim")
|
@Define("dim")
|
||||||
public List<Integer> getDimension() {
|
public List<Integer> getDimension() {
|
||||||
String width = getMediaInfo(StreamKind.Video, 0, "Width");
|
String width = getMediaInfo(StreamKind.Video, 0, "Width");
|
||||||
|
@ -365,19 +362,16 @@ public class MediaBindingBean {
|
||||||
return asList(width != null ? Integer.parseInt(width) : null, height != null ? Integer.parseInt(height) : null);
|
return asList(width != null ? Integer.parseInt(width) : null, height != null ? Integer.parseInt(height) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("original")
|
@Define("original")
|
||||||
public String getOriginalFileName() {
|
public String getOriginalFileName() {
|
||||||
return getOriginalFileName(mediaFile);
|
return getOriginalFileName(mediaFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("xattr")
|
@Define("xattr")
|
||||||
public Object getMetaAttributesObject() {
|
public Object getMetaAttributesObject() {
|
||||||
return getMetaAttributesObject(mediaFile);
|
return getMetaAttributesObject(mediaFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("crc32")
|
@Define("crc32")
|
||||||
public String getCRC32() throws IOException, InterruptedException {
|
public String getCRC32() throws IOException, InterruptedException {
|
||||||
// use inferred media file
|
// use inferred media file
|
||||||
|
@ -399,7 +393,6 @@ public class MediaBindingBean {
|
||||||
return crc32(inferredMediaFile);
|
return crc32(inferredMediaFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("fn")
|
@Define("fn")
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
// make sure media file is defined
|
// make sure media file is defined
|
||||||
|
@ -409,7 +402,6 @@ public class MediaBindingBean {
|
||||||
return FileUtilities.getName(mediaFile);
|
return FileUtilities.getName(mediaFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("ext")
|
@Define("ext")
|
||||||
public String getExtension() {
|
public String getExtension() {
|
||||||
// make sure media file is defined
|
// make sure media file is defined
|
||||||
|
@ -419,7 +411,6 @@ public class MediaBindingBean {
|
||||||
return FileUtilities.getExtension(mediaFile);
|
return FileUtilities.getExtension(mediaFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("source")
|
@Define("source")
|
||||||
public String getVideoSource() {
|
public String getVideoSource() {
|
||||||
// use inferred media file
|
// use inferred media file
|
||||||
|
@ -429,7 +420,6 @@ public class MediaBindingBean {
|
||||||
return releaseInfo.getVideoSource(inferredMediaFile.getParent(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile));
|
return releaseInfo.getVideoSource(inferredMediaFile.getParent(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("group")
|
@Define("group")
|
||||||
public String getReleaseGroup() throws IOException {
|
public String getReleaseGroup() throws IOException {
|
||||||
// use inferred media file
|
// use inferred media file
|
||||||
|
@ -439,7 +429,6 @@ public class MediaBindingBean {
|
||||||
return releaseInfo.getReleaseGroup(inferredMediaFile.getParent(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile));
|
return releaseInfo.getReleaseGroup(inferredMediaFile.getParent(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("lang")
|
@Define("lang")
|
||||||
public Locale detectSubtitleLanguage() throws Exception {
|
public Locale detectSubtitleLanguage() throws Exception {
|
||||||
// make sure media file is defined
|
// make sure media file is defined
|
||||||
|
@ -469,13 +458,11 @@ public class MediaBindingBean {
|
||||||
return WebServices.OpenSubtitles.detectLanguage(readFile(mediaFile));
|
return WebServices.OpenSubtitles.detectLanguage(readFile(mediaFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("actors")
|
@Define("actors")
|
||||||
public Object getActors() {
|
public Object getActors() {
|
||||||
return getMetaInfo().getProperty("actors");
|
return getMetaInfo().getProperty("actors");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("genres")
|
@Define("genres")
|
||||||
public Object getGenres() {
|
public Object getGenres() {
|
||||||
if (infoObject instanceof AudioTrack)
|
if (infoObject instanceof AudioTrack)
|
||||||
|
@ -484,31 +471,26 @@ public class MediaBindingBean {
|
||||||
return getMetaInfo().getProperty("genres");
|
return getMetaInfo().getProperty("genres");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("director")
|
@Define("director")
|
||||||
public Object getDirector() {
|
public Object getDirector() {
|
||||||
return getMetaInfo().getProperty("director");
|
return getMetaInfo().getProperty("director");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("certification")
|
@Define("certification")
|
||||||
public Object getCertification() {
|
public Object getCertification() {
|
||||||
return getMetaInfo().getProperty("certification");
|
return getMetaInfo().getProperty("certification");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("rating")
|
@Define("rating")
|
||||||
public Object getRating() {
|
public Object getRating() {
|
||||||
return getMetaInfo().getProperty("rating");
|
return getMetaInfo().getProperty("rating");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("collection")
|
@Define("collection")
|
||||||
public Object getCollection() {
|
public Object getCollection() {
|
||||||
return getMetaInfo().getProperty("collection");
|
return getMetaInfo().getProperty("collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("info")
|
@Define("info")
|
||||||
public synchronized AssociativeScriptObject getMetaInfo() {
|
public synchronized AssociativeScriptObject getMetaInfo() {
|
||||||
if (metaInfo == null) {
|
if (metaInfo == null) {
|
||||||
|
@ -525,7 +507,6 @@ public class MediaBindingBean {
|
||||||
return createMapBindings(new PropertyBindings(metaInfo, null));
|
return createMapBindings(new PropertyBindings(metaInfo, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("imdb")
|
@Define("imdb")
|
||||||
public synchronized AssociativeScriptObject getImdbApiInfo() {
|
public synchronized AssociativeScriptObject getImdbApiInfo() {
|
||||||
Object data = null;
|
Object data = null;
|
||||||
|
@ -545,97 +526,81 @@ public class MediaBindingBean {
|
||||||
return createMapBindings(new PropertyBindings(data, null));
|
return createMapBindings(new PropertyBindings(data, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("episodelist")
|
@Define("episodelist")
|
||||||
public Object getEpisodeList() throws Exception {
|
public Object getEpisodeList() throws Exception {
|
||||||
return WebServices.TheTVDB.getEpisodeList(WebServices.TheTVDB.search(getEpisode().getSeriesName()).get(0), SortOrder.Airdate, Locale.ENGLISH);
|
return WebServices.TheTVDB.getEpisodeList(WebServices.TheTVDB.search(getEpisode().getSeriesName()).get(0), SortOrder.Airdate, Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("media")
|
@Define("media")
|
||||||
public AssociativeScriptObject getGeneralMediaInfo() {
|
public AssociativeScriptObject getGeneralMediaInfo() {
|
||||||
return createMapBindings(getMediaInfo().snapshot(StreamKind.General, 0));
|
return createMapBindings(getMediaInfo().snapshot(StreamKind.General, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("video")
|
@Define("video")
|
||||||
public AssociativeScriptObject getVideoInfo() {
|
public AssociativeScriptObject getVideoInfo() {
|
||||||
return createMapBindings(getMediaInfo().snapshot(StreamKind.Video, 0));
|
return createMapBindings(getMediaInfo().snapshot(StreamKind.Video, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("audio")
|
@Define("audio")
|
||||||
public AssociativeScriptObject getAudioInfo() {
|
public AssociativeScriptObject getAudioInfo() {
|
||||||
return createMapBindings(getMediaInfo().snapshot(StreamKind.Audio, 0));
|
return createMapBindings(getMediaInfo().snapshot(StreamKind.Audio, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("text")
|
@Define("text")
|
||||||
public AssociativeScriptObject getTextInfo() {
|
public AssociativeScriptObject getTextInfo() {
|
||||||
return createMapBindings(getMediaInfo().snapshot(StreamKind.Text, 0));
|
return createMapBindings(getMediaInfo().snapshot(StreamKind.Text, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("videos")
|
@Define("videos")
|
||||||
public List<AssociativeScriptObject> getVideoInfoList() {
|
public List<AssociativeScriptObject> getVideoInfoList() {
|
||||||
return createMapBindingsList(getMediaInfo().snapshot().get(StreamKind.Video));
|
return createMapBindingsList(getMediaInfo().snapshot().get(StreamKind.Video));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("audios")
|
@Define("audios")
|
||||||
public List<AssociativeScriptObject> getAudioInfoList() {
|
public List<AssociativeScriptObject> getAudioInfoList() {
|
||||||
return createMapBindingsList(getMediaInfo().snapshot().get(StreamKind.Audio));
|
return createMapBindingsList(getMediaInfo().snapshot().get(StreamKind.Audio));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("texts")
|
@Define("texts")
|
||||||
public List<AssociativeScriptObject> getTextInfoList() {
|
public List<AssociativeScriptObject> getTextInfoList() {
|
||||||
return createMapBindingsList(getMediaInfo().snapshot().get(StreamKind.Text));
|
return createMapBindingsList(getMediaInfo().snapshot().get(StreamKind.Text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("artist")
|
@Define("artist")
|
||||||
public String getArtist() {
|
public String getArtist() {
|
||||||
return getMusic().getArtist();
|
return getMusic().getArtist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("albumArtist")
|
@Define("albumArtist")
|
||||||
public String getAlbumArtist() {
|
public String getAlbumArtist() {
|
||||||
return getMusic().getAlbumArtist();
|
return getMusic().getAlbumArtist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("album")
|
@Define("album")
|
||||||
public String getAlbum() {
|
public String getAlbum() {
|
||||||
return getMusic().getAlbum();
|
return getMusic().getAlbum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("episode")
|
@Define("episode")
|
||||||
public Episode getEpisode() {
|
public Episode getEpisode() {
|
||||||
return (Episode) infoObject;
|
return (Episode) infoObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("episodes")
|
@Define("episodes")
|
||||||
public List<Episode> getEpisodes() {
|
public List<Episode> getEpisodes() {
|
||||||
return infoObject instanceof MultiEpisode ? ((MultiEpisode) infoObject).getEpisodes() : asList(getEpisode());
|
return infoObject instanceof MultiEpisode ? ((MultiEpisode) infoObject).getEpisodes() : asList(getEpisode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("movie")
|
@Define("movie")
|
||||||
public Movie getMovie() {
|
public Movie getMovie() {
|
||||||
return (Movie) infoObject;
|
return (Movie) infoObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("music")
|
@Define("music")
|
||||||
public AudioTrack getMusic() {
|
public AudioTrack getMusic() {
|
||||||
return (AudioTrack) infoObject;
|
return (AudioTrack) infoObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("pi")
|
@Define("pi")
|
||||||
public Integer getPart() {
|
public Integer getPart() {
|
||||||
if (infoObject instanceof AudioTrack)
|
if (infoObject instanceof AudioTrack)
|
||||||
|
@ -646,7 +611,6 @@ public class MediaBindingBean {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("pn")
|
@Define("pn")
|
||||||
public Integer getPartCount() {
|
public Integer getPartCount() {
|
||||||
if (infoObject instanceof AudioTrack)
|
if (infoObject instanceof AudioTrack)
|
||||||
|
@ -657,37 +621,31 @@ public class MediaBindingBean {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("file")
|
@Define("file")
|
||||||
public File getMediaFile() {
|
public File getMediaFile() {
|
||||||
return mediaFile;
|
return mediaFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("folder")
|
@Define("folder")
|
||||||
public File getMediaParentFolder() {
|
public File getMediaParentFolder() {
|
||||||
return getMediaFile().getParentFile();
|
return getMediaFile().getParentFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("home")
|
@Define("home")
|
||||||
public File getUserHome() throws IOException {
|
public File getUserHome() throws IOException {
|
||||||
return new File(System.getProperty("user.home"));
|
return new File(System.getProperty("user.home"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("object")
|
@Define("object")
|
||||||
public Object getInfoObject() {
|
public Object getInfoObject() {
|
||||||
return infoObject;
|
return infoObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("i")
|
@Define("i")
|
||||||
public Integer getModelIndex() {
|
public Integer getModelIndex() {
|
||||||
return identityIndexOf(getContext().values(), getInfoObject());
|
return identityIndexOf(getContext().values(), getInfoObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("di")
|
@Define("di")
|
||||||
public Integer getDuplicateIndex() {
|
public Integer getDuplicateIndex() {
|
||||||
List<Object> duplicates = new ArrayList<Object>();
|
List<Object> duplicates = new ArrayList<Object>();
|
||||||
|
@ -700,19 +658,16 @@ public class MediaBindingBean {
|
||||||
return di == 0 ? null : di;
|
return di == 0 ? null : di;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("model")
|
@Define("model")
|
||||||
public Map<File, Object> getContext() {
|
public Map<File, Object> getContext() {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("json")
|
@Define("json")
|
||||||
public String getInfoObjectDump() throws Exception {
|
public String getInfoObjectDump() throws Exception {
|
||||||
return JsonWriter.objectToJson(infoObject);
|
return JsonWriter.objectToJson(infoObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private File getInferredMediaFile() {
|
private File getInferredMediaFile() {
|
||||||
// make sure media file is defined
|
// make sure media file is defined
|
||||||
checkMediaFile();
|
checkMediaFile();
|
||||||
|
@ -760,14 +715,12 @@ public class MediaBindingBean {
|
||||||
return mediaFile;
|
return mediaFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkMediaFile() throws RuntimeException {
|
private void checkMediaFile() throws RuntimeException {
|
||||||
// make sure file is not null, and that it is an existing file
|
// make sure file is not null, and that it is an existing file
|
||||||
if (mediaFile == null)
|
if (mediaFile == null)
|
||||||
throw new RuntimeException("Invalid media file: " + mediaFile);
|
throw new RuntimeException("Invalid media file: " + mediaFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private synchronized MediaInfo getMediaInfo() {
|
private synchronized MediaInfo getMediaInfo() {
|
||||||
if (mediaInfo == null) {
|
if (mediaInfo == null) {
|
||||||
// make sure media file is defined
|
// make sure media file is defined
|
||||||
|
@ -786,7 +739,6 @@ public class MediaBindingBean {
|
||||||
return mediaInfo;
|
return mediaInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Integer identityIndexOf(Iterable<?> c, Object o) {
|
private Integer identityIndexOf(Iterable<?> c, Object o) {
|
||||||
Iterator<?> itr = c.iterator();
|
Iterator<?> itr = c.iterator();
|
||||||
for (int i = 0; itr.hasNext(); i++) {
|
for (int i = 0; itr.hasNext(); i++) {
|
||||||
|
@ -797,7 +749,6 @@ public class MediaBindingBean {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getMediaInfo(StreamKind streamKind, int streamNumber, String... keys) {
|
private String getMediaInfo(StreamKind streamKind, int streamNumber, String... keys) {
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
String value = getMediaInfo().get(streamKind, streamNumber, key);
|
String value = getMediaInfo().get(streamKind, streamNumber, key);
|
||||||
|
@ -809,7 +760,6 @@ public class MediaBindingBean {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AssociativeScriptObject createMapBindings(Map<?, ?> map) {
|
private AssociativeScriptObject createMapBindings(Map<?, ?> map) {
|
||||||
return new AssociativeScriptObject(map) {
|
return new AssociativeScriptObject(map) {
|
||||||
|
|
||||||
|
@ -831,7 +781,6 @@ public class MediaBindingBean {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<AssociativeScriptObject> createMapBindingsList(List<Map<String, String>> mapList) {
|
private List<AssociativeScriptObject> createMapBindingsList(List<Map<String, String>> mapList) {
|
||||||
List<AssociativeScriptObject> bindings = new ArrayList<AssociativeScriptObject>();
|
List<AssociativeScriptObject> bindings = new ArrayList<AssociativeScriptObject>();
|
||||||
for (Map<?, ?> it : mapList) {
|
for (Map<?, ?> it : mapList) {
|
||||||
|
@ -840,7 +789,6 @@ public class MediaBindingBean {
|
||||||
return bindings;
|
return bindings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String crc32(File file) throws IOException, InterruptedException {
|
private String crc32(File file) throws IOException, InterruptedException {
|
||||||
// try to get checksum from cache
|
// try to get checksum from cache
|
||||||
Cache cache = Cache.getCache("checksum");
|
Cache cache = Cache.getCache("checksum");
|
||||||
|
@ -856,7 +804,6 @@ public class MediaBindingBean {
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getOriginalFileName(File file) {
|
private String getOriginalFileName(File file) {
|
||||||
if (useExtendedFileAttributes()) {
|
if (useExtendedFileAttributes()) {
|
||||||
try {
|
try {
|
||||||
|
@ -868,7 +815,6 @@ public class MediaBindingBean {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Object getMetaAttributesObject(File file) {
|
private Object getMetaAttributesObject(File file) {
|
||||||
if (useExtendedFileAttributes()) {
|
if (useExtendedFileAttributes()) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -611,7 +611,7 @@ public class MediaDetection {
|
||||||
sort(sorted, new SimilarityComparator(getMovieMatchMetric(), paragon.toArray()));
|
sort(sorted, new SimilarityComparator(getMovieMatchMetric(), paragon.toArray()));
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
// System.out.format("sortBySimilarity %s => %s", terms, options);
|
// System.out.format("sortBySimilarity %s => %s", terms, sorted);
|
||||||
|
|
||||||
return sorted;
|
return sorted;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,25 +5,25 @@ pattern.video.source: CAMRip|CAM|PDVD|TS|TELESYNC|PDVD|PPV|PPVRip|Screener|SCR|S
|
||||||
pattern.video.format: DivX|Xvid|AVC|x264|h264|3ivx|mpg|mpeg|mpeg4|mp3|AAC|AAC2.0|AAC5.1|AAC.2.0|AAC.5.1|AC3|dd20|dd51|2ch|6ch|TS|DTS|DTS.HD|DTS.HD.MA|TrueHD|WS|HR|7p|720p|18p|1080p|PAL|NTSC|3D
|
pattern.video.format: DivX|Xvid|AVC|x264|h264|3ivx|mpg|mpeg|mpeg4|mp3|AAC|AAC2.0|AAC5.1|AAC.2.0|AAC.5.1|AC3|dd20|dd51|2ch|6ch|TS|DTS|DTS.HD|DTS.HD.MA|TrueHD|WS|HR|7p|720p|18p|1080p|PAL|NTSC|3D
|
||||||
|
|
||||||
# known release group names
|
# known release group names
|
||||||
url.release-groups: http://filebot.net/data/release-groups.txt
|
url.release-groups: file:///d:/workspace/filebot/website/data/release-groups.txt
|
||||||
|
|
||||||
# blacklisted terms that will be ignored
|
# blacklisted terms that will be ignored
|
||||||
url.query-blacklist: http://filebot.net/data/query-blacklist.txt
|
url.query-blacklist: file:///d:/workspace/filebot/website/data/query-blacklist.txt
|
||||||
|
|
||||||
# clutter files that will be ignored
|
# clutter files that will be ignored
|
||||||
url.exclude-blacklist: http://filebot.net/data/exclude-blacklist.txt
|
url.exclude-blacklist: file:///d:/workspace/filebot/website/data/exclude-blacklist.txt
|
||||||
|
|
||||||
# list of patterns directly matching files to series names
|
# list of patterns directly matching files to series names
|
||||||
url.series-mappings: http://filebot.net/data/series-mappings.txt
|
url.series-mappings: file:///d:/workspace/filebot/website/data/series-mappings.txt
|
||||||
|
|
||||||
# list of all movies (id, name, year)
|
# list of all movies (id, name, year)
|
||||||
url.movie-list: http://filebot.net/data/movies.txt.xz
|
url.movie-list: file:///d:/workspace/filebot/website/data/movies.txt.xz
|
||||||
|
|
||||||
# TheTVDB index
|
# TheTVDB index
|
||||||
url.thetvdb-index: http://filebot.net/data/thetvdb.txt.xz
|
url.thetvdb-index: file:///d:/workspace/filebot/website/data/thetvdb.txt.xz
|
||||||
|
|
||||||
# AniDB index
|
# AniDB index
|
||||||
url.anidb-index: http://filebot.net/data/anidb.txt.xz
|
url.anidb-index: file:///d:/workspace/filebot/website/data/anidb.txt.xz
|
||||||
|
|
||||||
# disk folder matcher
|
# disk folder matcher
|
||||||
pattern.diskfolder.entry: BDMV|HVDVD_TS|VIDEO_TS|AUDIO_TS|VCD|movie.nfo
|
pattern.diskfolder.entry: BDMV|HVDVD_TS|VIDEO_TS|AUDIO_TS|VCD|movie.nfo
|
||||||
|
|
|
@ -1,20 +1,31 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.similarity;
|
package net.sourceforge.filebot.similarity;
|
||||||
|
|
||||||
|
import static java.lang.Math.ceil;
|
||||||
import static java.lang.Math.*;
|
import static java.lang.Math.floor;
|
||||||
import static java.util.Arrays.*;
|
import static java.lang.Math.max;
|
||||||
import static java.util.Collections.*;
|
import static java.lang.Math.min;
|
||||||
import static net.sourceforge.filebot.Settings.*;
|
import static java.util.Arrays.asList;
|
||||||
import static net.sourceforge.filebot.similarity.Normalization.*;
|
import static java.util.Collections.emptyMap;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static java.util.Collections.emptySet;
|
||||||
import static net.sourceforge.tuned.StringUtilities.*;
|
import static java.util.Collections.singleton;
|
||||||
|
import static java.util.Collections.synchronizedMap;
|
||||||
|
import static net.sourceforge.filebot.Settings.useExtendedFileAttributes;
|
||||||
|
import static net.sourceforge.filebot.similarity.Normalization.normalizePunctuation;
|
||||||
|
import static net.sourceforge.filebot.similarity.Normalization.removeEmbeddedChecksum;
|
||||||
|
import static net.sourceforge.filebot.similarity.Normalization.removeTrailingBrackets;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.getName;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.getNameWithoutExtension;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.getRelativePathTail;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.normalizePathSeparators;
|
||||||
|
import static net.sourceforge.tuned.StringUtilities.join;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -36,7 +47,6 @@ import net.sourceforge.filebot.web.TheTVDBSearchResult;
|
||||||
|
|
||||||
import com.ibm.icu.text.Transliterator;
|
import com.ibm.icu.text.Transliterator;
|
||||||
|
|
||||||
|
|
||||||
public enum EpisodeMetrics implements SimilarityMetric {
|
public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
|
|
||||||
// Match by season / episode numbers
|
// Match by season / episode numbers
|
||||||
|
@ -44,7 +54,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
|
|
||||||
private final Map<Object, Collection<SxE>> transformCache = synchronizedMap(new HashMap<Object, Collection<SxE>>(64, 4));
|
private final Map<Object, Collection<SxE>> transformCache = synchronizedMap(new HashMap<Object, Collection<SxE>>(64, 4));
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<SxE> parse(Object object) {
|
protected Collection<SxE> parse(Object object) {
|
||||||
if (object instanceof Movie) {
|
if (object instanceof Movie) {
|
||||||
|
@ -82,7 +91,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
|
|
||||||
private final Map<Object, Date> transformCache = synchronizedMap(new HashMap<Object, Date>(64, 4));
|
private final Map<Object, Date> transformCache = synchronizedMap(new HashMap<Object, Date>(64, 4));
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date parse(Object object) {
|
public Date parse(Object object) {
|
||||||
if (object instanceof Movie) {
|
if (object instanceof Movie) {
|
||||||
|
@ -154,7 +162,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return (float) ((max(sxe, 0) * title) + (floor(sxe) / 10));
|
return (float) ((max(sxe, 0) * title) + (floor(sxe) / 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object getTitle(Object o) {
|
public Object getTitle(Object o) {
|
||||||
if (o instanceof Episode) {
|
if (o instanceof Episode) {
|
||||||
Episode e = (Episode) o;
|
Episode e = (Episode) o;
|
||||||
|
@ -185,7 +192,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return (float) (ceil(sum * 3) / 3);
|
return (float) (ceil(sum * 3) / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String[] normalize(Object[] objects) {
|
protected String[] normalize(Object[] objects) {
|
||||||
String[] names = new String[objects.length];
|
String[] names = new String[objects.length];
|
||||||
|
|
||||||
|
@ -196,17 +202,23 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Object[] fields(Object object) {
|
protected Object[] fields(Object object) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
Episode episode = (Episode) object;
|
Episode episode = (Episode) object;
|
||||||
String seriesName = removeTrailingBrackets(episode.getSeriesName());
|
LinkedHashSet<String> set = new LinkedHashSet<String>(4);
|
||||||
String episodeTitle = episode.getTitle();
|
set.add(removeTrailingBrackets(episode.getSeriesName()));
|
||||||
if (!seriesName.equalsIgnoreCase(episodeTitle)) {
|
set.add(removeTrailingBrackets(episode.getTitle()));
|
||||||
return new Object[] { seriesName, episodeTitle };
|
set.add(removeTrailingBrackets(episode.getSeries().getName()));
|
||||||
} else {
|
for (String it : episode.getSeries().getAliasNames()) {
|
||||||
return new Object[] { seriesName, null };
|
set.add(removeTrailingBrackets(it));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Iterator<String> itr = set.iterator();
|
||||||
|
Object[] f = new Object[4];
|
||||||
|
for (int i = 0; i < f.length; i++) {
|
||||||
|
f[i] = itr.hasNext() ? itr.next() : null;
|
||||||
|
}
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object instanceof File) {
|
if (object instanceof File) {
|
||||||
|
@ -233,7 +245,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return (float) (floor(super.getSimilarity(o1, o2) * 4) / 4);
|
return (float) (floor(super.getSimilarity(o1, o2) * 4) / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String normalize(Object object) {
|
protected String normalize(Object object) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
|
@ -258,7 +269,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return (float) (floor(super.getSimilarity(o1, o2) * 4) / 4);
|
return (float) (floor(super.getSimilarity(o1, o2) * 4) / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String normalize(Object object) {
|
protected String normalize(Object object) {
|
||||||
// simplify file name, if possible
|
// simplify file name, if possible
|
||||||
|
@ -272,7 +282,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
private ReleaseInfo releaseInfo = new ReleaseInfo();
|
private ReleaseInfo releaseInfo = new ReleaseInfo();
|
||||||
private SeriesNameMatcher seriesNameMatcher = new SeriesNameMatcher();
|
private SeriesNameMatcher seriesNameMatcher = new SeriesNameMatcher();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
float lowerBound = super.getSimilarity(normalize(o1, true), normalize(o2, true));
|
float lowerBound = super.getSimilarity(normalize(o1, true), normalize(o2, true));
|
||||||
|
@ -281,13 +290,11 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return (float) (floor(max(lowerBound, upperBound) * 4) / 4);
|
return (float) (floor(max(lowerBound, upperBound) * 4) / 4);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String normalize(Object object) {
|
protected String normalize(Object object) {
|
||||||
return object.toString();
|
return object.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
protected String normalize(Object object, boolean strict) {
|
protected String normalize(Object object, boolean strict) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
if (strict) {
|
if (strict) {
|
||||||
|
@ -339,13 +346,11 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return max(lowerBound, upperBound);
|
return max(lowerBound, upperBound);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String normalize(Object object) {
|
protected String normalize(Object object) {
|
||||||
return object.toString();
|
return object.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
protected String normalize(Object object, boolean numbersOnly) {
|
protected String normalize(Object object, boolean numbersOnly) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
Episode e = (Episode) object;
|
Episode e = (Episode) object;
|
||||||
|
@ -391,7 +396,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String[] fields(Object object) {
|
protected String[] fields(Object object) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
Episode episode = (Episode) object;
|
Episode episode = (Episode) object;
|
||||||
|
@ -416,7 +420,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return o1 instanceof File ? super.getSimilarity(o2, o1) : super.getSimilarity(o1, o2);
|
return o1 instanceof File ? super.getSimilarity(o2, o1) : super.getSimilarity(o1, o2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected long getLength(Object object) {
|
protected long getLength(Object object) {
|
||||||
if (object instanceof FileInfo) {
|
if (object instanceof FileInfo) {
|
||||||
|
@ -450,7 +453,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return f >= 0.8 ? 1 : f >= 0 ? 0 : -1;
|
return f >= 0.8 ? 1 : f >= 0 ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTimeStamp(Object object) {
|
public long getTimeStamp(Object object) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
|
@ -483,7 +485,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
|
|
||||||
private final Map<String, SeriesInfo> seriesInfoCache = new HashMap<String, SeriesInfo>();
|
private final Map<String, SeriesInfo> seriesInfoCache = new HashMap<String, SeriesInfo>();
|
||||||
|
|
||||||
|
|
||||||
public float getRating(Object o) {
|
public float getRating(Object o) {
|
||||||
if (o instanceof Episode) {
|
if (o instanceof Episode) {
|
||||||
try {
|
try {
|
||||||
|
@ -545,12 +546,10 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
// inner metric
|
// inner metric
|
||||||
private final SimilarityMetric metric;
|
private final SimilarityMetric metric;
|
||||||
|
|
||||||
|
|
||||||
private EpisodeMetrics(SimilarityMetric metric) {
|
private EpisodeMetrics(SimilarityMetric metric) {
|
||||||
this.metric = metric;
|
this.metric = metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
return metric.getSimilarity(o1, o2);
|
return metric.getSimilarity(o1, o2);
|
||||||
|
@ -559,7 +558,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
private static final Map<Object, String> transformCache = synchronizedMap(new HashMap<Object, String>(64, 4));
|
private static final Map<Object, String> transformCache = synchronizedMap(new HashMap<Object, String>(64, 4));
|
||||||
private static final Transliterator transliterator = Transliterator.getInstance("Any-Latin;Latin-ASCII;[:Diacritic:]remove");
|
private static final Transliterator transliterator = Transliterator.getInstance("Any-Latin;Latin-ASCII;[:Diacritic:]remove");
|
||||||
|
|
||||||
|
|
||||||
protected static String normalizeObject(Object object) {
|
protected static String normalizeObject(Object object) {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -596,7 +594,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static SimilarityMetric[] defaultSequence(boolean includeFileMetrics) {
|
public static SimilarityMetric[] defaultSequence(boolean includeFileMetrics) {
|
||||||
// 1 pass: divide by file length (only works for matching torrent entries or files)
|
// 1 pass: divide by file length (only works for matching torrent entries or files)
|
||||||
// 2-3 pass: divide by title or season / episode numbers
|
// 2-3 pass: divide by title or season / episode numbers
|
||||||
|
@ -612,7 +609,6 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static SimilarityMetric verificationMetric() {
|
public static SimilarityMetric verificationMetric() {
|
||||||
return new MetricCascade(FileSize, FileName, SeasonEpisode, AirDate, Title, Name);
|
return new MetricCascade(FileSize, FileName, SeasonEpisode, AirDate, Title, Name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.similarity;
|
package net.sourceforge.filebot.similarity;
|
||||||
|
|
||||||
|
import static net.sourceforge.filebot.similarity.Normalization.normalizePunctuation;
|
||||||
import static net.sourceforge.filebot.similarity.Normalization.*;
|
|
||||||
|
|
||||||
|
|
||||||
public class SubstringMetric implements SimilarityMetric {
|
public class SubstringMetric implements SimilarityMetric {
|
||||||
|
|
||||||
|
@ -20,8 +17,10 @@ public class SubstringMetric implements SimilarityMetric {
|
||||||
return s1.contains(s2) || s2.contains(s1) ? 1 : 0;
|
return s1.contains(s2) || s2.contains(s1) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String normalize(Object object) {
|
protected String normalize(Object object) {
|
||||||
|
if (object == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
// use string representation
|
// use string representation
|
||||||
String name = object.toString();
|
String name = object.toString();
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ 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},"series":{"@type":"net.sourceforge.filebot.web.TheTVDBSearchResult","seriesId":78874,"name":"Firefly"}}
|
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","aliasNames":[]}}
|
||||||
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","aliasNames":[]}
|
||||||
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}
|
||||||
|
|
||||||
# basic 1.01
|
# basic 1.01
|
||||||
|
|
|
@ -1,58 +1,44 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
public class AnidbSearchResult extends SearchResult {
|
public class AnidbSearchResult extends SearchResult {
|
||||||
|
|
||||||
protected int aid;
|
protected int aid;
|
||||||
protected String primaryTitle; // one per anime
|
|
||||||
protected String englishTitle; // one per language
|
|
||||||
|
|
||||||
|
|
||||||
protected AnidbSearchResult() {
|
protected AnidbSearchResult() {
|
||||||
// used by serializer
|
// used by serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AnidbSearchResult(int aid, String primaryTitle, String englishTitle) {
|
public AnidbSearchResult(int aid, String primaryTitle, String englishTitle) {
|
||||||
|
super(primaryTitle, englishTitle);
|
||||||
this.aid = aid;
|
this.aid = aid;
|
||||||
this.primaryTitle = primaryTitle;
|
|
||||||
this.englishTitle = englishTitle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return aid;
|
return aid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getAnimeId() {
|
public int getAnimeId() {
|
||||||
return aid;
|
return aid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return primaryTitle;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getPrimaryTitle() {
|
public String getPrimaryTitle() {
|
||||||
return primaryTitle;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getEnglishTitle() {
|
public String getEnglishTitle() {
|
||||||
return englishTitle;
|
return aliasNames.length > 0 ? aliasNames[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return aid;
|
return aid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (object instanceof AnidbSearchResult) {
|
if (object instanceof AnidbSearchResult) {
|
||||||
|
|
|
@ -1,50 +1,44 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
||||||
public class Movie extends SearchResult {
|
public class Movie extends SearchResult {
|
||||||
|
|
||||||
protected int year;
|
protected int year;
|
||||||
protected int imdbId;
|
protected int imdbId;
|
||||||
protected int tmdbId;
|
protected int tmdbId;
|
||||||
|
|
||||||
|
|
||||||
protected Movie() {
|
protected Movie() {
|
||||||
// used by serializer
|
// used by serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Movie(Movie obj) {
|
public Movie(Movie obj) {
|
||||||
this(obj.name, obj.year, obj.imdbId, obj.tmdbId);
|
this(obj.name, obj.aliasNames, obj.year, obj.imdbId, obj.tmdbId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Movie(String name, int year, int imdbId, int tmdbId) {
|
public Movie(String name, int year, int imdbId, int tmdbId) {
|
||||||
super(name);
|
this(name, new String[0], year, imdbId, tmdbId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Movie(String name, String[] aliasNames, int year, int imdbId, int tmdbId) {
|
||||||
|
super(name, aliasNames);
|
||||||
this.year = year;
|
this.year = year;
|
||||||
this.imdbId = imdbId;
|
this.imdbId = imdbId;
|
||||||
this.tmdbId = tmdbId;
|
this.tmdbId = tmdbId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getYear() {
|
public int getYear() {
|
||||||
return year;
|
return year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getImdbId() {
|
public int getImdbId() {
|
||||||
return imdbId;
|
return imdbId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getTmdbId() {
|
public int getTmdbId() {
|
||||||
return tmdbId;
|
return tmdbId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (object instanceof Movie) {
|
if (object instanceof Movie) {
|
||||||
|
@ -55,25 +49,22 @@ public class Movie extends SearchResult {
|
||||||
return tmdbId == other.tmdbId;
|
return tmdbId == other.tmdbId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return year == other.year && name.equalsIgnoreCase(other.name);
|
return year == other.year && name.equals(other.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Movie clone() {
|
public Movie clone() {
|
||||||
return new Movie(this);
|
return new Movie(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Arrays.hashCode(new Object[] { name.toLowerCase(), year });
|
return Arrays.hashCode(new Object[] { name.toLowerCase(), year });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s (%04d)", name, year < 0 ? 0 : year);
|
return String.format("%s (%04d)", name, year < 0 ? 0 : year);
|
||||||
|
|
|
@ -1,33 +1,32 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
public abstract class SearchResult implements Serializable {
|
public abstract class SearchResult implements Serializable {
|
||||||
|
|
||||||
protected final String name;
|
protected String name;
|
||||||
|
protected String[] aliasNames;
|
||||||
|
|
||||||
protected SearchResult() {
|
protected SearchResult() {
|
||||||
this.name = null;
|
// used by serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SearchResult(String name, String... aliasNames) {
|
||||||
public SearchResult(String name) {
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.aliasNames = aliasNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getAliasNames() {
|
||||||
|
return aliasNames.clone();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName();
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,9 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
// e.g.
|
// e.g.
|
||||||
// {"id":16320,"title":"冲出宁静号","release_date":"2005-09-30","original_title":"Serenity"}
|
// {"id":16320,"title":"冲出宁静号","release_date":"2005-09-30","original_title":"Serenity"}
|
||||||
String title = (String) it.get("title");
|
String title = (String) it.get("title");
|
||||||
|
String originalTitle = (String) it.get("original_title");
|
||||||
if (title == null || title.isEmpty()) {
|
if (title == null || title.isEmpty()) {
|
||||||
title = (String) it.get("original_title");
|
title = originalTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -87,7 +88,7 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalArgumentException("Missing data: year");
|
throw new IllegalArgumentException("Missing data: year");
|
||||||
}
|
}
|
||||||
result.add(new Movie(title, year, -1, (int) id));
|
result.add(new Movie(title, title.equals(originalTitle) ? new String[] {} : new String[] { originalTitle }, year, -1, (int) id));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.getLogger(TMDbClient.class.getName()).log(Level.FINE, String.format("Ignore movie [%s]: %s", title, e.getMessage()));
|
Logger.getLogger(TMDbClient.class.getName()).log(Level.FINE, String.format("Ignore movie [%s]: %s", title, e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Arrays.*;
|
import static net.sourceforge.filebot.web.EpisodeUtilities.filterBySeason;
|
||||||
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
|
import static net.sourceforge.filebot.web.EpisodeUtilities.sortEpisodes;
|
||||||
import static net.sourceforge.filebot.web.WebRequest.*;
|
import static net.sourceforge.filebot.web.WebRequest.encode;
|
||||||
import static net.sourceforge.tuned.XPathUtilities.*;
|
import static net.sourceforge.filebot.web.WebRequest.getDocument;
|
||||||
|
import static net.sourceforge.tuned.XPathUtilities.getIntegerContent;
|
||||||
|
import static net.sourceforge.tuned.XPathUtilities.getTextContent;
|
||||||
|
import static net.sourceforge.tuned.XPathUtilities.selectNode;
|
||||||
|
import static net.sourceforge.tuned.XPathUtilities.selectNodes;
|
||||||
|
import static net.sourceforge.tuned.XPathUtilities.selectString;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -38,7 +42,6 @@ import net.sourceforge.tuned.FileUtilities;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
|
||||||
public class TheTVDBClient extends AbstractEpisodeListProvider {
|
public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
private final String host = "www.thetvdb.com";
|
private final String host = "www.thetvdb.com";
|
||||||
|
@ -47,7 +50,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
private final String apikey;
|
private final String apikey;
|
||||||
|
|
||||||
|
|
||||||
public TheTVDBClient(String apikey) {
|
public TheTVDBClient(String apikey) {
|
||||||
if (apikey == null)
|
if (apikey == null)
|
||||||
throw new NullPointerException("apikey must not be null");
|
throw new NullPointerException("apikey must not be null");
|
||||||
|
@ -55,31 +57,26 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
this.apikey = apikey;
|
this.apikey = apikey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "TheTVDB";
|
return "TheTVDB";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Icon getIcon() {
|
public Icon getIcon() {
|
||||||
return ResourceManager.getIcon("search.thetvdb");
|
return ResourceManager.getIcon("search.thetvdb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSingleSeasonSupport() {
|
public boolean hasSingleSeasonSupport() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasLocaleSupport() {
|
public boolean hasLocaleSupport() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getLanguageCode(Locale locale) {
|
public String getLanguageCode(Locale locale) {
|
||||||
String code = locale.getLanguage();
|
String code = locale.getLanguage();
|
||||||
|
|
||||||
|
@ -96,13 +93,11 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultCache getCache() {
|
public ResultCache getCache() {
|
||||||
return new ResultCache(host, Cache.getCache("web-datasource"));
|
return new ResultCache(host, Cache.getCache("web-datasource"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SearchResult> fetchSearchResult(String query, Locale locale) throws Exception {
|
public List<SearchResult> fetchSearchResult(String query, Locale locale) throws Exception {
|
||||||
// perform online search
|
// perform online search
|
||||||
|
@ -116,15 +111,19 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
int sid = getIntegerContent("seriesid", node);
|
int sid = getIntegerContent("seriesid", node);
|
||||||
String seriesName = getTextContent("SeriesName", node);
|
String seriesName = getTextContent("SeriesName", node);
|
||||||
|
|
||||||
|
List<String> aliasNames = new ArrayList<String>(2);
|
||||||
|
for (Node aliasNode : selectNodes("AliasNames", node)) {
|
||||||
|
aliasNames.add(getTextContent(aliasNode));
|
||||||
|
}
|
||||||
|
|
||||||
if (!resultSet.containsKey(sid)) {
|
if (!resultSet.containsKey(sid)) {
|
||||||
resultSet.put(sid, new TheTVDBSearchResult(seriesName, sid));
|
resultSet.put(sid, new TheTVDBSearchResult(seriesName, aliasNames.toArray(new String[0]), sid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ArrayList<SearchResult>(resultSet.values());
|
return new ArrayList<SearchResult>(resultSet.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Episode> fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws Exception {
|
public List<Episode> fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws Exception {
|
||||||
TheTVDBSearchResult series = (TheTVDBSearchResult) searchResult;
|
TheTVDBSearchResult series = (TheTVDBSearchResult) searchResult;
|
||||||
|
@ -189,7 +188,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return episodes;
|
return episodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Document getSeriesRecord(TheTVDBSearchResult searchResult, String languageCode) throws Exception {
|
public Document getSeriesRecord(TheTVDBSearchResult searchResult, String languageCode) throws Exception {
|
||||||
URL seriesRecord = getResource(MirrorType.ZIP, "/api/" + apikey + "/series/" + searchResult.getSeriesId() + "/all/" + languageCode + ".zip");
|
URL seriesRecord = getResource(MirrorType.ZIP, "/api/" + apikey + "/series/" + searchResult.getSeriesId() + "/all/" + languageCode + ".zip");
|
||||||
|
|
||||||
|
@ -217,7 +215,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TheTVDBSearchResult lookupByID(int id, Locale locale) throws Exception {
|
public TheTVDBSearchResult lookupByID(int id, Locale locale) throws Exception {
|
||||||
TheTVDBSearchResult cachedItem = getCache().getData("lookupByID", id, locale, TheTVDBSearchResult.class);
|
TheTVDBSearchResult cachedItem = getCache().getData("lookupByID", id, locale, TheTVDBSearchResult.class);
|
||||||
if (cachedItem != null) {
|
if (cachedItem != null) {
|
||||||
|
@ -240,7 +237,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TheTVDBSearchResult lookupByIMDbID(int imdbid, Locale locale) throws Exception {
|
public TheTVDBSearchResult lookupByIMDbID(int imdbid, Locale locale) throws Exception {
|
||||||
TheTVDBSearchResult cachedItem = getCache().getData("lookupByIMDbID", imdbid, locale, TheTVDBSearchResult.class);
|
TheTVDBSearchResult cachedItem = getCache().getData("lookupByIMDbID", imdbid, locale, TheTVDBSearchResult.class);
|
||||||
if (cachedItem != null) {
|
if (cachedItem != null) {
|
||||||
|
@ -261,13 +257,11 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getEpisodeListLink(SearchResult searchResult) {
|
public URI getEpisodeListLink(SearchResult searchResult) {
|
||||||
return URI.create("http://" + host + "/?tab=seasonall&id=" + ((TheTVDBSearchResult) searchResult).getSeriesId());
|
return URI.create("http://" + host + "/?tab=seasonall&id=" + ((TheTVDBSearchResult) searchResult).getSeriesId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String getMirror(MirrorType mirrorType) throws Exception {
|
protected String getMirror(MirrorType mirrorType) throws Exception {
|
||||||
synchronized (mirrors) {
|
synchronized (mirrors) {
|
||||||
if (mirrors.isEmpty()) {
|
if (mirrors.isEmpty()) {
|
||||||
|
@ -324,7 +318,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected URL getResource(MirrorType mirrorType, String path) throws Exception {
|
protected URL getResource(MirrorType mirrorType, String path) throws Exception {
|
||||||
if (mirrorType != null) {
|
if (mirrorType != null) {
|
||||||
// use mirror
|
// use mirror
|
||||||
|
@ -338,18 +331,15 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return new URL("http", host, path);
|
return new URL("http", host, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static enum MirrorType {
|
protected static enum MirrorType {
|
||||||
XML(1), BANNER(2), ZIP(4), SEARCH(1);
|
XML(1), BANNER(2), ZIP(4), SEARCH(1);
|
||||||
|
|
||||||
private final int bitMask;
|
private final int bitMask;
|
||||||
|
|
||||||
|
|
||||||
private MirrorType(int bitMask) {
|
private MirrorType(int bitMask) {
|
||||||
this.bitMask = bitMask;
|
this.bitMask = bitMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static EnumSet<MirrorType> fromTypeMask(int typeMask) {
|
public static EnumSet<MirrorType> fromTypeMask(int typeMask) {
|
||||||
// initialize enum set with all types
|
// initialize enum set with all types
|
||||||
EnumSet<MirrorType> enumSet = EnumSet.allOf(MirrorType.class);
|
EnumSet<MirrorType> enumSet = EnumSet.allOf(MirrorType.class);
|
||||||
|
@ -364,17 +354,14 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SeriesInfo getSeriesInfoByID(int thetvdbid, Locale locale) throws Exception {
|
public SeriesInfo getSeriesInfoByID(int thetvdbid, Locale locale) throws Exception {
|
||||||
return getSeriesInfo(new TheTVDBSearchResult(null, thetvdbid), locale);
|
return getSeriesInfo(new TheTVDBSearchResult(null, thetvdbid), locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SeriesInfo getSeriesInfoByIMDbID(int imdbid, Locale locale) throws Exception {
|
public SeriesInfo getSeriesInfoByIMDbID(int imdbid, Locale locale) throws Exception {
|
||||||
return getSeriesInfo(lookupByIMDbID(imdbid, locale), locale);
|
return getSeriesInfo(lookupByIMDbID(imdbid, locale), locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SeriesInfo getSeriesInfoByName(String name, Locale locale) throws Exception {
|
public SeriesInfo getSeriesInfoByName(String name, Locale locale) throws Exception {
|
||||||
for (SearchResult it : search(name, locale)) {
|
for (SearchResult it : search(name, locale)) {
|
||||||
if (name.equalsIgnoreCase(it.getName())) {
|
if (name.equalsIgnoreCase(it.getName())) {
|
||||||
|
@ -385,7 +372,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SeriesInfo getSeriesInfo(TheTVDBSearchResult searchResult, Locale locale) throws Exception {
|
public SeriesInfo getSeriesInfo(TheTVDBSearchResult searchResult, Locale locale) throws Exception {
|
||||||
// check cache first
|
// check cache first
|
||||||
SeriesInfo cachedItem = getCache().getData("seriesInfo", searchResult.seriesId, locale, SeriesInfo.class);
|
SeriesInfo cachedItem = getCache().getData("seriesInfo", searchResult.seriesId, locale, SeriesInfo.class);
|
||||||
|
@ -414,7 +400,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return seriesInfo;
|
return seriesInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class SeriesInfo implements Serializable {
|
public static class SeriesInfo implements Serializable {
|
||||||
|
|
||||||
public static enum SeriesProperty {
|
public static enum SeriesProperty {
|
||||||
|
@ -423,27 +408,22 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
protected Map<SeriesProperty, String> fields;
|
protected Map<SeriesProperty, String> fields;
|
||||||
|
|
||||||
|
|
||||||
protected SeriesInfo() {
|
protected SeriesInfo() {
|
||||||
// used by serializer
|
// used by serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected SeriesInfo(Map<SeriesProperty, String> fields) {
|
protected SeriesInfo(Map<SeriesProperty, String> fields) {
|
||||||
this.fields = new EnumMap<SeriesProperty, String>(fields);
|
this.fields = new EnumMap<SeriesProperty, String>(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String get(Object key) {
|
public String get(Object key) {
|
||||||
return fields.get(SeriesProperty.valueOf(key.toString()));
|
return fields.get(SeriesProperty.valueOf(key.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String get(SeriesProperty key) {
|
public String get(SeriesProperty key) {
|
||||||
return fields.get(key);
|
return fields.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
// e.g. 80348
|
// e.g. 80348
|
||||||
try {
|
try {
|
||||||
|
@ -453,19 +433,16 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<String> getActors() {
|
public List<String> getActors() {
|
||||||
// e.g. |Zachary Levi|Adam Baldwin|Yvonne Strzechowski|
|
// e.g. |Zachary Levi|Adam Baldwin|Yvonne Strzechowski|
|
||||||
return split(get(SeriesProperty.Actors));
|
return split(get(SeriesProperty.Actors));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<String> getGenres() {
|
public List<String> getGenres() {
|
||||||
// e.g. |Comedy|
|
// e.g. |Comedy|
|
||||||
return split(get(SeriesProperty.Genre));
|
return split(get(SeriesProperty.Genre));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected List<String> split(String values) {
|
protected List<String> split(String values) {
|
||||||
List<String> items = new ArrayList<String>();
|
List<String> items = new ArrayList<String>();
|
||||||
if (values != null && values.length() > 0) {
|
if (values != null && values.length() > 0) {
|
||||||
|
@ -479,36 +456,30 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getAirDayOfWeek() {
|
public String getAirDayOfWeek() {
|
||||||
// e.g. Monday
|
// e.g. Monday
|
||||||
return get(SeriesProperty.Airs_DayOfWeek);
|
return get(SeriesProperty.Airs_DayOfWeek);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getAirTime() {
|
public String getAirTime() {
|
||||||
// e.g. 8:00 PM
|
// e.g. 8:00 PM
|
||||||
return get(SeriesProperty.Airs_Time);
|
return get(SeriesProperty.Airs_Time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Date getFirstAired() {
|
public Date getFirstAired() {
|
||||||
// e.g. 2007-09-24
|
// e.g. 2007-09-24
|
||||||
return Date.parse(get(SeriesProperty.FirstAired), "yyyy-MM-dd");
|
return Date.parse(get(SeriesProperty.FirstAired), "yyyy-MM-dd");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getContentRating() {
|
public String getContentRating() {
|
||||||
// e.g. TV-PG
|
// e.g. TV-PG
|
||||||
return get(SeriesProperty.ContentRating);
|
return get(SeriesProperty.ContentRating);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getCertification() {
|
public String getCertification() {
|
||||||
return getContentRating(); // another getter for compability reasons
|
return getContentRating(); // another getter for compability reasons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getImdbId() {
|
public Integer getImdbId() {
|
||||||
// e.g. tt0934814
|
// e.g. tt0934814
|
||||||
try {
|
try {
|
||||||
|
@ -518,7 +489,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Locale getLanguage() {
|
public Locale getLanguage() {
|
||||||
// e.g. en
|
// e.g. en
|
||||||
try {
|
try {
|
||||||
|
@ -528,13 +498,11 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getOverview() {
|
public String getOverview() {
|
||||||
// e.g. Zachary Levi (Less Than Perfect) plays Chuck...
|
// e.g. Zachary Levi (Less Than Perfect) plays Chuck...
|
||||||
return get(SeriesProperty.Overview);
|
return get(SeriesProperty.Overview);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Double getRating() {
|
public Double getRating() {
|
||||||
// e.g. 9.0
|
// e.g. 9.0
|
||||||
try {
|
try {
|
||||||
|
@ -544,7 +512,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getRatingCount() {
|
public Integer getRatingCount() {
|
||||||
// e.g. 696
|
// e.g. 696
|
||||||
try {
|
try {
|
||||||
|
@ -554,31 +521,26 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getRuntime() {
|
public String getRuntime() {
|
||||||
// e.g. 30
|
// e.g. 30
|
||||||
return get(SeriesProperty.Runtime);
|
return get(SeriesProperty.Runtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
// e.g. Chuck
|
// e.g. Chuck
|
||||||
return get(SeriesProperty.SeriesName);
|
return get(SeriesProperty.SeriesName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getNetwork() {
|
public String getNetwork() {
|
||||||
// e.g. CBS
|
// e.g. CBS
|
||||||
return get(SeriesProperty.Network);
|
return get(SeriesProperty.Network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
// e.g. Continuing
|
// e.g. Continuing
|
||||||
return get(SeriesProperty.Status);
|
return get(SeriesProperty.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getBannerMirrorUrl() {
|
public URL getBannerMirrorUrl() {
|
||||||
try {
|
try {
|
||||||
return new URL(get(BannerProperty.BannerMirror));
|
return new URL(get(BannerProperty.BannerMirror));
|
||||||
|
@ -587,7 +549,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getBannerUrl() throws MalformedURLException {
|
public URL getBannerUrl() throws MalformedURLException {
|
||||||
try {
|
try {
|
||||||
return new URL(getBannerMirrorUrl(), get(SeriesProperty.banner));
|
return new URL(getBannerMirrorUrl(), get(SeriesProperty.banner));
|
||||||
|
@ -596,7 +557,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getFanartUrl() {
|
public URL getFanartUrl() {
|
||||||
try {
|
try {
|
||||||
return new URL(getBannerMirrorUrl(), get(SeriesProperty.fanart));
|
return new URL(getBannerMirrorUrl(), get(SeriesProperty.fanart));
|
||||||
|
@ -605,7 +565,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getPosterUrl() {
|
public URL getPosterUrl() {
|
||||||
try {
|
try {
|
||||||
return new URL(getBannerMirrorUrl(), get(SeriesProperty.poster));
|
return new URL(getBannerMirrorUrl(), get(SeriesProperty.poster));
|
||||||
|
@ -614,14 +573,12 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return fields.toString();
|
return fields.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a series banner matching the given parameters
|
* Search for a series banner matching the given parameters
|
||||||
*
|
*
|
||||||
|
@ -645,7 +602,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<BannerDescriptor> getBannerList(TheTVDBSearchResult series) throws Exception {
|
public List<BannerDescriptor> getBannerList(TheTVDBSearchResult series) throws Exception {
|
||||||
// check cache first
|
// check cache first
|
||||||
BannerDescriptor[] cachedList = getCache().getData("banners", series.seriesId, null, BannerDescriptor[].class);
|
BannerDescriptor[] cachedList = getCache().getData("banners", series.seriesId, null, BannerDescriptor[].class);
|
||||||
|
@ -684,7 +640,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
return banners;
|
return banners;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class BannerDescriptor implements Serializable {
|
public static class BannerDescriptor implements Serializable {
|
||||||
|
|
||||||
public static enum BannerProperty {
|
public static enum BannerProperty {
|
||||||
|
@ -693,27 +648,22 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
protected Map<BannerProperty, String> fields;
|
protected Map<BannerProperty, String> fields;
|
||||||
|
|
||||||
|
|
||||||
protected BannerDescriptor() {
|
protected BannerDescriptor() {
|
||||||
// used by serializer
|
// used by serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected BannerDescriptor(Map<BannerProperty, String> fields) {
|
protected BannerDescriptor(Map<BannerProperty, String> fields) {
|
||||||
this.fields = new EnumMap<BannerProperty, String>(fields);
|
this.fields = new EnumMap<BannerProperty, String>(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String get(Object key) {
|
public String get(Object key) {
|
||||||
return fields.get(BannerProperty.valueOf(key.toString()));
|
return fields.get(BannerProperty.valueOf(key.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String get(BannerProperty key) {
|
public String get(BannerProperty key) {
|
||||||
return fields.get(key);
|
return fields.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getBannerMirrorUrl() throws MalformedURLException {
|
public URL getBannerMirrorUrl() throws MalformedURLException {
|
||||||
try {
|
try {
|
||||||
return new URL(get(BannerProperty.BannerMirror));
|
return new URL(get(BannerProperty.BannerMirror));
|
||||||
|
@ -722,7 +672,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getUrl() throws MalformedURLException {
|
public URL getUrl() throws MalformedURLException {
|
||||||
try {
|
try {
|
||||||
return new URL(getBannerMirrorUrl(), get(BannerProperty.BannerPath));
|
return new URL(getBannerMirrorUrl(), get(BannerProperty.BannerPath));
|
||||||
|
@ -731,12 +680,10 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getExtension() {
|
public String getExtension() {
|
||||||
return FileUtilities.getExtension(get(BannerProperty.BannerPath));
|
return FileUtilities.getExtension(get(BannerProperty.BannerPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
try {
|
try {
|
||||||
return new Integer(get(BannerProperty.id));
|
return new Integer(get(BannerProperty.id));
|
||||||
|
@ -745,17 +692,14 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getBannerType() {
|
public String getBannerType() {
|
||||||
return get(BannerProperty.BannerType);
|
return get(BannerProperty.BannerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getBannerType2() {
|
public String getBannerType2() {
|
||||||
return get(BannerProperty.BannerType2);
|
return get(BannerProperty.BannerType2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getSeason() {
|
public Integer getSeason() {
|
||||||
try {
|
try {
|
||||||
return new Integer(get(BannerProperty.Season));
|
return new Integer(get(BannerProperty.Season));
|
||||||
|
@ -764,12 +708,10 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getColors() {
|
public String getColors() {
|
||||||
return get(BannerProperty.Colors);
|
return get(BannerProperty.Colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Locale getLocale() {
|
public Locale getLocale() {
|
||||||
try {
|
try {
|
||||||
return new Locale(get(BannerProperty.Language));
|
return new Locale(get(BannerProperty.Language));
|
||||||
|
@ -778,7 +720,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Double getRating() {
|
public Double getRating() {
|
||||||
try {
|
try {
|
||||||
return new Double(get(BannerProperty.Rating));
|
return new Double(get(BannerProperty.Rating));
|
||||||
|
@ -787,7 +728,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getRatingCount() {
|
public Integer getRatingCount() {
|
||||||
try {
|
try {
|
||||||
return new Integer(get(BannerProperty.RatingCount));
|
return new Integer(get(BannerProperty.RatingCount));
|
||||||
|
@ -796,12 +736,10 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean hasSeriesName() {
|
public boolean hasSeriesName() {
|
||||||
return Boolean.parseBoolean(get(BannerProperty.SeriesName));
|
return Boolean.parseBoolean(get(BannerProperty.SeriesName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getThumbnailUrl() throws MalformedURLException {
|
public URL getThumbnailUrl() throws MalformedURLException {
|
||||||
try {
|
try {
|
||||||
return new URL(getBannerMirrorUrl(), get(BannerProperty.ThumbnailPath));
|
return new URL(getBannerMirrorUrl(), get(BannerProperty.ThumbnailPath));
|
||||||
|
@ -810,7 +748,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getVignetteUrl() throws MalformedURLException {
|
public URL getVignetteUrl() throws MalformedURLException {
|
||||||
try {
|
try {
|
||||||
return new URL(getBannerMirrorUrl(), get(BannerProperty.VignettePath));
|
return new URL(getBannerMirrorUrl(), get(BannerProperty.VignettePath));
|
||||||
|
@ -819,7 +756,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return fields.toString();
|
return fields.toString();
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.web;
|
package net.sourceforge.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,34 +5,32 @@ public class TheTVDBSearchResult extends SearchResult {
|
||||||
|
|
||||||
protected int seriesId;
|
protected int seriesId;
|
||||||
|
|
||||||
|
|
||||||
protected TheTVDBSearchResult() {
|
protected TheTVDBSearchResult() {
|
||||||
// used by serializer
|
// used by serializer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TheTVDBSearchResult(String seriesName, int seriesId) {
|
public TheTVDBSearchResult(String seriesName, int seriesId) {
|
||||||
super(seriesName);
|
this(seriesName, new String[0], seriesId);
|
||||||
this.seriesId = seriesId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TheTVDBSearchResult(String seriesName, String[] aliasNames, int seriesId) {
|
||||||
|
super(seriesName, aliasNames);
|
||||||
|
this.seriesId = seriesId;
|
||||||
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return seriesId;
|
return seriesId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getSeriesId() {
|
public int getSeriesId() {
|
||||||
return seriesId;
|
return seriesId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return seriesId;
|
return seriesId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (object instanceof TheTVDBSearchResult) {
|
if (object instanceof TheTVDBSearchResult) {
|
||||||
|
|
Loading…
Reference in New Issue