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

View File

@ -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 ヾ(@⌒ー⌒@)");

View File

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

View File

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

View File

@ -67,10 +67,12 @@ public abstract class CachedResource<T extends Serializable> {
// 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<T extends Serializable> {
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage());
}
// update cached data and last-updated time
return type.cast(element.getValue());
return product;
}
}

View File

@ -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[.]

View File

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