|
|
@ -31,27 +31,29 @@ object BookContent { |
|
|
|
baseUrl |
|
|
|
baseUrl |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
val content = StringBuilder() |
|
|
|
val nextUrlList = arrayListOf(baseUrl) |
|
|
|
val nextUrlList = arrayListOf(baseUrl) |
|
|
|
val contentRule = bookSource.getContentRule() |
|
|
|
val contentRule = bookSource.getContentRule() |
|
|
|
var contentData = analyzeContent(body, contentRule, book, baseUrl) |
|
|
|
var contentData = analyzeContent(body, contentRule, book, baseUrl) |
|
|
|
var content = contentData.content |
|
|
|
content.append(contentData.content) |
|
|
|
if (contentData.nextUrl.size == 1) { |
|
|
|
if (contentData.nextUrl.size == 1) { |
|
|
|
var nextUrl = contentData.nextUrl[0] |
|
|
|
var nextUrl = contentData.nextUrl[0] |
|
|
|
while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) { |
|
|
|
while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) { |
|
|
|
nextUrlList.add(nextUrl) |
|
|
|
nextUrlList.add(nextUrl) |
|
|
|
AnalyzeUrl(ruleUrl = nextUrl, book = book).getResponse().execute() |
|
|
|
AnalyzeUrl(ruleUrl = nextUrl, book = book).getResponse().execute() |
|
|
|
.body()?.let { nextBody -> |
|
|
|
.body()?.let { nextBody -> |
|
|
|
analyzeContent(nextBody, contentRule, book, baseUrl) |
|
|
|
contentData = analyzeContent(nextBody, contentRule, book, baseUrl) |
|
|
|
|
|
|
|
nextUrl = if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" |
|
|
|
|
|
|
|
content.append(contentData.content) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (contentData.nextUrl.size > 1) { |
|
|
|
} else if (contentData.nextUrl.size > 1) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return content |
|
|
|
return content.toString() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun analyzeContent( |
|
|
|
private fun analyzeContent( |
|
|
|
body: String, |
|
|
|
body: String, |
|
|
|
contentRule: ContentRule, |
|
|
|
contentRule: ContentRule, |
|
|
|
book: Book, |
|
|
|
book: Book, |
|
|
|