From db9dc0f9e9442f2fc8fabad749664a9ea25b8e03 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 26 Jan 2016 11:29:16 +0000 Subject: [PATCH] Added {az} SortInitial binding. --- .../filebot/format/ExpressionFormatMethods.java | 15 +++++++++++++++ source/net/filebot/format/MediaBindingBean.java | 9 +++++++++ .../filebot/ui/rename/BindingDialog.properties | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/format/ExpressionFormatMethods.java b/source/net/filebot/format/ExpressionFormatMethods.java index 1fef898f..c34c6df6 100644 --- a/source/net/filebot/format/ExpressionFormatMethods.java +++ b/source/net/filebot/format/ExpressionFormatMethods.java @@ -133,6 +133,21 @@ public class ExpressionFormatMethods { return compile("^(The|A|An)\\s(.+)", CASE_INSENSITIVE).matcher(self).replaceFirst(replacement).trim(); } + public static String sortInitial(String self) { + // use primary initial, ignore The XY, A XY, etc + String s = ascii(sortName(self)).toUpperCase(); + int c = s.codePointAt(0); + + if (Character.isDigit(c)) { + return "0-9"; + } + if (Character.isLetter(c)) { + return String.valueOf(Character.toChars(c)); + } + + return null; + } + /** * Get acronym, i.e. first letter of each word. * diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index 13ccc69d..e926caa9 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -610,6 +610,15 @@ public class MediaBindingBean { return createMapBindings(new PropertyBindings(metaInfo, null)); } + @Define("az") + public String getSortInitial() { + try { + return sortInitial(getCollection().toString()); + } catch (Exception e) { + return sortInitial(getName()); + } + } + @Define("episodelist") public Object getEpisodeList() throws Exception { return WebServices.getEpisodeListProvider(getSeriesInfo().getDatabase()).getEpisodeList(getSeriesInfo().getId(), SortOrder.forName(getSeriesInfo().getOrder()), new Locale(getSeriesInfo().getLanguage())); diff --git a/source/net/filebot/ui/rename/BindingDialog.properties b/source/net/filebot/ui/rename/BindingDialog.properties index 4fe39d8f..713cb139 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,tags,s3d,group,original,fn,ext,mediaType,file,file.name,folder,folder.name,gigabytes,crc32,info,info.runtime,info.status,omdb.rating,omdb.votes,localize.German.title,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 +expressions: n,y,s,e,es,sxe,s00e00,t,d,startdate,absolute,special,episode,series,primaryTitle,alias,movie,tmdbid,imdbid,az,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,tags,s3d,group,original,fn,ext,mediaType,file,file.name,folder,folder.name,gigabytes,crc32,info,info.runtime,info.status,omdb.rating,omdb.votes,localize.German.title,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