From c2c49d2355f01c5090d0dd6b4f7dd4633b55f2a5 Mon Sep 17 00:00:00 2001 From: LamGC Date: Mon, 27 Apr 2020 12:32:25 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=20PixivDownload=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9=E6=8E=92=E8=A1=8C=E6=A6=9C=E8=8E=B7=E5=8F=96=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8=E7=9A=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF;=20[Fix]=20PixivURL.RankingContentType=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DisSupportedMode=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98;=20[Fix]=20RankingUpdateTimer=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=AF=8F=E6=97=A5=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4(12:10=20->=2012:30)=E4=BB=A5=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=92=E8=A1=8C=E6=A6=9C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E6=9C=BA=E8=BF=87=E6=97=A9=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/net/lamgc/cgj/bot/RankingUpdateTimer.java | 2 +- src/main/java/net/lamgc/cgj/pixiv/PixivDownload.java | 8 +++++--- src/main/java/net/lamgc/cgj/pixiv/PixivURL.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/lamgc/cgj/bot/RankingUpdateTimer.java b/src/main/java/net/lamgc/cgj/bot/RankingUpdateTimer.java index ed98c27..bb4a836 100644 --- a/src/main/java/net/lamgc/cgj/bot/RankingUpdateTimer.java +++ b/src/main/java/net/lamgc/cgj/bot/RankingUpdateTimer.java @@ -31,7 +31,7 @@ public class RankingUpdateTimer { cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + 1); } cal.set(Calendar.HOUR_OF_DAY, 12); - cal.set(Calendar.MINUTE, 10); + cal.set(Calendar.MINUTE, 30); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); diff --git a/src/main/java/net/lamgc/cgj/pixiv/PixivDownload.java b/src/main/java/net/lamgc/cgj/pixiv/PixivDownload.java index 2f1c74a..e0d1dee 100644 --- a/src/main/java/net/lamgc/cgj/pixiv/PixivDownload.java +++ b/src/main/java/net/lamgc/cgj/pixiv/PixivDownload.java @@ -299,6 +299,7 @@ public class PixivDownload { */ public List getRanking(PixivURL.RankingContentType contentType, PixivURL.RankingMode mode, Date time, int rankStart, int range) throws IOException { + Objects.requireNonNull(time); if(!Objects.requireNonNull(contentType).isSupportedMode(Objects.requireNonNull(mode))) { throw new IllegalArgumentException("ContentType不支持指定的RankingMode: ContentType: " + contentType.name() + ", Mode: " + mode.name()); } else if(rankStart <= 0) { @@ -322,7 +323,7 @@ public class PixivDownload { String responseBody = EntityUtils.toString(response.getEntity()); log.debug("ResponseBody: {}", responseBody); if(response.getStatusLine().getStatusCode() != 200) { - throw new IOException("Http Response Error: " + response.getStatusLine()); + throw new IOException("Http Response Error: '" + response.getStatusLine() + "', ResponseBody: '" + responseBody + '\''); } JsonArray resultArray = gson.fromJson(responseBody, JsonObject.class).getAsJsonArray("contents"); @@ -432,13 +433,14 @@ public class PixivDownload { THUMB_MINI } - - /** * 获取帐号所有的收藏插画,并以输入流形式提供 * @return 获取所有链接的InputStream, 请注意关闭InputStream * @throws IOException 当获取时发生异常则直接抛出 + * @deprecated 该方法可能会导致已经打开的InputStream超时, 使图片获取失败, + * 请直接使用{@linkplain #getCollectionAsInputStream(PageQuality, BiConsumer)} */ + @Deprecated public Set> getCollectionAsInputStream(PageQuality quality) throws IOException { HashSet> illustInputStreamSet = new HashSet<>(); getCollectionAsInputStream(quality, (link, inputStream) -> illustInputStreamSet.add(new AbstractMap.SimpleEntry<>(link, inputStream))); diff --git a/src/main/java/net/lamgc/cgj/pixiv/PixivURL.java b/src/main/java/net/lamgc/cgj/pixiv/PixivURL.java index 43ed259..0826a27 100644 --- a/src/main/java/net/lamgc/cgj/pixiv/PixivURL.java +++ b/src/main/java/net/lamgc/cgj/pixiv/PixivURL.java @@ -336,7 +336,7 @@ public class PixivURL { * @return 如果支持返回true */ public boolean isSupportedMode(RankingMode mode) { - return Arrays.binarySearch(supportedMode, mode) != -1; + return Arrays.binarySearch(supportedMode, mode) < 0; } }