From cfc52cd21532307628bed2b3df46d9846304368f Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 28 Apr 2012 17:46:46 +0000 Subject: [PATCH] * a little bit more robust movie-detection --- .../sourceforge/filebot/cli/ArgumentBean.java | 28 ----------- .../filebot/cli/ArgumentProcessor.java | 7 ++- .../sourceforge/filebot/cli/ScriptShell.java | 40 ++++++++++++++-- .../filebot/media/MediaDetection.java | 10 ++-- .../filebot/web/CachedResource.java | 7 +-- website/data/query-blacklist.txt | 2 + website/data/release-groups.txt | 48 ++++++++++++++++++- 7 files changed, 101 insertions(+), 41 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ArgumentBean.java b/source/net/sourceforge/filebot/cli/ArgumentBean.java index fbe081bd..7e65a217 100644 --- a/source/net/sourceforge/filebot/cli/ArgumentBean.java +++ b/source/net/sourceforge/filebot/cli/ArgumentBean.java @@ -6,10 +6,6 @@ import static java.util.Collections.*; import static net.sourceforge.tuned.FileUtilities.*; import java.io.File; -import java.io.FileNotFoundException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -148,30 +144,6 @@ public class ArgumentBean { } - public URI getScriptLocation() { - try { - return new URL(script).toURI(); - } catch (Exception eu) { - if (script.startsWith("script://")) { - try { - return new URI("script", script.substring(9), null, null, null); - } catch (URISyntaxException e) { - throw new IllegalArgumentException(e); - } - } - try { - File file = new File(script); - if (!file.exists()) { - throw new FileNotFoundException(file.getPath()); - } - return file.toURI(); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } - } - - public Locale getLocale() { return new Locale(lang); } diff --git a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java index b57299f9..307d141f 100644 --- a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java +++ b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java @@ -7,6 +7,7 @@ import static net.sourceforge.tuned.ExceptionUtilities.*; import static net.sourceforge.tuned.FileUtilities.*; import java.io.File; +import java.net.URI; import java.security.AccessController; import java.util.ArrayList; import java.util.Collection; @@ -110,9 +111,11 @@ public class ArgumentProcessor { Bindings bindings = new SimpleBindings(); bindings.put("args", args.getFiles(false)); - Analytics.trackEvent("CLI", "ExecuteScript", args.getScriptLocation().getScheme()); ScriptShell shell = new ScriptShell(cli, args, args.parameters, args.trustScript, AccessController.getContext()); - shell.run(args.getScriptLocation(), bindings); + URI script = shell.getScriptLocation(args.script); + + Analytics.trackEvent("CLI", "ExecuteScript", script.getScheme()); + shell.run(script, bindings); } CLILogger.finest("Done ヾ(@⌒ー⌒@)ノ"); diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.java b/source/net/sourceforge/filebot/cli/ScriptShell.java index fee44a6c..61677334 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.java +++ b/source/net/sourceforge/filebot/cli/ScriptShell.java @@ -8,6 +8,7 @@ import static net.sourceforge.tuned.FileUtilities.*; import java.awt.AWTPermission; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FilePermission; import java.io.InputStreamReader; import java.io.Reader; @@ -15,6 +16,8 @@ import java.io.StringReader; import java.lang.reflect.ReflectPermission; import java.net.SocketPermission; import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.security.AccessControlContext; @@ -105,17 +108,46 @@ class ScriptShell { } + public URI getScriptLocation(String input) { + try { + return new URL(input).toURI(); + } catch (Exception eu) { + if (input.startsWith("script:")) { + try { + return new URI("script", input.substring(7), null, null, null); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } + try { + File file = new File(input); + if (!file.exists()) { + throw new FileNotFoundException(file.getPath()); + } + return file.toURI(); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + } + } + + + public Object run(String input, Bindings bindings) throws Throwable { + return run(getScriptLocation(input), bindings); + } + + public Object run(URI scriptLocation, Bindings bindings) throws Throwable { if (scriptLocation.getScheme().equals("file")) { - return run(new InputStreamReader(new FileInputStream(new File(scriptLocation)), "UTF-8"), bindings); + return evalute(new InputStreamReader(new FileInputStream(new File(scriptLocation)), "UTF-8"), bindings); } if (scriptLocation.getScheme().equals("system")) { - return run(new InputStreamReader(System.in), bindings); + return evalute(new InputStreamReader(System.in), bindings); } if (scriptLocation.getScheme().equals("script")) { - return run(new StringReader(scriptLocation.getAuthority()), bindings); + return evalute(new StringReader(scriptLocation.getAuthority()), bindings); } // fetch remote script only if modified @@ -130,7 +162,7 @@ class ScriptShell { } - public Object run(Reader script, Bindings bindings) throws Throwable { + public Object evalute(Reader script, Bindings bindings) throws Throwable { return evaluate(readAll(script), bindings); } diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 0446cc6e..3e6bfc9e 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -267,10 +267,14 @@ public class MediaDetection { // lookup by file hash if (hashLookupService != null && movieFile.isFile()) { - for (Movie movie : hashLookupService.getMovieDescriptors(singleton(movieFile), locale).values()) { - if (movie != null) { - options.add(movie); + try { + for (Movie movie : hashLookupService.getMovieDescriptors(singleton(movieFile), locale).values()) { + if (movie != null) { + options.add(movie); + } } + } catch (Exception e) { + Logger.getLogger(MediaDetection.class.getName()).log(Level.WARNING, e.getMessage()); } } diff --git a/source/net/sourceforge/filebot/web/CachedResource.java b/source/net/sourceforge/filebot/web/CachedResource.java index a6b43915..5212d610 100644 --- a/source/net/sourceforge/filebot/web/CachedResource.java +++ b/source/net/sourceforge/filebot/web/CachedResource.java @@ -67,10 +67,12 @@ public abstract class CachedResource { // fetch and process resource ByteBuffer data = fetchData(new URL(resource), element != null ? lastUpdateTime : 0); + T product = null; if (data != null) { try { - element = new Element(cacheKey, process(data)); + product = process(data); + element = new Element(cacheKey, product); } catch (Exception e) { throw new IOException(e); } @@ -82,8 +84,7 @@ public abstract class CachedResource { Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage()); } - // update cached data and last-updated time - return type.cast(element.getValue()); + return product; } } diff --git a/website/data/query-blacklist.txt b/website/data/query-blacklist.txt index f9a729c4..5f4430ee 100644 --- a/website/data/query-blacklist.txt +++ b/website/data/query-blacklist.txt @@ -1,4 +1,5 @@ .+sample$ +1-3-3-8.com 5[.,]1 @KIDZ [1-3]CDRip @@ -92,6 +93,7 @@ TS TSXVID UNCUT unrated +unrated.edition UsaBit.com Video[s]? www[.] diff --git a/website/data/release-groups.txt b/website/data/release-groups.txt index 7973d1ec..3150b98b 100644 --- a/website/data/release-groups.txt +++ b/website/data/release-groups.txt @@ -7,10 +7,13 @@ 2Lions 2PaCaVeLi 2WIRE +310yuma 3Li +420RipZ 4HM 7SiNS 850105 +aacrime aAF AaS aBD @@ -29,6 +32,7 @@ ALLiANCE AMiABLE ANiHLS ARiGOLD +ARROW ASAP AVCHD AVS720 @@ -36,16 +40,19 @@ AW aWake aXXo AZuRRaY +babylonad BAJSKORV BamHD Barba BaSS BAUM +bc10 BDClub BDiSC beAst BestHD BiA +BiDA BLOW Blu-bits BluDragon @@ -60,17 +67,23 @@ bReAK BrG BRiGHT BRMP +BRUTUS BRZONE BTSD BTT +BugZ +BULLDOZER Bunny +BWB C4TV CAMELOT CBGB CDD CDDHD Chakra +chaostheory Chara +charliebartlett CHD CHDBits CHDSUBS @@ -85,8 +98,11 @@ CiNEFiLE CiNEFOX CLASSiC CLDD +cntc COALiTiON +Cocksure COMPULSION +cottage CPtScene CPY CRF @@ -94,6 +110,7 @@ CRIMSON CRiSC CROSSBOW Crow +CRYS CSHD CtrlHD CTU @@ -103,10 +120,13 @@ CYBERMEN D-Z0N3 D3Si danger2u +danirl DARM +DASH DATA DAW DDC +dddc DEAL decibeL DEFiNiTE @@ -119,6 +139,7 @@ DEViSE DEWSTRR DHD DiAMOND +Diamonds DiCH DIMENSION DiMiTri @@ -126,6 +147,7 @@ DiNA DiR DiRTY disc +disturbia DiTa DiVERSiTY DivXNL @@ -136,24 +158,30 @@ DNL DNR DON DOT +doubt DOWN DRHD DUPLI DUQA DutchReleaseTeam +DvF EBi EbP +ECHiZEN ECI Eclipse +eeye EiMi Ekolb Electri4ka ELECTRiC Electrichka +elizabethtga EmC EMPiREHD ENCOUNTERS EnDoR +eots EPiK ESiR ETHOS @@ -172,6 +200,7 @@ FELONY FFNDVD FHD FHM +FiCO FiHTV FilmHD FLAiTE @@ -185,6 +214,7 @@ FourGHD FoV FPG FQM +FRAGMENT FraMeSToR FRIGGHD Frost @@ -230,6 +260,7 @@ HDBT HDC HDChina HDClub +hdcp HDEncX HDEX HDFiRE @@ -290,8 +321,10 @@ Japhson JAVLiU JCH JENC +JJH k2 KaKa +kamera keltz KiNGS KLAXXON @@ -313,6 +346,7 @@ LoneWolf LOST LP LTT +LUSO M794 MACHD MAGiCAL @@ -327,7 +361,6 @@ MEDiEVAL MELiTE MeTH METiS -WiKi MHQ MiND MiNT @@ -346,6 +379,7 @@ mVmHD MySiLU NaRB NBS +NeDiVx NERDHD NEW.SOURCE NewArtRiot @@ -362,6 +396,7 @@ NODLABS NOHD Noir NORARS +NoSCR NOsegmenT NoTV NOVO @@ -415,9 +450,11 @@ PS3-TEAM psig PSV PSYCHD +Pti PtS Pudding Pukka +Purana PURE PUZZLE PxHD @@ -442,6 +479,7 @@ REVEiLLE REWARD RightSiZE RiplleyHD +RiPTATORz RiVER RMT RoCKRioT @@ -456,8 +494,10 @@ SAiNTS SAiVERT SAMFD SANTI +saphire Sapphire Scratch404 +Scratched SecretMyth SECTOR7 SEMTEX @@ -485,7 +525,11 @@ Softfeng SoW SpaceHD SPARKS +SPOOKY SSF +stieg +Stranded +streetwars STV SuBoXoNe SUNSPOT @@ -524,6 +568,7 @@ tRuE TRUEFRENCH tRuEHD TsH +tsn TUSAHD TVA TWiZTED @@ -550,6 +595,7 @@ VoMiT VOSTFR VoX VoXHD +vrs w0rm w4f WANKAZ