+ new bindings {tags}

This commit is contained in:
Reinhard Pointner 2014-06-29 11:04:04 +00:00
parent 24f96b5ade
commit 06a342cdef
4 changed files with 49 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package net.filebot.format;
import static java.util.Arrays.*; import static java.util.Arrays.*;
import static net.filebot.MediaTypes.*; import static net.filebot.MediaTypes.*;
import static net.filebot.format.Define.*; import static net.filebot.format.Define.*;
import static net.filebot.format.ExpressionFormatMethods.*;
import static net.filebot.hash.VerificationUtilities.*; import static net.filebot.hash.VerificationUtilities.*;
import static net.filebot.media.MediaDetection.*; import static net.filebot.media.MediaDetection.*;
import static net.filebot.similarity.Normalization.*; import static net.filebot.similarity.Normalization.*;
@ -426,6 +427,25 @@ public class MediaBindingBean {
return releaseInfo.getVideoSource(inferredMediaFile.getParent(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile)); return releaseInfo.getVideoSource(inferredMediaFile.getParent(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile));
} }
@Define("tags")
public List<String> getVideoTags() {
// use inferred media file
File inferredMediaFile = getInferredMediaFile();
// look for video source patterns in media file and it's parent folder
List<String> matches = releaseInfo.getVideoTags(inferredMediaFile.getParent(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile));
if (matches.isEmpty()) {
return null;
}
Set<String> tags = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (String m : matches) {
// heavy normalization of whatever pattern was matched with the regex pattern
tags.add(lowerTrail(upperInitial(normalizePunctuation(normalizeSpace(m, " ")))));
}
return new ArrayList<String>(tags);
}
@Define("group") @Define("group")
public String getReleaseGroup() throws IOException { public String getReleaseGroup() throws IOException {
// use inferred media file // use inferred media file

View File

@ -42,9 +42,24 @@ import org.tukaani.xz.XZInputStream;
public class ReleaseInfo { public class ReleaseInfo {
public String getVideoSource(String... strings) { public String getVideoSource(String... input) {
// check parent and itself for group names // check parent and itself for group names
return matchLast(getVideoSourcePattern(), getBundle(getClass().getName()).getString("pattern.video.source").split("[|]"), strings); return matchLast(getVideoSourcePattern(), getBundle(getClass().getName()).getString("pattern.video.source").split("[|]"), input);
}
public List<String> getVideoTags(String... input) {
Pattern videoTagPattern = getVideoTagPattern();
List<String> tags = new ArrayList<String>();
for (String s : input) {
if (s == null)
continue;
Matcher m = videoTagPattern.matcher(s);
while (m.find()) {
tags.add(m.group());
}
}
return tags;
} }
public String getReleaseGroup(String... strings) throws IOException { public String getReleaseGroup(String... strings) throws IOException {
@ -240,11 +255,17 @@ public class ReleaseInfo {
} }
public Pattern getVideoSourcePattern() { public Pattern getVideoSourcePattern() {
// pattern matching any video source name // pattern matching any video source name, like BluRay
String pattern = getBundle(getClass().getName()).getString("pattern.video.source"); String pattern = getBundle(getClass().getName()).getString("pattern.video.source");
return compile("(?<!\\p{Alnum})(" + pattern + ")(?!\\p{Alnum})", CASE_INSENSITIVE); return compile("(?<!\\p{Alnum})(" + pattern + ")(?!\\p{Alnum})", CASE_INSENSITIVE);
} }
public Pattern getVideoTagPattern() {
// pattern matching any video tag, like Directors Cut
String pattern = getBundle(getClass().getName()).getString("pattern.video.tags");
return compile("(?<!\\p{Alnum})(" + pattern + ")(?!\\p{Alnum})", CASE_INSENSITIVE);
}
public Pattern getClutterBracketPattern(boolean strict) { public Pattern getClutterBracketPattern(boolean strict) {
// match patterns like [Action, Drama] or {ENG-XViD-MP3-DVDRiP} etc // match patterns like [Action, Drama] or {ENG-XViD-MP3-DVDRiP} etc
String contentFilter = strict ? "[\\p{Space}\\p{Punct}&&[^\\[\\]]]" : "\\p{Alpha}"; String contentFilter = strict ? "[\\p{Space}\\p{Punct}&&[^\\[\\]]]" : "\\p{Alpha}";

View File

@ -1,6 +1,9 @@
# source names mostly copied from [http://en.wikipedia.org/wiki/Pirated_movie_release_types] # patterns for all video sources
pattern.video.source: CAMRip|CAM|PDVD|TS|TELESYNC|PDVD|PTVD|PPV|PPVRip|Screener|SCR|SCREENER|DVDSCR|DVDSCREENER|BDSCR|R4|R5|R5LINE|R5.LINE|DVD|DVD5|DVD9|DVDRip|DVDR|TVRip|DSR|PDTV|SDTV|HDTV|DVB|DVBRip|DTHRip|VODRip|VODR|BDRip|BRRip|BluRay|BDR|BD25|BD50|3D.BluRay|3DBluRay|3DBD|BR.Scr|BR.Screener|HDDVD|HDRip|WorkPrint|VHS|VCD|TELECINE|WEB.DL|WEBRip|ithd|iTunesHD|Laserdisc pattern.video.source: CAMRip|CAM|PDVD|TS|TELESYNC|PDVD|PTVD|PPV|PPVRip|Screener|SCR|SCREENER|DVDSCR|DVDSCREENER|BDSCR|R4|R5|R5LINE|R5.LINE|DVD|DVD5|DVD9|DVDRip|DVDR|TVRip|DSR|PDTV|SDTV|HDTV|DVB|DVBRip|DTHRip|VODRip|VODR|BDRip|BRRip|BluRay|BDR|BD25|BD50|3D.BluRay|3DBluRay|3DBD|BR.Scr|BR.Screener|HDDVD|HDRip|WorkPrint|VHS|VCD|TELECINE|WEB.DL|WEBRip|ithd|iTunesHD|Laserdisc
# patterns for all video tags
pattern.video.tags: extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition
# additional release info patterns # additional release info patterns
pattern.video.format: DivX|Xvid|AVC|x264|h264|h.264|3ivx|mpg|mpeg|mpeg4|mp3|AAC|AAC2.0|AAC5.1|AAC.2.0|AAC.5.1|AC3|dd20|dd51|2ch|6ch|DTS|DTS.HD|DTS.HD.MA|TrueHD|720p|1080p|10bit|(19|20)[0-9]+(.)S[0-9]+(?!(.)?E[0-9]+) pattern.video.format: DivX|Xvid|AVC|x264|h264|h.264|3ivx|mpg|mpeg|mpeg4|mp3|AAC|AAC2.0|AAC5.1|AAC.2.0|AAC.5.1|AC3|dd20|dd51|2ch|6ch|DTS|DTS.HD|DTS.HD.MA|TrueHD|720p|1080p|10bit|(19|20)[0-9]+(.)S[0-9]+(?!(.)?E[0-9]+)

View File

@ -2,4 +2,4 @@
parameter.exclude: ^StreamKind|Count$ parameter.exclude: ^StreamKind|Count$
# preview expressions (keys are tagged so they can be sorted alphabetically) # 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,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,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,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