pull/32/head
kunfei 5 years ago
parent a385977aca
commit d4153b5d43
  1. 44
      app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt
  2. 8
      app/src/main/java/io/legado/app/model/webbook/ChapterData.kt

@ -1,5 +1,47 @@
package io.legado.app.model.webbook package io.legado.app.model.webbook
object BookChapterList { import io.legado.app.App
import io.legado.app.R
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.TocRule
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.NetworkUtils
import retrofit2.Response
class BookChapterList {
fun analyzeChapterList(
book: Book,
response: Response<String>,
bookSource: BookSource,
analyzeUrl: AnalyzeUrl
): List<BookChapter> {
val chapterList = arrayListOf<BookChapter>()
val baseUrl: String = NetworkUtils.getUrl(response)
val body: String? = response.body()
body ?: throw Exception(
App.INSTANCE.getString(
R.string.get_web_content_error,
baseUrl
)
)
val tocRule = bookSource.getTocRule()
val nextUrlList = arrayListOf(baseUrl)
val chapterData = analyzeChapterList(body, tocRule)
chapterList.addAll(chapterData.chapterList)
return chapterList
}
private fun analyzeChapterList(body: String, tocRule: TocRule): ChapterData {
val chapterList = arrayListOf<BookChapter>()
val nextUrlList = arrayListOf<String>()
return ChapterData(chapterList, nextUrlList)
}
} }

@ -0,0 +1,8 @@
package io.legado.app.model.webbook
import io.legado.app.data.entities.BookChapter
data class ChapterData(
var chapterList: List<BookChapter>,
var nextUrlList: List<String>
)
Loading…
Cancel
Save