From ffcf61472d748425283df07fc7fe540ac0601404 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 12 May 2014 15:45:19 +0000 Subject: [PATCH] * new binding {age} meaning "days since airdate" --- source/net/filebot/format/MediaBindingBean.java | 10 ++++++++-- source/net/filebot/ui/rename/BindingDialog.properties | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index dcbdd444..ccefe151 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -23,6 +23,7 @@ import java.util.Scanner; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -146,12 +147,12 @@ public class MediaBindingBean { } @Define("d") - public Object getReleaseDate() { + public SimpleDate getReleaseDate() { if (infoObject instanceof Episode) { return getEpisode().getAirdate(); } if (infoObject instanceof Movie) { - return getMetaInfo().getProperty("released"); + return (SimpleDate) getMetaInfo().getProperty("released"); } if (infoObject instanceof AudioTrack) { return getMusic().getAlbumReleaseDate(); @@ -166,6 +167,11 @@ public class MediaBindingBean { return getEpisode().getAirdate(); } + @Define("age") + public Number getAgeInDays() { + return TimeUnit.MILLISECONDS.toDays(getNow() - getReleaseDate().getTimeStamp()); + } + @Define("startdate") public SimpleDate startdate() { return getEpisode().getSeriesStartDate(); diff --git a/source/net/filebot/ui/rename/BindingDialog.properties b/source/net/filebot/ui/rename/BindingDialog.properties index fe3d1540..eb54a035 100644 --- a/source/net/filebot/ui/rename/BindingDialog.properties +++ b/source/net/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,es,sxe,s00e00,t,d,startdate,absolute,special,episode,series,primaryTitle,alias,movie,tmdbid,imdbid,music,artist,albumArtist,album,pi,pn,lang,actors,director,collection,genre,genres,certification,rating,vc,ac,cf,vf,hpi,af,resolution,dim,ws,sdhd,source,group,original,fn,ext,mediaType,file,file.name,folder,folder.name,crc32,info,info.runtime,info.status,imdb,imdb.rating,imdb.votes,duration,seconds,minutes,media,media.title,media.overallBitRateString,video,video.codecID,video.frameRate,video.displayAspectRatioString,video.scanType,audio,audio.bitRateString,audio.language,audios,audios.language,text,text.codecInfo,text.language,texts,texts.language \ No newline at end of file +expressions: n,y,s,e,es,sxe,s00e00,t,d,startdate,absolute,special,episode,series,primaryTitle,alias,movie,tmdbid,imdbid,music,artist,albumArtist,album,pi,pn,lang,actors,director,collection,genre,genres,certification,rating,vc,ac,cf,vf,hpi,af,resolution,dim,ws,sdhd,source,group,original,fn,ext,mediaType,file,file.name,folder,folder.name,crc32,info,info.runtime,info.status,imdb,imdb.rating,imdb.votes,age,duration,seconds,minutes,media,media.title,media.overallBitRateString,video,video.codecID,video.frameRate,video.displayAspectRatioString,video.scanType,audio,audio.bitRateString,audio.language,audios,audios.language,text,text.codecInfo,text.language,texts,texts.language \ No newline at end of file