From ee6330a10c20979a6728a79e712d13174151a6ab Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 5 Dec 2012 09:36:30 +0000 Subject: [PATCH] * include omdb dump in movie index * allow foreach for AssociativeScriptObjects * added sysenv script used for printing out system properties and environment variables --- BuildData.groovy | 11 +++++++++-- .../format/AssociativeScriptObject.java | 18 +++++++++++++----- website/naming.html | 8 ++++---- website/scripts/sysenv.groovy | 11 +++++++++++ website/scripts/sysinfo.groovy | 2 +- 5 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 website/scripts/sysenv.groovy diff --git a/BuildData.groovy b/BuildData.groovy index 189ef51f..be3ba98b 100644 --- a/BuildData.groovy +++ b/BuildData.groovy @@ -71,15 +71,22 @@ imdb_ids = new HashSet(imdb.collect{ it[0] }) // BUILD movies.txt.gz def osdb_tsv = new URL("http://www.opensubtitles.org/addons/export_movie.php") -def osdb = [] +def osdb = new TreeSet({ a, b -> a[0].compareTo(b[0]) } as Comparator) osdb_tsv.getText('UTF-8').eachLine{ def line = it.split(/\t/)*.replaceAll(/\s+/, ' ')*.trim() if (line.size() == 4 && line[0] =~ /\d+/) { osdb << [line[1].toInteger(), line[2], line[3].toInteger()] } } -osdb = osdb.findAll{ it[0] <= 9999999 && it[2] >= 1930 && it[1] =~ /^[A-Z0-9]/ && it[1] =~ /[\p{Alpha}]{3}/ }.collect{ [it[0].pad(7), it[1], it[2]] } +new File('omdb.txt').eachLine{ + def line = it.split(/\t/) + if (line.length > 11 && line[5] =~ /h/ && line[3].toInteger() >= 1970 && (tryQuietly{ line[11].toFloat() } ?: 0) > 1 && (tryQuietly{ line[12].toInteger() } ?: 0) >= 10) { + line = line*.replaceAll(/\s+/, ' ')*.trim() + osdb << [line[0].toInteger(), line[2], line[3].toInteger()] + } +} +osdb = osdb.findAll{ it[0] <= 9999999 && it[2] >= 1930 && it[1] =~ /^[A-Z0-9]/ && it[1] =~ /[\p{Alpha}]{3}/ }.collect{ [it[0].pad(7), it[1], it[2]] } parallel(osdb.collect{ row -> return { diff --git a/source/net/sourceforge/filebot/format/AssociativeScriptObject.java b/source/net/sourceforge/filebot/format/AssociativeScriptObject.java index cb52cd94..a0cefbba 100644 --- a/source/net/sourceforge/filebot/format/AssociativeScriptObject.java +++ b/source/net/sourceforge/filebot/format/AssociativeScriptObject.java @@ -9,13 +9,14 @@ import java.util.AbstractSet; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.TreeSet; -public class AssociativeScriptObject extends GroovyObjectSupport { +public class AssociativeScriptObject extends GroovyObjectSupport implements Iterable> { - private final Map properties; + private final Map properties; public AssociativeScriptObject(Map properties) { @@ -26,8 +27,10 @@ public class AssociativeScriptObject extends GroovyObjectSupport { /** * Get the property with the given name. * - * @param name the property name - * @param start the object where the lookup began + * @param name + * the property name + * @param start + * the object where the lookup began */ @Override public Object getProperty(String name) { @@ -41,6 +44,12 @@ public class AssociativeScriptObject extends GroovyObjectSupport { } + @Override + public Iterator> iterator() { + return properties.entrySet().iterator(); + } + + @Override public String toString() { // all the properties in alphabetic order @@ -92,7 +101,6 @@ public class AssociativeScriptObject extends GroovyObjectSupport { public Set> entrySet() { return new AbstractSet>() { - @SuppressWarnings("unchecked") @Override public Iterator> iterator() { return (Iterator) lookup.values().iterator(); diff --git a/website/naming.html b/website/naming.html index ab1645a4..88f9a94c 100644 --- a/website/naming.html +++ b/website/naming.html @@ -114,21 +114,21 @@

- Episode Format Expressions - User defined episode naming scheme + Format Expressions + User defined episode / movie naming scheme

About

- You can easily define your own episode naming scheme. It uses Groovy expressions, + You can easily define your own episode and movie naming schemes. It uses Groovy expressions, which means that you can do pretty much anything, especially if you know a little bit about programming. You even get media info bindings. You can find predefined format expressions for all kinds of scenarios in the forums. Ready for you to just copy & paste.

diff --git a/website/scripts/sysenv.groovy b/website/scripts/sysenv.groovy new file mode 100644 index 00000000..ba9a860c --- /dev/null +++ b/website/scripts/sysenv.groovy @@ -0,0 +1,11 @@ +// filebot -script fn:sysenv + +println '# Java System Properties #' +_system.each{ + println "$it.key: $it.value" +} + +println '# Environment Variables #' +_environment.each{ + println "$it.key: $it.value" +} diff --git a/website/scripts/sysinfo.groovy b/website/scripts/sysinfo.groovy index f7f86f37..ba70fa31 100644 --- a/website/scripts/sysinfo.groovy +++ b/website/scripts/sysinfo.groovy @@ -1,4 +1,4 @@ -// filebot -script "fn:sysinfo" +// filebot -script fn:sysinfo // FileBot 2.62 (r993) println net.sourceforge.filebot.Settings.applicationIdentifier