| 
						
						
						
					 | 
					 | 
					@ -1,5 +1,6 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					package io.legado.app.model.webBook | 
					 | 
					 | 
					 | 
					package io.legado.app.model.webBook | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import io.legado.app.constant.AppLog | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.data.entities.Book | 
					 | 
					 | 
					 | 
					import io.legado.app.data.entities.Book | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.data.entities.BookChapter | 
					 | 
					 | 
					 | 
					import io.legado.app.data.entities.BookChapter | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.data.entities.BookSource | 
					 | 
					 | 
					 | 
					import io.legado.app.data.entities.BookSource | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -9,6 +10,7 @@ import io.legado.app.help.book.getBookType | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.help.coroutine.Coroutine | 
					 | 
					 | 
					 | 
					import io.legado.app.help.coroutine.Coroutine | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.help.http.StrResponse | 
					 | 
					 | 
					 | 
					import io.legado.app.help.http.StrResponse | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.Debug | 
					 | 
					 | 
					 | 
					import io.legado.app.model.Debug | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import io.legado.app.model.analyzeRule.AnalyzeRule | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.analyzeRule.AnalyzeUrl | 
					 | 
					 | 
					 | 
					import io.legado.app.model.analyzeRule.AnalyzeUrl | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.analyzeRule.RuleData | 
					 | 
					 | 
					 | 
					import io.legado.app.model.analyzeRule.RuleData | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import kotlinx.coroutines.CoroutineScope | 
					 | 
					 | 
					 | 
					import kotlinx.coroutines.CoroutineScope | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -179,19 +181,30 @@ object WebBook { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        scope: CoroutineScope, | 
					 | 
					 | 
					 | 
					        scope: CoroutineScope, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        bookSource: BookSource, | 
					 | 
					 | 
					 | 
					        bookSource: BookSource, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        book: Book, | 
					 | 
					 | 
					 | 
					        book: Book, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        runPerJs: Boolean = false, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        context: CoroutineContext = Dispatchers.IO | 
					 | 
					 | 
					 | 
					        context: CoroutineContext = Dispatchers.IO | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ): Coroutine<List<BookChapter>> { | 
					 | 
					 | 
					 | 
					    ): Coroutine<List<BookChapter>> { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return Coroutine.async(scope, context) { | 
					 | 
					 | 
					 | 
					        return Coroutine.async(scope, context) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            getChapterListAwait(bookSource, book).getOrThrow() | 
					 | 
					 | 
					 | 
					            getChapterListAwait(bookSource, book, runPerJs).getOrThrow() | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    suspend fun getChapterListAwait( | 
					 | 
					 | 
					 | 
					    suspend fun getChapterListAwait( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        bookSource: BookSource, | 
					 | 
					 | 
					 | 
					        bookSource: BookSource, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        book: Book, | 
					 | 
					 | 
					 | 
					        book: Book, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        runPerJs: Boolean = false | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ): Result<List<BookChapter>> { | 
					 | 
					 | 
					 | 
					    ): Result<List<BookChapter>> { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        book.type = bookSource.getBookType() | 
					 | 
					 | 
					 | 
					        book.type = bookSource.getBookType() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return kotlin.runCatching { | 
					 | 
					 | 
					 | 
					        return kotlin.runCatching { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            val preUpdateJs = bookSource.ruleToc?.preUpdateJs | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (runPerJs && !preUpdateJs.isNullOrBlank()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                kotlin.runCatching { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    AnalyzeRule(book, bookSource).evalJS(preUpdateJs) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                }.onFailure { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    AppLog.put("执行preUpdateJs规则失败 书源:${bookSource.bookSourceName}", it) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    throw it | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { | 
					 | 
					 | 
					 | 
					            if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                BookChapterList.analyzeChapterList( | 
					 | 
					 | 
					 | 
					                BookChapterList.analyzeChapterList( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    bookSource = bookSource, | 
					 | 
					 | 
					 | 
					                    bookSource = bookSource, | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |