* 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)
This commit is contained in:
Reinhard Pointner 2013-04-19 09:28:55 +00:00
parent 50a917d645
commit 6d0d7ca75e
8 changed files with 18 additions and 10 deletions

View File

@ -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.*

View File

@ -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
}

View File

@ -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());
}

View File

@ -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));
}

View File

@ -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
}

View File

@ -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);
}

View File

@ -669,6 +669,7 @@ hannibal
harmy
Hatsuyuki
Hatsuyuki-Tsuki
HBHD
HCA
HD-UNiT3D
HD1080

View File

@ -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) {