From 6d0d7ca75e2c372ceb621dbea61f1c7068ff1823 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 19 Apr 2013 09:28:55 +0000 Subject: [PATCH] * script bindings for MetaAttributes and added related auto-detection to amc script * support Mar.adentro.2004.HDTVRip.720p => The Sea Inside 2004 (@see http://www.filebot.net/forums/viewtopic.php?f=6&t=680&p=4512#p4512) --- source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy | 7 +++++++ .../net/sourceforge/filebot/format/MediaBindingBean.java | 2 +- source/net/sourceforge/filebot/media/MediaDetection.java | 6 +++--- source/net/sourceforge/filebot/media/MetaAttributes.java | 4 ++-- .../net/sourceforge/filebot/similarity/EpisodeMetrics.java | 2 +- .../net/sourceforge/filebot/ui/rename/BindingDialog.java | 2 +- website/data/release-groups.txt | 1 + website/scripts/amc.groovy | 4 ++-- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index 77ec0d36..2d9272ee 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -183,6 +183,12 @@ File.metaClass.watch = { c -> createWatchService(c, [delegate], true) } List.metaClass.watch = { c -> createWatchService(c, delegate, true) } +// FileBot MetaAttributes helpers +import net.sourceforge.filebot.media.MetaAttributes + +File.metaClass.getMetadata = { net.sourceforge.filebot.Settings.useExtendedFileAttributes() ? new MetaAttributes(delegate) : null } + + // Complete or session rename history def getRenameLog(complete = false) { def spooler = net.sourceforge.filebot.HistorySpooler.getInstance() @@ -190,6 +196,7 @@ def getRenameLog(complete = false) { return history.sequences*.elements.flatten().collectEntries{ [new File(it.dir, it.from), new File(it.to).isAbsolute() ? new File(it.to) : new File(it.dir, it.to)] } } + // Season / Episode helpers import net.sourceforge.filebot.similarity.* diff --git a/source/net/sourceforge/filebot/format/MediaBindingBean.java b/source/net/sourceforge/filebot/format/MediaBindingBean.java index 420063bc..0e1c4e59 100644 --- a/source/net/sourceforge/filebot/format/MediaBindingBean.java +++ b/source/net/sourceforge/filebot/format/MediaBindingBean.java @@ -815,7 +815,7 @@ public class MediaBindingBean { private Object getMetaAttributesObject(File file) { if (useExtendedFileAttributes()) { try { - return new MetaAttributes(file).getMetaData(); + return new MetaAttributes(file).getObject(); } catch (Throwable e) { // ignore } diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 504974b5..c5f19131 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -256,7 +256,7 @@ public class MediaDetection { for (File it : files) { MetaAttributes xattr = new MetaAttributes(it); try { - Episode episode = (Episode) xattr.getMetaData(); + Episode episode = (Episode) xattr.getObject(); names.add(episode.getSeriesName()); } catch (Exception e) { // can't read meta attributes => ignore @@ -469,7 +469,7 @@ public class MediaDetection { try { MetaAttributes xattr = new MetaAttributes(movieFile); try { - Movie movie = (Movie) xattr.getMetaData(); + Movie movie = (Movie) xattr.getObject(); if (movie != null) { options.add(new Movie(movie)); // normalize as movie object } @@ -984,7 +984,7 @@ public class MediaDetection { if (xattr.getOriginalName() == null) { xattr.setOriginalName(file.getName()); } - xattr.setMetaData(model); + xattr.setObject(model); } catch (Exception e) { Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set xattr: " + e.getMessage()); } diff --git a/source/net/sourceforge/filebot/media/MetaAttributes.java b/source/net/sourceforge/filebot/media/MetaAttributes.java index e69f9889..3b4fcd3c 100644 --- a/source/net/sourceforge/filebot/media/MetaAttributes.java +++ b/source/net/sourceforge/filebot/media/MetaAttributes.java @@ -53,12 +53,12 @@ public class MetaAttributes { } - public void setMetaData(Object object) { + public void setObject(Object object) { metaAttributeView.put(METADATA_KEY, JsonWriter.toJson(object)); } - public Object getMetaData() { + public Object getObject() { return JsonReader.toJava(metaAttributeView.get(METADATA_KEY)); } diff --git a/source/net/sourceforge/filebot/similarity/EpisodeMetrics.java b/source/net/sourceforge/filebot/similarity/EpisodeMetrics.java index dd1e93b3..443c4d55 100644 --- a/source/net/sourceforge/filebot/similarity/EpisodeMetrics.java +++ b/source/net/sourceforge/filebot/similarity/EpisodeMetrics.java @@ -505,7 +505,7 @@ public enum EpisodeMetrics implements SimilarityMetric { // deserialize MetaAttributes if enabled and available if (object instanceof File && useExtendedFileAttributes()) { try { - return super.getProperties(new net.sourceforge.filebot.media.MetaAttributes((File) object).getMetaData()); + return super.getProperties(new net.sourceforge.filebot.media.MetaAttributes((File) object).getObject()); } catch (Throwable e) { // ignore } diff --git a/source/net/sourceforge/filebot/ui/rename/BindingDialog.java b/source/net/sourceforge/filebot/ui/rename/BindingDialog.java index 449ccd86..aefc0edc 100644 --- a/source/net/sourceforge/filebot/ui/rename/BindingDialog.java +++ b/source/net/sourceforge/filebot/ui/rename/BindingDialog.java @@ -393,7 +393,7 @@ class BindingDialog extends JDialog { try { MetaAttributes xattr = new MetaAttributes(file); try { - Object object = xattr.getMetaData(); + Object object = xattr.getObject(); if (infoObjectFormat.format(object) != null) { setInfoObject(object); } diff --git a/website/data/release-groups.txt b/website/data/release-groups.txt index 836d9832..ba89e0ba 100644 --- a/website/data/release-groups.txt +++ b/website/data/release-groups.txt @@ -669,6 +669,7 @@ hannibal harmy Hatsuyuki Hatsuyuki-Tsuki +HBHD HCA HD-UNiT3D HD1080 diff --git a/website/scripts/amc.groovy b/website/scripts/amc.groovy index cfbc894b..940594a1 100644 --- a/website/scripts/amc.groovy +++ b/website/scripts/amc.groovy @@ -41,11 +41,11 @@ def format = [ // force movie/series/anime logic def forceMovie(f) { - tryQuietly{ ut_label } =~ /^(?i:Movie|Couch.Potato)/ + tryQuietly{ ut_label } =~ /^(?i:Movie|Couch.Potato)/ || f.path =~ /(?<=tt)\\d{7}/ || tryQuietly{ def m = detectMovie(f, true); m.year >= 1950 && f.listPath().reverse().take(3).find{ it.name =~ m.year } } || tryQuietly{ f.metadata?.object?.class.name =~ /Movie/ } } def forceSeries(f) { - parseEpisodeNumber(f) || parseDate(f) || f.path =~ /(?i:Season)\D?[0-9]{1,2}/ || tryQuietly{ ut_label } =~ /^(?i:TV|Kids.Shows)/ + tryQuietly{ ut_label } =~ /^(?i:TV|Kids.Shows)/ || parseEpisodeNumber(f) || parseDate(f) || f.path =~ /(?i:Season)\D?[0-9]{1,2}/ || tryQuietly{ f.metadata?.object?.class.name =~ /Episode/ } } def forceAnime(f) {