From 869a571f2acf8385491934f4c77bc7a2a75537c0 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 31 Mar 2016 20:13:51 +0000 Subject: [PATCH] handle error response correctly --- source/net/filebot/web/ShooterSubtitles.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/web/ShooterSubtitles.java b/source/net/filebot/web/ShooterSubtitles.java index 38563198..33396fe2 100644 --- a/source/net/filebot/web/ShooterSubtitles.java +++ b/source/net/filebot/web/ShooterSubtitles.java @@ -91,10 +91,14 @@ public class ShooterSubtitles implements VideoHashSubtitleService { // use the first best option and ignore the rest return getCache().castList(SubtitleDescriptor.class).computeIfAbsent(param.toString(), it -> { - ByteBuffer post = WebRequest.post(endpoint, param, null); - Object response = readJson(UTF_8.decode(post)); + ByteBuffer bb = WebRequest.post(endpoint, param, null); + + // error response + if (bb.remaining() == 1 && bb.get(0) == -1) + return emptyList(); String name = getNameWithoutExtension(file.getName()); + Object response = readJson(UTF_8.decode(bb)); return streamJsonObjects(response).flatMap(n -> streamJsonObjects(n, "Files")).map(f -> { String type = getString(f, "Ext");