From 5d595d50a138e34a256de8014f7854d8ea1b7b06 Mon Sep 17 00:00:00 2001 From: LamGC Date: Mon, 30 Mar 2020 12:07:29 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=20=E5=A2=9E=E5=8A=A0Ranking=E5=B8=A6?= =?UTF-8?q?=E5=9B=BE=E4=BD=9C=E5=93=81=E9=99=90=E5=88=B6=E7=9A=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9;=20[Add]=20=E5=A2=9E=E5=8A=A0image.downloadA?= =?UTF-8?q?llPages=E9=85=8D=E7=BD=AE=E9=A1=B9=E4=BB=A5=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E4=BD=9C=E5=93=81=E4=B8=AD=E6=9F=90=E4=B8=80?= =?UTF-8?q?Pages=E7=9A=84=E6=97=B6=E5=80=99=E6=98=AF=E5=90=A6=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=85=B6=E4=BB=96Pages;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/net/lamgc/cgj/CQProcess.java | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/lamgc/cgj/CQProcess.java b/src/main/java/net/lamgc/cgj/CQProcess.java index 84f5370..3d4919a 100644 --- a/src/main/java/net/lamgc/cgj/CQProcess.java +++ b/src/main/java/net/lamgc/cgj/CQProcess.java @@ -112,16 +112,23 @@ public class CQProcess { StringBuilder resultBuilder = new StringBuilder(mode.name() + " - 以下是 ").append(new SimpleDateFormat("yyyy-MM-dd").format(queryDate)).append(" 的Pixiv插画排名榜前十名:\n"); try { int index = 0; - int limit = 10; - String propertyKey = "ranking.ItemCountLimit"; + int itemLimit = 10; + String itemLimitPropertyKey = "ranking.ItemCountLimit"; try { - - limit = Integer.parseInt(CQPluginMain.globalProp.getProperty(propertyKey, "10")); + itemLimit = Integer.parseInt(CQPluginMain.globalProp.getProperty(itemLimitPropertyKey, "10")); } catch(NumberFormatException e) { - log.warn("配置项 {} 的参数值格式有误!", propertyKey); + log.warn("配置项 {} 的参数值格式有误!", itemLimitPropertyKey); } - for (JsonObject rankInfo : getRankingInfoByCache(PixivURL.RankingContentType.TYPE_ILLUST, mode, queryDate, 0, limit)) { + int imageLimit = 3; + String imageLimitPropertyKey = "ranking.imageCountLimit"; + try { + imageLimit = Integer.parseInt(CQPluginMain.globalProp.getProperty(imageLimitPropertyKey, "3")); + } catch(NumberFormatException e) { + log.warn("配置项 {} 的参数值格式有误!", imageLimitPropertyKey); + } + + for (JsonObject rankInfo : getRankingInfoByCache(PixivURL.RankingContentType.TYPE_ILLUST, mode, queryDate, 0, itemLimit)) { index++; int rank = rankInfo.get("rank").getAsInt(); int illustId = rankInfo.get("illust_id").getAsInt(); @@ -130,7 +137,7 @@ public class CQProcess { String title = rankInfo.get("title").getAsString(); resultBuilder.append(rank).append(". (id: ").append(illustId).append(") ").append(title) .append("(Author: ").append(authorName).append(",").append(authorId).append(")\n"); - if (index < 4) { + if (index <= imageLimit) { resultBuilder.append(getImageById(illustId, PixivDownload.PageQuality.REGULAR, 1)).append("\n"); } } @@ -399,7 +406,8 @@ public class CQProcess { } catch (InterruptedException e) { log.warn("图片下载遭到中断!", e); } - } else { + } else if(CQPluginMain.globalProp.getProperty("image.downloadAllPages", "false") + .equalsIgnoreCase("true")) { imageCacheExecutor.executor( new ImageCacheObject(imageCache, illustId, link, currentImageFile)); }