* a little bit more robust movie-detection

This commit is contained in:
Reinhard Pointner 2012-04-28 17:46:46 +00:00
parent 7a355d676f
commit cfc52cd215
7 changed files with 101 additions and 41 deletions

View File

@ -6,10 +6,6 @@ import static java.util.Collections.*;
import static net.sourceforge.tuned.FileUtilities.*; import static net.sourceforge.tuned.FileUtilities.*;
import java.io.File; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; 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() { public Locale getLocale() {
return new Locale(lang); return new Locale(lang);
} }

View File

@ -7,6 +7,7 @@ import static net.sourceforge.tuned.ExceptionUtilities.*;
import static net.sourceforge.tuned.FileUtilities.*; import static net.sourceforge.tuned.FileUtilities.*;
import java.io.File; import java.io.File;
import java.net.URI;
import java.security.AccessController; import java.security.AccessController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -110,9 +111,11 @@ public class ArgumentProcessor {
Bindings bindings = new SimpleBindings(); Bindings bindings = new SimpleBindings();
bindings.put("args", args.getFiles(false)); 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()); 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 ヾ(@⌒ー⌒@)"); CLILogger.finest("Done ヾ(@⌒ー⌒@)");

View File

@ -8,6 +8,7 @@ import static net.sourceforge.tuned.FileUtilities.*;
import java.awt.AWTPermission; import java.awt.AWTPermission;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilePermission; import java.io.FilePermission;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
@ -15,6 +16,8 @@ import java.io.StringReader;
import java.lang.reflect.ReflectPermission; import java.lang.reflect.ReflectPermission;
import java.net.SocketPermission; import java.net.SocketPermission;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.AccessControlContext; 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 { public Object run(URI scriptLocation, Bindings bindings) throws Throwable {
if (scriptLocation.getScheme().equals("file")) { 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")) { if (scriptLocation.getScheme().equals("system")) {
return run(new InputStreamReader(System.in), bindings); return evalute(new InputStreamReader(System.in), bindings);
} }
if (scriptLocation.getScheme().equals("script")) { 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 // 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); return evaluate(readAll(script), bindings);
} }

View File

@ -267,10 +267,14 @@ public class MediaDetection {
// lookup by file hash // lookup by file hash
if (hashLookupService != null && movieFile.isFile()) { if (hashLookupService != null && movieFile.isFile()) {
for (Movie movie : hashLookupService.getMovieDescriptors(singleton(movieFile), locale).values()) { try {
if (movie != null) { for (Movie movie : hashLookupService.getMovieDescriptors(singleton(movieFile), locale).values()) {
options.add(movie); if (movie != null) {
options.add(movie);
}
} }
} catch (Exception e) {
Logger.getLogger(MediaDetection.class.getName()).log(Level.WARNING, e.getMessage());
} }
} }

View File

@ -67,10 +67,12 @@ public abstract class CachedResource<T extends Serializable> {
// fetch and process resource // fetch and process resource
ByteBuffer data = fetchData(new URL(resource), element != null ? lastUpdateTime : 0); ByteBuffer data = fetchData(new URL(resource), element != null ? lastUpdateTime : 0);
T product = null;
if (data != null) { if (data != null) {
try { try {
element = new Element(cacheKey, process(data)); product = process(data);
element = new Element(cacheKey, product);
} catch (Exception e) { } catch (Exception e) {
throw new IOException(e); throw new IOException(e);
} }
@ -82,8 +84,7 @@ public abstract class CachedResource<T extends Serializable> {
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage()); Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage());
} }
// update cached data and last-updated time return product;
return type.cast(element.getValue());
} }
} }

View File

@ -1,4 +1,5 @@
.+sample$ .+sample$
1-3-3-8.com
5[.,]1 5[.,]1
@KIDZ @KIDZ
[1-3]CDRip [1-3]CDRip
@ -92,6 +93,7 @@ TS
TSXVID TSXVID
UNCUT UNCUT
unrated unrated
unrated.edition
UsaBit.com UsaBit.com
Video[s]? Video[s]?
www[.] www[.]

View File

