arena: add parseSearchResult function
@@ -106,8 +106,15 @@ open class Arena : OkHttpBaseApi() {
?: 0
val coverAjaxUrls = getAjaxUrls(doc)
- val results = doc.select(".arena-record").mapIndexed { i, record ->
- SearchResult().apply {
+ val results = doc.select(".arena-record").map{ record ->
+ parseSearchResult(record, coverAjaxUrls)
+ }
+ return SearchRequestResult(results, count, page)
+ }
+
+ protected fun parseSearchResult(record: Element, coverAjaxUrls: Map<String, String>):
+ SearchResult {
+ return SearchResult().apply {
val title = record.select(".arena-record-title").text
val year = record.select(".arena-record-year .arena-value").first()?.text
val author = record.select(".arena-record-author .arena-value").map { it.text }.joinToString(", ")
@@ -117,8 +124,6 @@ open class Arena : OkHttpBaseApi() {
cover = getCover(record, coverAjaxUrls)
}
}
- return SearchRequestResult(results, count, page)
- }
internal fun getCover(record: Element, coverAjaxUrls: Map<String, String>? = null): String? {
val coverHolder = record.select(".arena-record-cover").first()
