|
|
@ -22,18 +22,20 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
fun searchBook( |
|
|
|
fun searchBook( |
|
|
|
key: String, |
|
|
|
key: String, |
|
|
|
page: Int? = 1, |
|
|
|
page: Int? = 1, |
|
|
|
|
|
|
|
variableBook: SearchBook, |
|
|
|
scope: CoroutineScope = Coroutine.DEFAULT, |
|
|
|
scope: CoroutineScope = Coroutine.DEFAULT, |
|
|
|
context: CoroutineContext = Dispatchers.IO |
|
|
|
context: CoroutineContext = Dispatchers.IO, |
|
|
|
): Coroutine<ArrayList<SearchBook>> { |
|
|
|
): Coroutine<ArrayList<SearchBook>> { |
|
|
|
return Coroutine.async(scope, context) { |
|
|
|
return Coroutine.async(scope, context) { |
|
|
|
searchBookSuspend(scope, key, page) |
|
|
|
searchBookSuspend(scope, key, page, variableBook) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
suspend fun searchBookSuspend( |
|
|
|
suspend fun searchBookSuspend( |
|
|
|
scope: CoroutineScope, |
|
|
|
scope: CoroutineScope, |
|
|
|
key: String, |
|
|
|
key: String, |
|
|
|
page: Int? = 1 |
|
|
|
page: Int? = 1, |
|
|
|
|
|
|
|
variableBook: SearchBook, |
|
|
|
): ArrayList<SearchBook> { |
|
|
|
): ArrayList<SearchBook> { |
|
|
|
bookSource.searchUrl?.let { searchUrl -> |
|
|
|
bookSource.searchUrl?.let { searchUrl -> |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
@ -41,7 +43,8 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
key = key, |
|
|
|
key = key, |
|
|
|
page = page, |
|
|
|
page = page, |
|
|
|
baseUrl = sourceUrl, |
|
|
|
baseUrl = sourceUrl, |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
headerMapF = bookSource.getHeaderMap(), |
|
|
|
|
|
|
|
book = variableBook |
|
|
|
) |
|
|
|
) |
|
|
|
val res = analyzeUrl.getResponseAwait(bookSource.bookSourceUrl) |
|
|
|
val res = analyzeUrl.getResponseAwait(bookSource.bookSourceUrl) |
|
|
|
return BookList.analyzeBookList( |
|
|
|
return BookList.analyzeBookList( |
|
|
@ -50,6 +53,7 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
bookSource, |
|
|
|
bookSource, |
|
|
|
analyzeUrl, |
|
|
|
analyzeUrl, |
|
|
|
res.url, |
|
|
|
res.url, |
|
|
|
|
|
|
|
variableBook, |
|
|
|
true |
|
|
|
true |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -62,8 +66,9 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
fun exploreBook( |
|
|
|
fun exploreBook( |
|
|
|
url: String, |
|
|
|
url: String, |
|
|
|
page: Int? = 1, |
|
|
|
page: Int? = 1, |
|
|
|
|
|
|
|
variableBook: SearchBook, |
|
|
|
scope: CoroutineScope = Coroutine.DEFAULT, |
|
|
|
scope: CoroutineScope = Coroutine.DEFAULT, |
|
|
|
context: CoroutineContext = Dispatchers.IO |
|
|
|
context: CoroutineContext = Dispatchers.IO, |
|
|
|
): Coroutine<List<SearchBook>> { |
|
|
|
): Coroutine<List<SearchBook>> { |
|
|
|
return Coroutine.async(scope, context) { |
|
|
|
return Coroutine.async(scope, context) { |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
@ -79,6 +84,7 @@ class WebBook(val bookSource: BookSource) { |
|
|
|
bookSource, |
|
|
|
bookSource, |
|
|
|
analyzeUrl, |
|
|
|
analyzeUrl, |
|
|
|
res.url, |
|
|
|
res.url, |
|
|
|
|
|
|
|
variableBook, |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|