From d7eaa39e6702c80db2e52c1d70e08a308fc1e155 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 5 Sep 2021 01:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E6=BA=90=E5=86=85=E7=9A=84=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E7=8E=87=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 5 +- .../app/model/analyzeRule/AnalyzeUrl.kt | 46 ++++++++++--------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1d51f30bb..74f3402d3 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -12,12 +12,15 @@ * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! * 关于最近版本有时候界面没有数据的问题是因为把LiveData组件换成了谷歌推荐的Flow组件导致的问题,正在查找解决办法 -**2021/09/03** +**2021/09/05** 1. 采用exoPlayer播放音频,支持更多格式 2. js规则内的@get,@put,{{}},不再在拆分时替换,都有对应的java函数,可以留着解析url时实时运算 3. 替换不再阻塞 4. 修复详情页初始化:规则bug +5. 书源内的并发率生效,两种格式 + * 时间 格式: 如 500, 访问间隔500毫秒 + * 次数/时间 格式: 如 5/6000, 每分钟最多访问5次 **2021/09/01** diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 6489427c9..25c60a9b1 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -277,30 +277,34 @@ class AnalyzeUrl( return } val waitTime = synchronized(fetchRecord) { - val rateIndex = concurrentRate.indexOf("/") - if (rateIndex == -1) { - val nextTime = fetchRecord.time + concurrentRate.toInt() - if (System.currentTimeMillis() >= nextTime) { - fetchRecord.time = System.currentTimeMillis() - fetchRecord.frequency = 1 - return@synchronized 0 - } - return@synchronized nextTime - System.currentTimeMillis() - } else { - val sj = concurrentRate.substring(rateIndex + 1) - val nextTime = fetchRecord.time + sj.toInt() - if (System.currentTimeMillis() >= nextTime) { - fetchRecord.time = System.currentTimeMillis() - fetchRecord.frequency = 1 - return@synchronized 0 - } - val cs = concurrentRate.substring(0, rateIndex) - if (fetchRecord.frequency > cs.toInt()) { + try { + val rateIndex = concurrentRate.indexOf("/") + if (rateIndex == -1) { + val nextTime = fetchRecord.time + concurrentRate.toInt() + if (System.currentTimeMillis() >= nextTime) { + fetchRecord.time = System.currentTimeMillis() + fetchRecord.frequency = 1 + return@synchronized 0 + } return@synchronized nextTime - System.currentTimeMillis() } else { - fetchRecord.frequency = fetchRecord.frequency + 1 - return@synchronized 0 + val sj = concurrentRate.substring(rateIndex + 1) + val nextTime = fetchRecord.time + sj.toInt() + if (System.currentTimeMillis() >= nextTime) { + fetchRecord.time = System.currentTimeMillis() + fetchRecord.frequency = 1 + return@synchronized 0 + } + val cs = concurrentRate.substring(0, rateIndex) + if (fetchRecord.frequency > cs.toInt()) { + return@synchronized nextTime - System.currentTimeMillis() + } else { + fetchRecord.frequency = fetchRecord.frequency + 1 + return@synchronized 0 + } } + } catch (e: Exception) { + return@synchronized 0 } } if (waitTime > 0) {