|
|
@ -7,7 +7,6 @@ import io.legado.app.model.WebBook |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.fromJsonObject |
|
|
|
import io.legado.app.utils.fromJsonObject |
|
|
|
import io.legado.app.web.utils.ReturnData |
|
|
|
import io.legado.app.web.utils.ReturnData |
|
|
|
import kotlinx.coroutines.runBlocking |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BookshelfController { |
|
|
|
class BookshelfController { |
|
|
|
|
|
|
|
|
|
|
@ -37,25 +36,18 @@ class BookshelfController { |
|
|
|
return returnData.setErrorMsg("参数url不能为空,请指定内容地址") |
|
|
|
return returnData.setErrorMsg("参数url不能为空,请指定内容地址") |
|
|
|
} |
|
|
|
} |
|
|
|
val book = App.db.bookDao().getBook(strings[0]) |
|
|
|
val book = App.db.bookDao().getBook(strings[0]) |
|
|
|
val chapter = App.db.bookChapterDao().getChapter(strings[0], 1) |
|
|
|
val chapter = App.db.bookChapterDao().getChapter(strings[0], strings[1].toInt()) |
|
|
|
if (book == null || chapter == null) { |
|
|
|
if (book == null || chapter == null) { |
|
|
|
returnData.setErrorMsg("未找到") |
|
|
|
returnData.setErrorMsg("未找到") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val content = BookHelp.getContent(book, chapter) |
|
|
|
var content = BookHelp.getContent(book, chapter) |
|
|
|
if (content != null) { |
|
|
|
if (content != null) { |
|
|
|
returnData.setData(content) |
|
|
|
returnData.setData(content) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
runBlocking { |
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { source -> |
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { source -> |
|
|
|
content = WebBook(source).getContentBlocking(book, chapter) |
|
|
|
WebBook(source).getContent(book, chapter) |
|
|
|
returnData.setErrorMsg(content) |
|
|
|
.onSuccess { |
|
|
|
} ?: returnData.setErrorMsg("未找到书源") |
|
|
|
returnData.setData(it!!) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.onError { |
|
|
|
|
|
|
|
returnData.setErrorMsg(it.localizedMessage) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} ?: returnData.setErrorMsg("未找到书源") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return returnData |
|
|
|
return returnData |
|
|
|