@ -7,10 +7,13 @@
2Lions 2Lions
2PaCaVeLi 2PaCaVeLi
2WIRE 2WIRE
310yuma
3Li 3Li
420RipZ
4HM 4HM
7SiNS 7SiNS
850105 850105
aacrime
aAF aAF
AaS AaS
aBD aBD
@ -29,6 +32,7 @@ ALLiANCE
AMiABLE AMiABLE
ANiHLS ANiHLS
ARiGOLD ARiGOLD
ARROW
ASAP ASAP
AVCHD AVCHD
AVS720 AVS720
@ -36,16 +40,19 @@ AW
aWake aWake
aXXo aXXo
AZuRRaY AZuRRaY
babylonad
BAJSKORV BAJSKORV
BamHD BamHD
Barba Barba
BaSS BaSS
BAUM BAUM
bc10
BDClub BDClub
BDiSC BDiSC
beAst beAst
BestHD BestHD
BiA BiA
BiDA
BLOW BLOW
Blu-bits Blu-bits
BluDragon BluDragon
@ -60,17 +67,23 @@ bReAK
BrG BrG
BRiGHT BRiGHT
BRMP BRMP
BRUTUS
BRZONE BRZONE
BTSD BTSD
BTT BTT
BugZ
BULLDOZER
Bunny Bunny
BWB
C4TV C4TV
CAMELOT CAMELOT
CBGB CBGB
CDD CDD
CDDHD CDDHD
Chakra Chakra
chaostheory
Chara Chara
charliebartlett
CHD CHD
CHDBits CHDBits
CHDSUBS CHDSUBS
@ -85,8 +98,11 @@ CiNEFiLE
CiNEFOX CiNEFOX
CLASSiC CLASSiC
CLDD CLDD
cntc
COALiTiON COALiTiON
Cocksure
COMPULSION COMPULSION
cottage
CPtScene CPtScene
CPY CPY
CRF CRF
@ -94,6 +110,7 @@ CRIMSON
CRiSC CRiSC
CROSSBOW CROSSBOW
Crow Crow
CRYS
CSHD CSHD
CtrlHD CtrlHD
CTU CTU
@ -103,10 +120,13 @@ CYBERMEN
D-Z0N3 D-Z0N3
D3Si D3Si
danger2u danger2u
danirl
DARM DARM
DASH
DATA DATA
DAW DAW
DDC DDC
dddc
DEAL DEAL
decibeL decibeL
DEFiNiTE DEFiNiTE
@ -119,6 +139,7 @@ DEViSE
DEWSTRR DEWSTRR
DHD DHD
DiAMOND DiAMOND
Diamonds
DiCH DiCH
DIMENSION DIMENSION
DiMiTri DiMiTri
@ -126,6 +147,7 @@ DiNA
DiR DiR
DiRTY DiRTY
disc disc
disturbia
DiTa DiTa
DiVERSiTY DiVERSiTY
DivXNL DivXNL
@ -136,24 +158,30 @@ DNL
DNR DNR
DON DON
DOT DOT
doubt
DOWN DOWN
DRHD DRHD
DUPLI DUPLI
DUQA DUQA
DutchReleaseTeam DutchReleaseTeam
DvF
EBi EBi
EbP EbP
ECHiZEN
ECI ECI
Eclipse Eclipse
eeye
EiMi EiMi
Ekolb Ekolb
Electri4ka Electri4ka
ELECTRiC ELECTRiC
Electrichka Electrichka
elizabethtga
EmC EmC
EMPiREHD EMPiREHD
ENCOUNTERS ENCOUNTERS
EnDoR EnDoR
eots
EPiK EPiK
ESiR ESiR
ETHOS ETHOS
@ -172,6 +200,7 @@ FELONY
FFNDVD FFNDVD
FHD FHD
FHM FHM
FiCO
FiHTV FiHTV
FilmHD FilmHD
FLAiTE FLAiTE
@ -185,6 +214,7 @@ FourGHD
FoV FoV
FPG FPG
FQM FQM
FRAGMENT
FraMeSToR FraMeSToR
FRIGGHD FRIGGHD
Frost Frost
@ -230,6 +260,7 @@ HDBT
HDC HDC
HDChina HDChina
HDClub HDClub
hdcp
HDEncX HDEncX
HDEX HDEX
HDFiRE HDFiRE
@ -290,8 +321,10 @@ Japhson
JAVLiU JAVLiU
JCH JCH
JENC JENC
JJH
k2 k2
KaKa KaKa
kamera
keltz keltz
KiNGS KiNGS
KLAXXON KLAXXON
@ -313,6 +346,7 @@ LoneWolf
LOST LOST
LP LP
LTT LTT
LUSO
M794 M794
MACHD MACHD
MAGiCAL MAGiCAL
@ -327,7 +361,6 @@ MEDiEVAL
MELiTE MELiTE
MeTH MeTH
METiS METiS
WiKi
MHQ MHQ
MiND MiND
MiNT MiNT
@ -346,6 +379,7 @@ mVmHD
MySiLU MySiLU
NaRB NaRB
NBS NBS
NeDiVx
NERDHD NERDHD
NEW.SOURCE NEW.SOURCE
NewArtRiot NewArtRiot
@ -362,6 +396,7 @@ NODLABS
NOHD NOHD
Noir Noir
NORARS NORARS
NoSCR
NOsegmenT NOsegmenT
NoTV NoTV
NOVO NOVO
@ -415,9 +450,11 @@ PS3-TEAM
psig psig
PSV PSV
PSYCHD PSYCHD
Pti
PtS PtS
Pudding Pudding
Pukka Pukka
Purana
PURE PURE
PUZZLE PUZZLE
PxHD PxHD
@ -442,6 +479,7 @@ REVEiLLE
REWARD REWARD
RightSiZE RightSiZE
RiplleyHD RiplleyHD
RiPTATORz
RiVER RiVER
RMT RMT
RoCKRioT RoCKRioT
@ -456,8 +494,10 @@ SAiNTS
SAiVERT SAiVERT
SAMFD SAMFD
SANTI SANTI
saphire
Sapphire Sapphire
Scratch404 Scratch404
Scratched
SecretMyth SecretMyth
SECTOR7 SECTOR7
SEMTEX SEMTEX
@ -485,7 +525,11 @@ Softfeng
SoW SoW
SpaceHD SpaceHD
SPARKS SPARKS
SPOOKY
SSF SSF
stieg
Stranded
streetwars
STV STV
SuBoXoNe SuBoXoNe
SUNSPOT SUNSPOT
@ -524,6 +568,7 @@ tRuE
TRUEFRENCH TRUEFRENCH
tRuEHD tRuEHD
TsH TsH
tsn
TUSAHD TUSAHD
TVA TVA
TWiZTED TWiZTED
@ -550,6 +595,7 @@ VoMiT
VOSTFR VOSTFR
VoX VoX
VoXHD VoXHD
vrs
w0rm w0rm
w4f w4f
WANKAZ WANKAZ