* added convenience bindings {SxE} and {S00E00}

* added widescreen mi binding {ws}
This commit is contained in:
Reinhard Pointner 2011-11-20 18:38:49 +00:00
parent e26ae9f4e7
commit 469de911e6
4 changed files with 62 additions and 4 deletions

View File

@ -5,6 +5,7 @@ package net.sourceforge.filebot.format;
import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.filebot.format.Define.*;
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
import static net.sourceforge.filebot.web.EpisodeFormat.*;
import java.io.File;
import java.io.IOException;
@ -78,6 +79,18 @@ public class MediaBindingBean {
}
@Define("SxE")
public String getSxE() {
return SeasonEpisode.formatSxE(getEpisode());
}
@Define("S00E00")
public String getS00E00() {
return SeasonEpisode.formatS00E00(getEpisode());
}
@Define("t")
public String getTitle() {
return getEpisode().getTitle();
@ -187,6 +200,16 @@ public class MediaBindingBean {
}
@Define("ws")
public String getWidescreen() {
float width = Integer.parseInt(getMediaInfo(StreamKind.Video, 0, "Width"));
float height = Integer.parseInt(getMediaInfo(StreamKind.Video, 0, "Height"));
// width-to-height aspect ratio greater than 1.37:1
return width / height > 1.37 ? "ws" : null;
}
@Define("sdhd")
public String getVideoDefinitionCategory() {
String height = getMediaInfo(StreamKind.Video, 0, "Height");

View File

@ -2,4 +2,4 @@
parameter.exclude: ^StreamKind|Count$
# preview expressions (keys are tagged so they can be sorted alphabetically)
expressions: n,y,s,e,t,airdate,startdate,absolute,special,imdb,episode,movie,vc,ac,cf,vf,af,resolution,sdhd,source,group,crc32,fn,ext,file,pi,pn,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language
expressions: n,y,s,e,t,airdate,startdate,absolute,special,imdb,episode,SxE,S00E00,movie,vc,ac,cf,vf,af,resolution,ws,sdhd,source,group,crc32,fn,ext,file,pi,pn,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language

View File

@ -7,9 +7,9 @@ movie.sample: Avatar (2009) Part 1
# basic 1.01
episode.example[0]: {n} - {s}.{e} - {t}
# S01E01
episode.example[1]: {n} - {'S'+s.pad(2)}E{e.pad(2)} - {t}
# 1x01
episode.example[2]: {n} - {s+'x'}{e.pad(2)} - {t}
episode.example[1]: {n} - {S00E00} - {t}
# airdate
episode.example[2]: {n} [{airdate}] {t}
# uglyfy name
episode.example[3]: {n.space('.').lower()}.{s}{e.pad(2)}

View File

@ -59,6 +59,41 @@ public class EpisodeFormat extends Format {
}
public String formatSxE(Episode episode) {
StringBuilder sb = new StringBuilder();
if (episode.getSeason() != null) {
sb.append(episode.getSeason()).append('x');
}
if (episode.getEpisode() != null) {
sb.append(String.format("%02d", episode.getEpisode()));
} else if (includeSpecial && episode.getSpecial() != null) {
sb.append("Special " + episode.getSpecial());
}
return sb.toString();
}
public String formatS00E00(Episode episode) {
StringBuilder sb = new StringBuilder();
if (episode.getSeason() != null) {
sb.append(String.format("S%02d", episode.getSeason()));
}
if (episode.getEpisode() != null) {
sb.append(String.format("E%02d", episode.getEpisode()));
} else if (includeSpecial && episode.getSpecial() != null) {
sb.append(episode.getSeason() != null ? " - " : "");
sb.append("Special " + episode.getSpecial());
}
return sb.toString();
}
private final Pattern sxePattern = Pattern.compile("- (?:(\\d{1,2})x)?(Special )?(\\d{1,3}) -");
private final Pattern airdatePattern = Pattern.compile("\\[(\\d{4}-\\d{1,2}-\\d{1,2})\\]");