* fix local file script call

* stop any unnecessary scraping of subscene
This commit is contained in:
Reinhard Pointner 2012-04-09 14:37:16 +00:00
parent 32b2d35e0c
commit ec796fc478
2 changed files with 15 additions and 14 deletions

View File

@ -9,6 +9,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; 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;
@ -145,8 +146,8 @@ public class ArgumentBean {
public URI getScriptLocation() { public URI getScriptLocation() {
try { try {
return new URI(script); return new URL(script).toURI();
} catch (URISyntaxException eu) { } catch (Exception eu) {
if (script.startsWith("script://")) { if (script.startsWith("script://")) {
try { try {
return new URI("script", script.substring(9), null, null, null); return new URI("script", script.substring(9), null, null, null);

View File

@ -24,32 +24,32 @@ public class SubsceneSubtitleDescriptor implements SubtitleDescriptor {
private URL subtitlePage; private URL subtitlePage;
private Map<String, String> subtitleInfo; private Map<String, String> subtitleInfo;
public SubsceneSubtitleDescriptor(String title, String language, URL subtitlePage) { public SubsceneSubtitleDescriptor(String title, String language, URL subtitlePage) {
this.title = title; this.title = title;
this.language = language; this.language = language;
this.subtitlePage = subtitlePage; this.subtitlePage = subtitlePage;
} }
@Override @Override
public String getName() { public String getName() {
return title; return title;
} }
@Override @Override
public String getLanguageName() { public String getLanguageName() {
return language; return language;
} }
@Override @Override
public String getType() { public String getType() {
return null; return null;
} }
@Override @Override
public ByteBuffer fetch() throws Exception { public ByteBuffer fetch() throws Exception {
// e.g. http://subscene.com/english/Firefly-The-Complete-Series/subtitle-40003-dlpath-20008/rar.zipx // e.g. http://subscene.com/english/Firefly-The-Complete-Series/subtitle-40003-dlpath-20008/rar.zipx
@ -65,7 +65,7 @@ public class SubsceneSubtitleDescriptor implements SubtitleDescriptor {
return WebRequest.post(connection, downloadPostData); return WebRequest.post(connection, downloadPostData);
} }
private synchronized Map<String, String> getSubtitleInfo() { private synchronized Map<String, String> getSubtitleInfo() {
// extract subtitle information from subtitle page if necessary // extract subtitle information from subtitle page if necessary
if (subtitleInfo == null) { if (subtitleInfo == null) {
@ -84,25 +84,25 @@ public class SubsceneSubtitleDescriptor implements SubtitleDescriptor {
return subtitleInfo; return subtitleInfo;
} }
@Override @Override
public String getPath() { public String getPath() {
return String.format("%s.%s", getName(), getSubtitleInfo().get("typeId")); return String.format("%s.%s", getName(), subtitleInfo == null ? null : subtitleInfo.get("typeId"));
} }
@Override @Override
public long getLength() { public long getLength() {
return -1; return -1;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return subtitlePage.getPath().hashCode(); return subtitlePage.getPath().hashCode();
} }
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (object instanceof SubsceneSubtitleDescriptor) { if (object instanceof SubsceneSubtitleDescriptor) {
@ -113,7 +113,7 @@ public class SubsceneSubtitleDescriptor implements SubtitleDescriptor {
return false; return false;
} }
@Override @Override
public String toString() { public String toString() {
return String.format("%s [%s]", getName(), getLanguageName()); return String.format("%s [%s]", getName(), getLanguageName());