* better error messages when anti-leech limits are reached
This commit is contained in:
parent
9effd7cc6d
commit
8fd4576ff4
|
@ -2,6 +2,7 @@
|
|||
package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -9,6 +10,7 @@ import java.util.EnumMap;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.ZipException;
|
||||
|
||||
import net.sourceforge.tuned.ByteBufferOutputStream;
|
||||
import net.sourceforge.tuned.FileUtilities;
|
||||
|
@ -130,12 +132,19 @@ public class OpenSubtitlesSubtitleDescriptor implements SubtitleDescriptor {
|
|||
@Override
|
||||
public ByteBuffer fetch() throws Exception {
|
||||
URL resource = new URL(getProperty(Property.SubDownloadLink));
|
||||
InputStream stream = new GZIPInputStream(resource.openStream());
|
||||
InputStream stream = resource.openStream();
|
||||
|
||||
try {
|
||||
ByteBufferOutputStream buffer = new ByteBufferOutputStream(getLength());
|
||||
|
||||
// read all
|
||||
// extract gzipped subtitle on-the-fly
|
||||
try {
|
||||
stream = new GZIPInputStream(stream);
|
||||
} catch (ZipException e) {
|
||||
throw new IOException(String.format("%s: anti-leech limit may have been reached", e.getMessage()));
|
||||
}
|
||||
|
||||
// fully download
|
||||
buffer.transferFully(stream);
|
||||
|
||||
return buffer.getByteBuffer();
|
||||
|
|
Loading…
Reference in New Issue