|
|
@ -10,7 +10,6 @@ import io.legado.app.model.webbook.BookChapterList |
|
|
|
import io.legado.app.model.webbook.BookContent |
|
|
|
import io.legado.app.model.webbook.BookContent |
|
|
|
import io.legado.app.model.webbook.BookInfo |
|
|
|
import io.legado.app.model.webbook.BookInfo |
|
|
|
import io.legado.app.model.webbook.BookList |
|
|
|
import io.legado.app.model.webbook.BookList |
|
|
|
import io.legado.app.utils.NetworkUtils |
|
|
|
|
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
@ -38,21 +37,12 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
baseUrl = sourceUrl, |
|
|
|
baseUrl = sourceUrl, |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
) |
|
|
|
) |
|
|
|
val baseUrl: String |
|
|
|
|
|
|
|
val body = if (analyzeUrl.useWebView) { |
|
|
|
|
|
|
|
val res = analyzeUrl.getResultByWebView(bookSource.bookSourceUrl) |
|
|
|
|
|
|
|
baseUrl = res.url |
|
|
|
|
|
|
|
res.content |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val res = analyzeUrl.getResponseAwait() |
|
|
|
val res = analyzeUrl.getResponseAwait() |
|
|
|
baseUrl = NetworkUtils.getUrl(res) |
|
|
|
|
|
|
|
res.body() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BookList.analyzeBookList( |
|
|
|
BookList.analyzeBookList( |
|
|
|
body, |
|
|
|
res.body, |
|
|
|
bookSource, |
|
|
|
bookSource, |
|
|
|
analyzeUrl, |
|
|
|
analyzeUrl, |
|
|
|
baseUrl, |
|
|
|
res.url, |
|
|
|
true |
|
|
|
true |
|
|
|
) |
|
|
|
) |
|
|
|
} ?: arrayListOf() |
|
|
|
} ?: arrayListOf() |
|
|
@ -75,21 +65,12 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
baseUrl = sourceUrl, |
|
|
|
baseUrl = sourceUrl, |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
) |
|
|
|
) |
|
|
|
val baseUrl: String |
|
|
|
|
|
|
|
val body = if (analyzeUrl.useWebView) { |
|
|
|
|
|
|
|
val res = analyzeUrl.getResultByWebView(bookSource.bookSourceUrl) |
|
|
|
|
|
|
|
baseUrl = res.url |
|
|
|
|
|
|
|
res.content |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val res = analyzeUrl.getResponseAwait() |
|
|
|
val res = analyzeUrl.getResponseAwait() |
|
|
|
baseUrl = NetworkUtils.getUrl(res) |
|
|
|
|
|
|
|
res.body() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BookList.analyzeBookList( |
|
|
|
BookList.analyzeBookList( |
|
|
|
body, |
|
|
|
res.body, |
|
|
|
bookSource, |
|
|
|
bookSource, |
|
|
|
analyzeUrl, |
|
|
|
analyzeUrl, |
|
|
|
baseUrl, |
|
|
|
res.url, |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -114,12 +95,7 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
baseUrl = sourceUrl, |
|
|
|
baseUrl = sourceUrl, |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
) |
|
|
|
) |
|
|
|
if (analyzeUrl.useWebView) { |
|
|
|
analyzeUrl.getResponseAwait().body |
|
|
|
bookSource.getContentRule() |
|
|
|
|
|
|
|
analyzeUrl.getResultByWebView(bookSource.bookSourceUrl).content |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
analyzeUrl.getResponseAwait().body() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
BookInfo.analyzeBookInfo(book, body, bookSource, book.bookUrl) |
|
|
|
BookInfo.analyzeBookInfo(book, body, bookSource, book.bookUrl) |
|
|
|
book |
|
|
|
book |
|
|
@ -139,17 +115,12 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
val body = if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { |
|
|
|
val body = if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { |
|
|
|
book.tocHtml |
|
|
|
book.tocHtml |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
AnalyzeUrl( |
|
|
|
book = book, |
|
|
|
book = book, |
|
|
|
ruleUrl = book.tocUrl, |
|
|
|
ruleUrl = book.tocUrl, |
|
|
|
baseUrl = book.bookUrl, |
|
|
|
baseUrl = book.bookUrl, |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
) |
|
|
|
).getResponseAwait().body |
|
|
|
if (analyzeUrl.useWebView) { |
|
|
|
|
|
|
|
analyzeUrl.getResultByWebView(bookSource.bookSourceUrl).content |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
analyzeUrl.getResponseAwait().body() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
BookChapterList.analyzeChapterList(this, book, body, bookSource, book.tocUrl) |
|
|
|
BookChapterList.analyzeChapterList(this, book, body, bookSource, book.tocUrl) |
|
|
|
} |
|
|
|
} |
|
|
@ -179,15 +150,11 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
baseUrl = book.tocUrl, |
|
|
|
baseUrl = book.tocUrl, |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
) |
|
|
|
) |
|
|
|
if (analyzeUrl.useWebView) { |
|
|
|
analyzeUrl.getResponseAwait( |
|
|
|
analyzeUrl.getResultByWebView( |
|
|
|
|
|
|
|
bookSource.bookSourceUrl, |
|
|
|
bookSource.bookSourceUrl, |
|
|
|
jsStr = bookSource.getContentRule().webJs, |
|
|
|
jsStr = bookSource.getContentRule().webJs, |
|
|
|
sourceRegex = bookSource.getContentRule().sourceRegex |
|
|
|
sourceRegex = bookSource.getContentRule().sourceRegex |
|
|
|
).content |
|
|
|
).body |
|
|
|
} else { |
|
|
|
|
|
|
|
analyzeUrl.getResponseAwait().body() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
BookContent.analyzeContent( |
|
|
|
BookContent.analyzeContent( |
|
|
|
this, |
|
|
|
this, |
|
|
|