|
|
@ -1,20 +1,18 @@ |
|
|
|
package xyz.fycz.myreader.model.third3.webBook |
|
|
|
package xyz.fycz.myreader.model.third3.webBook |
|
|
|
|
|
|
|
|
|
|
|
import io.legado.app.R |
|
|
|
import android.util.Log |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
|
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
|
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
|
|
|
|
import io.legado.app.data.entities.rule.BookListRule |
|
|
|
|
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
|
|
|
|
import io.legado.app.model.Debug |
|
|
|
|
|
|
|
import io.legado.app.model.NoStackTraceException |
|
|
|
|
|
|
|
import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule |
|
|
|
import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule |
|
|
|
import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl |
|
|
|
import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.utils.NetworkUtils |
|
|
|
|
|
|
|
import io.legado.app.utils.StringUtils.wordCountFormat |
|
|
|
|
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.ensureActive |
|
|
|
import kotlinx.coroutines.ensureActive |
|
|
|
import splitties.init.appCtx |
|
|
|
import xyz.fycz.myreader.R |
|
|
|
|
|
|
|
import xyz.fycz.myreader.application.App |
|
|
|
|
|
|
|
import xyz.fycz.myreader.greendao.entity.Book |
|
|
|
|
|
|
|
import xyz.fycz.myreader.greendao.entity.rule.BookListRule |
|
|
|
|
|
|
|
import xyz.fycz.myreader.greendao.entity.rule.BookSource |
|
|
|
|
|
|
|
import xyz.fycz.myreader.model.third3.NoStackTraceException |
|
|
|
|
|
|
|
import xyz.fycz.myreader.util.utils.HtmlFormatter |
|
|
|
|
|
|
|
import xyz.fycz.myreader.util.utils.NetworkUtils |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取书籍列表 |
|
|
|
* 获取书籍列表 |
|
|
@ -25,32 +23,32 @@ object BookList { |
|
|
|
fun analyzeBookList( |
|
|
|
fun analyzeBookList( |
|
|
|
scope: CoroutineScope, |
|
|
|
scope: CoroutineScope, |
|
|
|
bookSource: BookSource, |
|
|
|
bookSource: BookSource, |
|
|
|
variableBook: SearchBook, |
|
|
|
variableBook: Book, |
|
|
|
analyzeUrl: AnalyzeUrl, |
|
|
|
analyzeUrl: AnalyzeUrl, |
|
|
|
baseUrl: String, |
|
|
|
baseUrl: String, |
|
|
|
body: String?, |
|
|
|
body: String?, |
|
|
|
isSearch: Boolean = true, |
|
|
|
isSearch: Boolean = true, |
|
|
|
): ArrayList<SearchBook> { |
|
|
|
): ArrayList<Book> { |
|
|
|
body ?: throw NoStackTraceException( |
|
|
|
body ?: throw NoStackTraceException( |
|
|
|
appCtx.getString( |
|
|
|
App.getmContext().getString( |
|
|
|
R.string.error_get_web_content, |
|
|
|
R.string.error_get_web_content, |
|
|
|
analyzeUrl.ruleUrl |
|
|
|
analyzeUrl.ruleUrl |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
val bookList = ArrayList<SearchBook>() |
|
|
|
val bookList = ArrayList<Book>() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${analyzeUrl.ruleUrl}") |
|
|
|
Log.d(bookSource.sourceUrl, "≡获取成功:${analyzeUrl.ruleUrl}") |
|
|
|
Debug.log(bookSource.bookSourceUrl, body, state = 10) |
|
|
|
Log.d(bookSource.sourceUrl, body) |
|
|
|
val analyzeRule = AnalyzeRule(variableBook, bookSource) |
|
|
|
val analyzeRule = AnalyzeRule(variableBook, bookSource) |
|
|
|
analyzeRule.setContent(body).setBaseUrl(baseUrl) |
|
|
|
analyzeRule.setContent(body).setBaseUrl(baseUrl) |
|
|
|
analyzeRule.setRedirectUrl(baseUrl) |
|
|
|
analyzeRule.setRedirectUrl(baseUrl) |
|
|
|
bookSource.bookUrlPattern?.let { |
|
|
|
bookSource.infoRule.urlPattern?.let { |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
if (baseUrl.matches(it.toRegex())) { |
|
|
|
if (baseUrl.matches(it.toRegex())) { |
|
|
|
Debug.log(bookSource.bookSourceUrl, "≡链接为详情页") |
|
|
|
Log.d(bookSource.sourceUrl, "≡链接为详情页") |
|
|
|
getInfoItem( |
|
|
|
getInfoItem( |
|
|
|
scope, bookSource, analyzeRule, analyzeUrl, body, baseUrl, variableBook.variable |
|
|
|
scope, bookSource, analyzeRule, analyzeUrl, body, baseUrl, variableBook.variable |
|
|
|
)?.let { searchBook -> |
|
|
|
)?.let { searchBook -> |
|
|
|
searchBook.infoHtml = body |
|
|
|
searchBook.putCathe("infoHtml", body) |
|
|
|
bookList.add(searchBook) |
|
|
|
bookList.add(searchBook) |
|
|
|
} |
|
|
|
} |
|
|
|
return bookList |
|
|
|
return bookList |
|
|
@ -59,11 +57,11 @@ object BookList { |
|
|
|
val collections: List<Any> |
|
|
|
val collections: List<Any> |
|
|
|
var reverse = false |
|
|
|
var reverse = false |
|
|
|
val bookListRule: BookListRule = when { |
|
|
|
val bookListRule: BookListRule = when { |
|
|
|
isSearch -> bookSource.getSearchRule() |
|
|
|
isSearch -> bookSource.searchRule |
|
|
|
bookSource.getExploreRule().bookList.isNullOrBlank() -> bookSource.getSearchRule() |
|
|
|
bookSource.findRule.url.isNullOrBlank() -> bookSource.searchRule |
|
|
|
else -> bookSource.getExploreRule() |
|
|
|
else -> bookSource.findRule |
|
|
|
} |
|
|
|
} |
|
|
|
var ruleList: String = bookListRule.bookList ?: "" |
|
|
|
var ruleList: String = bookListRule.list ?: "" |
|
|
|
if (ruleList.startsWith("-")) { |
|
|
|
if (ruleList.startsWith("-")) { |
|
|
|
reverse = true |
|
|
|
reverse = true |
|
|
|
ruleList = ruleList.substring(1) |
|
|
|
ruleList = ruleList.substring(1) |
|
|
@ -71,27 +69,27 @@ object BookList { |
|
|
|
if (ruleList.startsWith("+")) { |
|
|
|
if (ruleList.startsWith("+")) { |
|
|
|
ruleList = ruleList.substring(1) |
|
|
|
ruleList = ruleList.substring(1) |
|
|
|
} |
|
|
|
} |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取书籍列表") |
|
|
|
Log.d(bookSource.sourceUrl, "┌获取书籍列表") |
|
|
|
collections = analyzeRule.getElements(ruleList) |
|
|
|
collections = analyzeRule.getElements(ruleList) |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) { |
|
|
|
if (collections.isEmpty() && bookSource.infoRule.urlPattern.isNullOrEmpty()) { |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└列表为空,按详情页解析") |
|
|
|
Log.d(bookSource.sourceUrl, "└列表为空,按详情页解析") |
|
|
|
getInfoItem( |
|
|
|
getInfoItem( |
|
|
|
scope, bookSource, analyzeRule, analyzeUrl, body, baseUrl, variableBook.variable |
|
|
|
scope, bookSource, analyzeRule, analyzeUrl, body, baseUrl, variableBook.variable |
|
|
|
)?.let { searchBook -> |
|
|
|
)?.let { searchBook -> |
|
|
|
searchBook.infoHtml = body |
|
|
|
searchBook.putCathe("infoHtml", body) |
|
|
|
bookList.add(searchBook) |
|
|
|
bookList.add(searchBook) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val ruleName = analyzeRule.splitSourceRule(bookListRule.name) |
|
|
|
val ruleName = analyzeRule.splitSourceRule(bookListRule.name) |
|
|
|
val ruleBookUrl = analyzeRule.splitSourceRule(bookListRule.bookUrl) |
|
|
|
val ruleBookUrl = analyzeRule.splitSourceRule(bookListRule.infoUrl) |
|
|
|
val ruleAuthor = analyzeRule.splitSourceRule(bookListRule.author) |
|
|
|
val ruleAuthor = analyzeRule.splitSourceRule(bookListRule.author) |
|
|
|
val ruleCoverUrl = analyzeRule.splitSourceRule(bookListRule.coverUrl) |
|
|
|
val ruleCoverUrl = analyzeRule.splitSourceRule(bookListRule.imgUrl) |
|
|
|
val ruleIntro = analyzeRule.splitSourceRule(bookListRule.intro) |
|
|
|
val ruleIntro = analyzeRule.splitSourceRule(bookListRule.desc) |
|
|
|
val ruleKind = analyzeRule.splitSourceRule(bookListRule.kind) |
|
|
|
val ruleKind = analyzeRule.splitSourceRule(bookListRule.type) |
|
|
|
val ruleLastChapter = analyzeRule.splitSourceRule(bookListRule.lastChapter) |
|
|
|
val ruleLastChapter = analyzeRule.splitSourceRule(bookListRule.lastChapter) |
|
|
|
val ruleWordCount = analyzeRule.splitSourceRule(bookListRule.wordCount) |
|
|
|
val ruleWordCount = analyzeRule.splitSourceRule(bookListRule.wordCount) |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└列表大小:${collections.size}") |
|
|
|
Log.d(bookSource.sourceUrl, "└列表大小:${collections.size}") |
|
|
|
for ((index, item) in collections.withIndex()) { |
|
|
|
for ((index, item) in collections.withIndex()) { |
|
|
|
getSearchItem( |
|
|
|
getSearchItem( |
|
|
|
scope, bookSource, analyzeRule, item, baseUrl, variableBook.variable, |
|
|
|
scope, bookSource, analyzeRule, item, baseUrl, variableBook.variable, |
|
|
@ -105,8 +103,8 @@ object BookList { |
|
|
|
ruleLastChapter = ruleLastChapter, |
|
|
|
ruleLastChapter = ruleLastChapter, |
|
|
|
ruleWordCount = ruleWordCount |
|
|
|
ruleWordCount = ruleWordCount |
|
|
|
)?.let { searchBook -> |
|
|
|
)?.let { searchBook -> |
|
|
|
if (baseUrl == searchBook.bookUrl) { |
|
|
|
if (baseUrl == searchBook.infoUrl) { |
|
|
|
searchBook.infoHtml = body |
|
|
|
searchBook.putCathe("infoHtml", body) |
|
|
|
} |
|
|
|
} |
|
|
|
bookList.add(searchBook) |
|
|
|
bookList.add(searchBook) |
|
|
|
} |
|
|
|
} |
|
|
@ -127,13 +125,14 @@ object BookList { |
|
|
|
body: String, |
|
|
|
body: String, |
|
|
|
baseUrl: String, |
|
|
|
baseUrl: String, |
|
|
|
variable: String? |
|
|
|
variable: String? |
|
|
|
): SearchBook? { |
|
|
|
): Book? { |
|
|
|
val book = Book(variable = variable) |
|
|
|
val book = Book() |
|
|
|
book.bookUrl = analyzeUrl.ruleUrl |
|
|
|
book.variable = variable |
|
|
|
book.origin = bookSource.bookSourceUrl |
|
|
|
book.infoUrl = analyzeUrl.ruleUrl |
|
|
|
book.originName = bookSource.bookSourceName |
|
|
|
book.source = bookSource.sourceUrl |
|
|
|
book.originOrder = bookSource.customOrder |
|
|
|
//book.originName = bookSource.bookSourceName |
|
|
|
book.type = bookSource.bookSourceType |
|
|
|
//book.originOrder = bookSource.customOrder |
|
|
|
|
|
|
|
//book.type = bookSource.bookSourceType |
|
|
|
analyzeRule.book = book |
|
|
|
analyzeRule.book = book |
|
|
|
BookInfo.analyzeBookInfo( |
|
|
|
BookInfo.analyzeBookInfo( |
|
|
|
scope, |
|
|
|
scope, |
|
|
@ -146,7 +145,8 @@ object BookList { |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
if (book.name.isNotBlank()) { |
|
|
|
if (book.name.isNotBlank()) { |
|
|
|
return book.toSearchBook() |
|
|
|
//return book.toSearchBook() |
|
|
|
|
|
|
|
return book |
|
|
|
} |
|
|
|
} |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
@ -168,76 +168,98 @@ object BookList { |
|
|
|
ruleWordCount: List<AnalyzeRule.SourceRule>, |
|
|
|
ruleWordCount: List<AnalyzeRule.SourceRule>, |
|
|
|
ruleIntro: List<AnalyzeRule.SourceRule>, |
|
|
|
ruleIntro: List<AnalyzeRule.SourceRule>, |
|
|
|
ruleLastChapter: List<AnalyzeRule.SourceRule> |
|
|
|
ruleLastChapter: List<AnalyzeRule.SourceRule> |
|
|
|
): SearchBook? { |
|
|
|
): Book? { |
|
|
|
val searchBook = SearchBook(variable = variable) |
|
|
|
val searchBook = Book() |
|
|
|
searchBook.origin = bookSource.bookSourceUrl |
|
|
|
searchBook.variable = variable |
|
|
|
searchBook.originName = bookSource.bookSourceName |
|
|
|
searchBook.source = bookSource.sourceUrl |
|
|
|
|
|
|
|
/* searchBook.originName = bookSource.bookSourceName |
|
|
|
searchBook.type = bookSource.bookSourceType |
|
|
|
searchBook.type = bookSource.bookSourceType |
|
|
|
searchBook.originOrder = bookSource.customOrder |
|
|
|
searchBook.originOrder = bookSource.customOrder*/ |
|
|
|
analyzeRule.book = searchBook |
|
|
|
analyzeRule.book = searchBook |
|
|
|
analyzeRule.setContent(item) |
|
|
|
analyzeRule.setContent(item) |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取书名", log) |
|
|
|
if (log) if (log) Log.d(bookSource.sourceUrl, "┌获取书名") |
|
|
|
searchBook.name = BookHelp.formatBookName(analyzeRule.getString(ruleName)) |
|
|
|
searchBook.name = formatBookName(analyzeRule.getString(ruleName)) |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.name}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${searchBook.name}") |
|
|
|
if (searchBook.name.isNotEmpty()) { |
|
|
|
if (searchBook.name.isNotEmpty()) { |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取作者", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "┌获取作者") |
|
|
|
searchBook.author = BookHelp.formatBookAuthor(analyzeRule.getString(ruleAuthor)) |
|
|
|
searchBook.author = formatBookAuthor(analyzeRule.getString(ruleAuthor)) |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.author}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${searchBook.author}") |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取分类", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "┌获取分类") |
|
|
|
try { |
|
|
|
try { |
|
|
|
searchBook.kind = analyzeRule.getStringList(ruleKind)?.joinToString(",") |
|
|
|
searchBook.type = analyzeRule.getStringList(ruleKind)?.joinToString(",") |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.kind}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${searchBook.type}") |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${e.localizedMessage}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${e.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取字数", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "┌获取字数") |
|
|
|
try { |
|
|
|
try { |
|
|
|
searchBook.wordCount = wordCountFormat(analyzeRule.getString(ruleWordCount)) |
|
|
|
//searchBook.wordCount = wordCountFormat(analyzeRule.getString(ruleWordCount)) |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.wordCount}", log) |
|
|
|
searchBook.wordCount = analyzeRule.getString(ruleWordCount) |
|
|
|
|
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${searchBook.wordCount}") |
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${e.localizedMessage}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${e.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取最新章节", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "┌获取最新章节") |
|
|
|
try { |
|
|
|
try { |
|
|
|
searchBook.latestChapterTitle = analyzeRule.getString(ruleLastChapter) |
|
|
|
searchBook.newestChapterTitle = analyzeRule.getString(ruleLastChapter) |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.latestChapterTitle}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${searchBook.newestChapterTitle}") |
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${e.localizedMessage}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${e.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取简介", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "┌获取简介") |
|
|
|
try { |
|
|
|
try { |
|
|
|
searchBook.intro = HtmlFormatter.format(analyzeRule.getString(ruleIntro)) |
|
|
|
searchBook.desc = HtmlFormatter.format(analyzeRule.getString(ruleIntro)) |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.intro}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${searchBook.desc}") |
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${e.localizedMessage}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${e.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "┌获取封面链接") |
|
|
|
try { |
|
|
|
try { |
|
|
|
analyzeRule.getString(ruleCoverUrl).let { |
|
|
|
analyzeRule.getString(ruleCoverUrl).let { |
|
|
|
if (it.isNotEmpty()) searchBook.coverUrl = |
|
|
|
if (it.isNotEmpty()) searchBook.imgUrl = |
|
|
|
NetworkUtils.getAbsoluteURL(baseUrl, it) |
|
|
|
NetworkUtils.getAbsoluteURL(baseUrl, it) |
|
|
|
} |
|
|
|
} |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.coverUrl}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${searchBook.imgUrl}") |
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${e.localizedMessage}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${e.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
scope.ensureActive() |
|
|
|
scope.ensureActive() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取详情页链接", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "┌获取详情页链接") |
|
|
|
searchBook.bookUrl = analyzeRule.getString(ruleBookUrl, isUrl = true) |
|
|
|
searchBook.infoUrl = analyzeRule.getString(ruleBookUrl, isUrl = true) |
|
|
|
if (searchBook.bookUrl.isEmpty()) { |
|
|
|
if (searchBook.infoUrl.isEmpty()) { |
|
|
|
searchBook.bookUrl = baseUrl |
|
|
|
searchBook.infoUrl = baseUrl |
|
|
|
} |
|
|
|
} |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.bookUrl}", log) |
|
|
|
if (log) Log.d(bookSource.sourceUrl, "└${searchBook.infoUrl}") |
|
|
|
return searchBook |
|
|
|
return searchBook |
|
|
|
} |
|
|
|
} |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val nameRegex = Regex("\\s+作\\s*者.*|\\s+\\S+\\s+著") |
|
|
|
|
|
|
|
val authorRegex = Regex("^\\s*作\\s*者[::\\s]+|\\s+著") |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 格式化书名 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun formatBookName(name: String): String { |
|
|
|
|
|
|
|
return name |
|
|
|
|
|
|
|
.replace(nameRegex, "") |
|
|
|
|
|
|
|
.trim { it <= ' ' } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 格式化作者 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun formatBookAuthor(author: String): String { |
|
|
|
|
|
|
|
return author |
|
|
|
|
|
|
|
.replace(authorRegex, "") |
|
|
|
|
|
|
|
.trim { it <= ' ' } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |