From d94c85ab00b885b9ba47129dd273b5d846166496 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 3 Dec 2012 18:08:02 +0000 Subject: [PATCH] * improve stability --- BuildData.groovy | 2 ++ installer/webstart/filebot.jnlp | 2 +- .../sourceforge/filebot/cli/ScriptShell.lib.groovy | 1 + .../net/sourceforge/filebot/media/ReleaseInfo.java | 2 +- .../sourceforge/filebot/web/OpenSubtitlesHasher.java | 12 +++++++++++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/BuildData.groovy b/BuildData.groovy index d758a88a..189ef51f 100644 --- a/BuildData.groovy +++ b/BuildData.groovy @@ -122,6 +122,8 @@ def thetvdb_index = thetvdb_index_url.fetch().getHtml('UTF-8') .depthFirst().TR.findAll{ it.TD.size() == 3 && it.TD[1].text() == 'English' && it.TD[0].A.text() } .findResults{ [it.TD[2].text(), it.TD[0].A.text()] } +thetvdb_index = thetvdb_index.findResults{ [it[0] as Integer, it[1].replaceAll(/\s+/, ' ').trim()] }.findAll{ !(it[1] =~ /(?i:duplicate)/ || it[1] =~ /\d{6,}/ || it[1].startsWith('*') || it[1].endsWith('*') || it[1].empty) } as HashSet + // join and sort def thetvdb = thetvdb_index.findResults{ [it[0].pad(6), it[1]].join('\t') }.sort() gz(thetvdb_out, thetvdb) diff --git a/installer/webstart/filebot.jnlp b/installer/webstart/filebot.jnlp index 7c2b6e55..fa537a7d 100644 --- a/installer/webstart/filebot.jnlp +++ b/installer/webstart/filebot.jnlp @@ -26,7 +26,7 @@ - + diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index effaeb95..327623e4 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -47,6 +47,7 @@ File.metaClass.copyTo = { dir -> copyAs(delegate, new File(dir, delegate.getName File.metaClass.getXattr = { new net.sourceforge.filebot.MetaAttributeView(delegate) } List.metaClass.mapByFolder = { mapByFolder(delegate) } List.metaClass.mapByExtension = { mapByExtension(delegate) } +String.metaClass.getNameWithoutExtension = { getNameWithoutExtension(delegate) } String.metaClass.getExtension = { getExtension(delegate) } String.metaClass.hasExtension = { String... ext -> hasExtension(delegate, ext) } String.metaClass.validateFileName = { validateFileName(delegate) } diff --git a/source/net/sourceforge/filebot/media/ReleaseInfo.java b/source/net/sourceforge/filebot/media/ReleaseInfo.java index 5c7e3b10..7c3f4106 100644 --- a/source/net/sourceforge/filebot/media/ReleaseInfo.java +++ b/source/net/sourceforge/filebot/media/ReleaseInfo.java @@ -342,7 +342,7 @@ public class ReleaseInfo { Scanner scanner = new Scanner(new GZIPInputStream(new ByteBufferInputStream(data)), "UTF-8").useDelimiter("\t|\n"); List tvshows = new ArrayList(); - while (scanner.hasNext()) { + while (scanner.hasNext() && scanner.hasNextInt()) { int id = scanner.nextInt(); String name = scanner.next().trim(); tvshows.add(new TheTVDBSearchResult(name, id)); diff --git a/source/net/sourceforge/filebot/web/OpenSubtitlesHasher.java b/source/net/sourceforge/filebot/web/OpenSubtitlesHasher.java index 900513a2..8220d14e 100644 --- a/source/net/sourceforge/filebot/web/OpenSubtitlesHasher.java +++ b/source/net/sourceforge/filebot/web/OpenSubtitlesHasher.java @@ -27,7 +27,7 @@ public final class OpenSubtitlesHasher { public static final int HASH_CHUNK_SIZE = 64 * 1024; - public static String computeHash(File file) throws IOException { + public static String computeHashNIO(File file) throws IOException { long size = file.length(); long chunkSizeForFile = Math.min(HASH_CHUNK_SIZE, size); @@ -43,6 +43,16 @@ public final class OpenSubtitlesHasher { } } + + public static String computeHash(File file) throws IOException { + FileInputStream in = new FileInputStream(file); + try { + return computeHash(in, file.length()); + } finally { + in.close(); + } + } + public static String computeHash(InputStream stream, long length) throws IOException { int chunkSizeForFile = (int) Math.min(HASH_CHUNK_SIZE, length);