diff --git a/source/net/sourceforge/filebot/format/MediaBindingBean.java b/source/net/sourceforge/filebot/format/MediaBindingBean.java index 96edbd03..1a8c1705 100644 --- a/source/net/sourceforge/filebot/format/MediaBindingBean.java +++ b/source/net/sourceforge/filebot/format/MediaBindingBean.java @@ -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"); diff --git a/source/net/sourceforge/filebot/ui/rename/BindingDialog.properties b/source/net/sourceforge/filebot/ui/rename/BindingDialog.properties index 20c42884..02698519 100644 --- a/source/net/sourceforge/filebot/ui/rename/BindingDialog.properties +++ b/source/net/sourceforge/filebot/ui/rename/BindingDialog.properties @@ -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 diff --git a/source/net/sourceforge/filebot/ui/rename/FormatDialog.properties b/source/net/sourceforge/filebot/ui/rename/FormatDialog.properties index fb2a4ef5..a2162ee9 100644 --- a/source/net/sourceforge/filebot/ui/rename/FormatDialog.properties +++ b/source/net/sourceforge/filebot/ui/rename/FormatDialog.properties @@ -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)} diff --git a/source/net/sourceforge/filebot/web/EpisodeFormat.java b/source/net/sourceforge/filebot/web/EpisodeFormat.java index 122c2ab4..17b13e3a 100644 --- a/source/net/sourceforge/filebot/web/EpisodeFormat.java +++ b/source/net/sourceforge/filebot/web/EpisodeFormat.java @@ -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})\\]");