添加一个默认订阅源,阅读下载源

pull/811/head
gedoor 4 years ago
parent a6cbb632f3
commit f21682229f
  1. 21
      app/src/main/assets/defaultData/rssSources.json
  2. 13
      app/src/main/java/io/legado/app/help/DefaultData.kt
  3. 3
      app/src/main/java/io/legado/app/help/LocalConfig.kt
  4. 4
      app/src/main/java/io/legado/app/help/storage/Backup.kt
  5. 2
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  6. 3
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt

@ -0,0 +1,21 @@
[
{
"articleStyle": 0,
"customOrder": 1,
"enableJs": true,
"enabled": true,
"loadWithBaseUrl": false,
"ruleArticles": "class.release-main-section||tbody@tr",
"ruleContent": "@js:\nif(baseUrl.match(\/90pan\/)){\nresult=result.replace(\/true\\||<a href=\"([^\"]+)\".*?><.*?>([^<]+)<\\\/span><\\\/a>\/g,'<h4><a href=\"$1\" style=\"color:#000\">$2<\/a><\/h4><p style=\"font-size:10px\">$1<\/p>\\n\\n')}\nelse{\nhtml=String(java.getString(\"@@class.markdown-body@html\",false)+java.getString(\"@@class.flex-justify-between.-1@html\",false));\nhref='https:\/\/github.com'+String(java.getString(\"@@class.flex-justify-between.-1@class.Box-body.0@a@href\",false))\nhtml+'<br><p>下载地址:<\/p><a style=\"font-size:13px\">'+href+'<\/a>'\n}",
"ruleImage": "@js:if(baseUrl.match(\/legado|704\/g)){\nresult='https:\/\/urlmin.cn\/034'\n}else{result=\"https:\/\/urlmin.cn\/15c\"}",
"ruleLink": "tag.a.0@href\n@js:if(baseUrl.match(\/90pan\/)){\nresult='https:\/\/www.90pan.com\/ajax.php,{\"method\": \"POST\",\"body\": \"action=load_down_addr1&file_id='+result.match(\/b(\\d+)\/)[1]+'\"}'}else{\nresult='https:\/\/github.com'+result\n}",
"ruleNextPage": "text.Next@href",
"rulePubDate": "tag.td!0@text||class.markdown-body@text##\\n##·",
"ruleTitle": "tag.a.0@text",
"sortUrl": "阅读2.0·GitHub::https:\/\/github.com\/gedoor\/MyBookshelf\/releases\n阅读3.0·GitHub::https:\/\/github.com\/gedoor\/legado\/releases\n阅读2.0·90盘::https:\/\/www.90pan.com\/o138703\n阅读3.0·90盘::https:\/\/www.90pan.com\/o138704",
"sourceIcon": "http:\/\/ku.mumuceo.com\/static\/images\/applogo\/yuedu.png",
"sourceName": "阅读下载",
"sourceUrl": "https:\/\/github.com\/gedoor\/legado\/releases",
"style": ""
}
]

@ -2,6 +2,7 @@ package io.legado.app.help
import io.legado.app.App
import io.legado.app.data.entities.HttpTTS
import io.legado.app.data.entities.RssSource
import io.legado.app.data.entities.TxtTocRule
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonArray
@ -45,6 +46,14 @@ object DefaultData {
GSON.fromJsonArray<ThemeConfig.Config>(json)!!
}
val rssSources by lazy {
val json = String(
App.INSTANCE.assets.open("defaultData${File.separator}rssSources.json")
.readBytes()
)
GSON.fromJsonArray<RssSource>(json)!!
}
fun importDefaultHttpTTS() {
App.db.httpTTSDao.deleteDefault()
httpTTS.let {
@ -58,4 +67,8 @@ object DefaultData {
App.db.txtTocRule.insert(*it.toTypedArray())
}
}
fun importDefaultRssSources() {
App.db.rssSourceDao.insert(*rssSources.toTypedArray())
}
}

@ -69,4 +69,7 @@ object LocalConfig {
val hasUpTxtTocRule: Boolean
get() = isLastVersion(1, "txtTocRuleVersion")
val hasUpRssSources: Boolean
get() = isLastVersion(1, "rssSourceVersion")
}

@ -29,7 +29,7 @@ object Backup {
"bookmark.json",
"bookGroup.json",
"bookSource.json",
"rssSource.json",
"rssSources.json",
"rssStar.json",
"replaceRule.json",
"readRecord.json",
@ -61,7 +61,7 @@ object Backup {
writeListToJson(App.db.bookmarkDao.all, "bookmark.json", backupPath)
writeListToJson(App.db.bookGroupDao.all, "bookGroup.json", backupPath)
writeListToJson(App.db.bookSourceDao.all, "bookSource.json", backupPath)
writeListToJson(App.db.rssSourceDao.all, "rssSource.json", backupPath)
writeListToJson(App.db.rssSourceDao.all, "rssSources.json", backupPath)
writeListToJson(App.db.rssStarDao.all, "rssStar.json", backupPath)
writeListToJson(App.db.replaceRuleDao.all, "replaceRule.json", backupPath)
writeListToJson(App.db.readRecordDao.all, "readRecord.json", backupPath)

@ -122,7 +122,7 @@ object Restore {
fileToListT<BookSource>(path, "bookSource.json")?.let {
App.db.bookSourceDao.insert(*it.toTypedArray())
}
fileToListT<RssSource>(path, "rssSource.json")?.let {
fileToListT<RssSource>(path, "rssSources.json")?.let {
App.db.rssSourceDao.insert(*it.toTypedArray())
}
fileToListT<RssStar>(path, "rssStar.json")?.let {

@ -157,6 +157,9 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
if (LocalConfig.hasUpTxtTocRule) {
DefaultData.importDefaultTocRules()
}
if (LocalConfig.hasUpRssSources) {
DefaultData.importDefaultRssSources()
}
}
}
}
Loading…
Cancel
Save