目录规则添加是否购买

pull/1319/head
gedoor 3 years ago
parent 9010f1747e
commit cd4bbb8eba
  1. 1483
      app/schemas/io.legado.app.data.AppDatabase/40.json
  2. 2
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  3. 10
      app/src/main/java/io/legado/app/data/DatabaseMigrations.kt
  4. 4
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt
  5. 1
      app/src/main/java/io/legado/app/data/entities/rule/TocRule.kt
  6. 8
      app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt

File diff suppressed because it is too large Load Diff

@ -16,7 +16,7 @@ val appDb by lazy {
}
@Database(
version = 39,
version = 40,
exportSchema = true,
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,

@ -35,7 +35,8 @@ object DatabaseMigrations {
migration_35_36,
migration_36_37,
migration_37_38,
migration_38_39
migration_38_39,
migration_39_40
)
}
@ -310,4 +311,11 @@ object DatabaseMigrations {
database.execSQL("ALTER TABLE `rssSources` ADD `concurrentRate` TEXT")
}
}
private val migration_39_40 = object : Migration(39, 40) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE `chapters` ADD `isVip` INTEGER NOT NULL DEFAULT 0")
database.execSQL("ALTER TABLE `chapters` ADD `isPay` INTEGER NOT NULL DEFAULT 0")
}
}
}

@ -30,9 +30,11 @@ import kotlinx.parcelize.Parcelize
data class BookChapter(
var url: String = "", // 章节地址
var title: String = "", // 章节标题
var baseUrl: String = "", //用来拼接相对url
var baseUrl: String = "", // 用来拼接相对url
var bookUrl: String = "", // 书籍地址
var index: Int = 0, // 章节序号
var isVip: Boolean = false, // 是否VIP
var isPay: Boolean = false, // 是否已购买
var resourceUrl: String? = null, // 音频真实URL
var tag: String? = null, //
var start: Long? = null, // 章节起始位置

@ -9,6 +9,7 @@ data class TocRule(
var chapterName: String? = null,
var chapterUrl: String? = null,
var isVip: String? = null,
var isPay: String? = null,
var updateTime: String? = null,
var nextTocUrl: String? = null
) : Parcelable

@ -166,8 +166,10 @@ object BookChapterList {
val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName)
val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl)
val vipRule = analyzeRule.splitSourceRule(tocRule.isVip)
val payRule = analyzeRule.splitSourceRule(tocRule.isPay)
val update = analyzeRule.splitSourceRule(tocRule.updateTime)
var isVip: String?
var isPay: String?
for (item in elements) {
scope.ensureActive()
analyzeRule.setContent(item)
@ -177,12 +179,16 @@ object BookChapterList {
bookChapter.url = analyzeRule.getString(urlRule)
bookChapter.tag = analyzeRule.getString(update)
isVip = analyzeRule.getString(vipRule)
isPay = analyzeRule.getString(payRule)
if (bookChapter.url.isEmpty()) {
bookChapter.url = baseUrl
}
if (bookChapter.title.isNotEmpty()) {
if (isVip.isNotEmpty() && isVip != "null" && isVip != "false" && isVip != "0") {
bookChapter.title = "\uD83D\uDD12" + bookChapter.title
bookChapter.isVip = true
}
if (isPay.isNotEmpty() && isPay != "null" && isPay != "false" && isPay != "0") {
bookChapter.isPay = true
}
chapterList.add(bookChapter)
}

Loading…
Cancel
Save