pull/32/head
kunfei 5 years ago
parent 2c51e1453f
commit c56587894b
  1. 2
      app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt
  2. 6
      app/src/main/java/io/legado/app/model/webbook/BookList.kt
  3. 10
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt

@ -35,6 +35,4 @@ interface SearchBookDao {
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg searchBook: SearchBook): List<Long> fun insert(vararg searchBook: SearchBook): List<Long>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(searchBook: SearchBook): Long
} }

@ -112,11 +112,11 @@ object BookList {
} }
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取书名") SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取书名")
searchBook.name = analyzeRule.getString(name ?: "") ?: "" searchBook.name = analyzeRule.getString(name ?: "") ?: ""
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.name ?: "") SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.name)
if (searchBook.name.isNotEmpty()) { if (searchBook.name.isNotEmpty()) {
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取作者") SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取作者")
searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(author ?: "")) searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(author ?: ""))
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author ?: "") SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author)
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取分类") SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取分类")
searchBook.kind = analyzeRule.getString(kind ?: "") searchBook.kind = analyzeRule.getString(kind ?: "")
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.kind ?: "") SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.kind ?: "")
@ -169,7 +169,7 @@ object BookList {
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.bookUrl, printLog) SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.bookUrl, printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取作者", printLog) SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取作者", printLog)
searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(ruleAuthor)) searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(ruleAuthor))
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author ?: "", printLog) SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author, printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取分类", printLog) SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取分类", printLog)
searchBook.kind = analyzeRule.getString(ruleKind) searchBook.kind = analyzeRule.getString(ruleKind)
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.kind ?: "", printLog) SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.kind ?: "", printLog)

@ -65,11 +65,11 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource ->
WebBook(bookSource).getChapterList(book, this) WebBook(bookSource).getChapterList(book, this)
.onSuccess(Dispatchers.IO) { .onSuccess(Dispatchers.IO) {
it?.let { it?.map { chapter ->
if (it.isNotEmpty()) { book.latestChapterTitle = chapter.title
book.latestChapterTitle = it.last().title val searchBook = book.toSearchBook()
searchBooks.add(book.toSearchBook()) searchBooks.add(searchBook)
} App.db.searchBookDao().insert(searchBook)
} }
}.onError { }.onError {
toast(R.string.error_get_chapter_list) toast(R.string.error_get_chapter_list)

Loading…
Cancel
Save