mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
添加书籍地址优先匹配启用的规则
This commit is contained in:
parent
10bdb9962c
commit
4c47e4a24a
@ -74,7 +74,7 @@ interface BookSourceDao {
|
||||
@Query("select * from book_sources where enabled = 1 and bookSourceGroup like '%' || :group || '%'")
|
||||
fun getEnabledByGroup(group: String): List<BookSource>
|
||||
|
||||
@get:Query("select * from book_sources where trim(bookUrlPattern) <> ''")
|
||||
@get:Query("select * from book_sources where trim(bookUrlPattern) <> '' order by enabled desc, customOrder")
|
||||
val hasBookUrlPattern: List<BookSource>
|
||||
|
||||
@get:Query("select * from book_sources where bookSourceGroup is null or bookSourceGroup = ''")
|
||||
|
@ -117,7 +117,7 @@ object RssParserByRule {
|
||||
Debug.log(sourceUrl, "┌获取文章链接", log)
|
||||
rssArticle.link = NetworkUtils.getAbsoluteURL(sourceUrl, analyzeRule.getString(ruleLink))
|
||||
Debug.log(sourceUrl, "└${rssArticle.link}", log)
|
||||
rssArticle.variable = GSON.toJson(analyzeRule.ruleData.variableMap)
|
||||
rssArticle.variable = analyzeRule.ruleData?.variableMap?.let { GSON.toJson(it) }
|
||||
if (rssArticle.title.isBlank()) {
|
||||
return null
|
||||
}
|
||||
|
@ -24,7 +24,9 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
|
||||
fun addBookByUrl(bookUrls: String) {
|
||||
var successCount = 0
|
||||
execute {
|
||||
var hasBookUrlPattern: List<BookSource>? = null
|
||||
val hasBookUrlPattern: List<BookSource> by lazy {
|
||||
appDb.bookSourceDao.hasBookUrlPattern
|
||||
}
|
||||
val urls = bookUrls.split("\n")
|
||||
for (url in urls) {
|
||||
val bookUrl = url.trim()
|
||||
@ -33,9 +35,6 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
|
||||
val baseUrl = NetworkUtils.getBaseUrl(bookUrl) ?: continue
|
||||
var source = appDb.bookSourceDao.getBookSource(baseUrl)
|
||||
if (source == null) {
|
||||
if (hasBookUrlPattern == null) {
|
||||
hasBookUrlPattern = appDb.bookSourceDao.hasBookUrlPattern
|
||||
}
|
||||
hasBookUrlPattern.forEach { bookSource ->
|
||||
if (bookUrl.matches(bookSource.bookUrlPattern!!.toRegex())) {
|
||||
source = bookSource
|
||||
|
Loading…
Reference in New Issue
Block a user