书源内的并发率生效

pull/1296/head
gedoor 4 years ago
parent ce06471b4c
commit d7eaa39e67
  1. 5
      app/src/main/assets/updateLog.md
  2. 46
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -12,12 +12,15 @@
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!
* 关于最近版本有时候界面没有数据的问题是因为把LiveData组件换成了谷歌推荐的Flow组件导致的问题,正在查找解决办法 * 关于最近版本有时候界面没有数据的问题是因为把LiveData组件换成了谷歌推荐的Flow组件导致的问题,正在查找解决办法
**2021/09/03** **2021/09/05**
1. 采用exoPlayer播放音频,支持更多格式 1. 采用exoPlayer播放音频,支持更多格式
2. js规则内的@get,@put,{{}},不再在拆分时替换,都有对应的java函数,可以留着解析url时实时运算 2. js规则内的@get,@put,{{}},不再在拆分时替换,都有对应的java函数,可以留着解析url时实时运算
3. 替换不再阻塞 3. 替换不再阻塞
4. 修复详情页初始化:规则bug 4. 修复详情页初始化:规则bug
5. 书源内的并发率生效,两种格式
* 时间 格式: 如 500, 访问间隔500毫秒
* 次数/时间 格式: 如 5/6000, 每分钟最多访问5次
**2021/09/01** **2021/09/01**

@ -277,30 +277,34 @@ class AnalyzeUrl(
return return
} }
val waitTime = synchronized(fetchRecord) { val waitTime = synchronized(fetchRecord) {
val rateIndex = concurrentRate.indexOf("/") try {
if (rateIndex == -1) { val rateIndex = concurrentRate.indexOf("/")
val nextTime = fetchRecord.time + concurrentRate.toInt() if (rateIndex == -1) {
if (System.currentTimeMillis() >= nextTime) { val nextTime = fetchRecord.time + concurrentRate.toInt()
fetchRecord.time = System.currentTimeMillis() if (System.currentTimeMillis() >= nextTime) {
fetchRecord.frequency = 1 fetchRecord.time = System.currentTimeMillis()
return@synchronized 0 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()) {
return@synchronized nextTime - System.currentTimeMillis() return@synchronized nextTime - System.currentTimeMillis()
} else { } else {
fetchRecord.frequency = fetchRecord.frequency + 1 val sj = concurrentRate.substring(rateIndex + 1)
return@synchronized 0 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) { if (waitTime > 0) {

Loading…
Cancel
Save