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) {