pull/48/head
kunfei 5 years ago
parent 3109357326
commit c96774783b
  1. 319
      app/src/main/assets/rssSource.json
  2. 3
      app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt
  3. 6
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  4. 21
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt

@ -0,0 +1,319 @@
[
{
"customOrder": 14,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "class.wrap",
"ruleContent": "@js:String(result).replace(/<html[\\s\\S]*class=\"main-wrap/,'<body><div class=\"main-wrap>').replace(/<div class=\"qr\">[\\s\\S]*/,\"</body>\")",
"ruleImage": "tag.img@src",
"ruleLink": "class.link-button@href",
"rulePubDate": "",
"ruleTitle": "class.title@text",
"sourceGroup": "Origin",
"sourceIcon": "http://static.daily.zhihu.com/img/app-logo.png",
"sourceName": "知乎日報",
"sourceUrl": "https://daily.zhihu.com"
},
{
"customOrder": 2,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "@css:.cell.item",
"ruleContent": "@js:var doc=org.jsoup.Jsoup.parse(result);\n\"<h1>\"+doc.select(\"h1\").text()+\"</h1>\"+String(doc.select(\"#img-content\").html()).replace(/data-src=/g,\"src=\")",
"ruleImage": "@css:.topic_image>img@src",
"ruleLink": "@css:.item_title>a@href",
"rulePubDate": "@css:.fade@text",
"ruleTitle": "@css:.item_title@text",
"sourceGroup": "JTKS",
"sourceIcon": "https://gitee.com/alanskycn/yuedu/raw/master/JS/xiaoshuoshiyi.jpg",
"sourceName": "小說拾遺",
"sourceUrl": "http://www.jintiankansha.me/column/LoglHJhFTR"
},
{
"customOrder": 1,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "@css:.cell.item",
"ruleContent": "<js>var doc=org.jsoup.Jsoup.parse(result);\n\"<h1>\"+doc.select(\"h1\").text()+\"</h1>\"+String(doc.select(\"#img-content\").html()).replace(/data-src=/g,\"src=\")</js>",
"ruleImage": "@css:.topic_image>img@src",
"ruleLink": "@css:.item_title>a@href",
"rulePubDate": "@css:.fade@text",
"ruleTitle": "@css:.item_title@text",
"sourceGroup": "JTKS",
"sourceIcon": "http://img.100weidu.com/weixin/head/MzI5NTA4NjgwNw==",
"sourceName": "赤戟的书荒救济所",
"sourceUrl": "http://www.jintiankansha.me/column/qOcZgyKfdi"
},
{
"customOrder": 3,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "@css:.t_news",
"ruleContent": "@js:org.jsoup.Jsoup.parse(result).select(\".news_content\").html()",
"ruleImage": "@css:.img_t>a:eq(0)>img@src##^##https:",
"ruleLink": "@css:.news_tit02 a@href",
"rulePubDate": "@css:.news_info>span:eq(1)@text",
"ruleTitle": "@css:.news_tit02 a@text",
"sourceGroup": "",
"sourceIcon": "https://file.thepaper.cn/wap/v3/img/deskicon.png",
"sourceName": "澎湃新闻",
"sourceUrl": "https://m.thepaper.cn/"
},
{
"customOrder": 6,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/qdaily.jpg",
"sourceName": "好奇心日报",
"sourceUrl": "http://47.105.79.245/v3/article?feedId=13&articleId=0&pageSize=20&isLookDown=true"
},
{
"customOrder": 5,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/mtime.jpg",
"sourceName": "时光网",
"sourceUrl": "http://47.105.79.245/v3/article?feedId=27&articleId=0&pageSize=20&isLookDown=true"
},
{
"customOrder": 8,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/zimuzu-9999x0w.jpg",
"sourceName": "字幕组",
"sourceUrl": "http://47.105.79.245/v3/article?feedId=3&articleId=0&pageSize=20&isLookDown=true"
},
{
"customOrder": 11,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/doubanmoviereview.jpg",
"sourceName": "豆瓣最受欢迎的影评",
"sourceUrl": "http://47.105.79.245/v3/article?feedId=76&articleId=0&pageSize=20&isLookDown=true"
},
{
"customOrder": 7,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/anitama.jpg",
"sourceName": "Anitama",
"sourceUrl": "http://47.105.79.245/v3/article?feedId=86&articleId=0&pageSize=20&isLookDown=true"
},
{
"customOrder": 12,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/nfw.png",
"sourceName": "南方要闻",
"sourceUrl": "http://47.105.79.245/v2/article/newest,{\n \"headers\": \"{User-Agent:\\\"okhttp/3.10.0\\\",Content-Type:\\\"application/json; charset=UTF-8\\\",Content-Length:27}\",\n \"method\": \"POST\",\n \"body\": \"{\\\"articleId\\\":0,\\\"feedId\\\":80}\"\n}"
},
{
"customOrder": 9,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/iplaysoft.png",
"sourceName": "异次元软件世界",
"sourceUrl": "http://47.105.79.245/v2/article/newest,{\n \"headers\": \"{User-Agent:\\\"okhttp/3.10.0\\\",Content-Type:\\\"application/json; charset=UTF-8\\\",Content-Length:27}\",\n \"method\": \"POST\",\n \"body\": \"{\\\"articleId\\\":0,\\\"feedId\\\":51}\"\n}"
},
{
"customOrder": 13,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/appin.png",
"sourceName": "小众软件",
"sourceUrl": "http://47.105.79.245/v2/article/newest,{\n \"headers\": \"{User-Agent:\\\"okhttp/3.10.0\\\",Content-Type:\\\"application/json; charset=UTF-8\\\",Content-Length:27}\",\n \"method\": \"POST\",\n \"body\": \"{\\\"articleId\\\":0,\\\"feedId\\\":14}\"\n}"
},
{
"customOrder": 15,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/zhangzishi.png",
"sourceName": "涨姿势",
"sourceUrl": "http://47.105.79.245/v2/article/newest,{\n \"headers\": \"{User-Agent:\\\"okhttp/3.10.0\\\",Content-Type:\\\"application/json; charset=UTF-8\\\",Content-Length:27}\",\n \"method\": \"POST\",\n \"body\": \"{\\\"articleId\\\":0,\\\"feedId\\\":78}\"\n}"
},
{
"customOrder": 16,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/penti.png",
"sourceName": "喷嚏图卦",
"sourceUrl": "http://47.105.79.245/v3/article?feedId=66&articleId=0&pageSize=20&isLookDown=true"
},
{
"customOrder": 17,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/guancha.jpg",
"sourceName": "观察者 要闻",
"sourceUrl": "http://47.105.79.245/v2/article/newest,{\n \"headers\": \"{User-Agent:\\\"okhttp/3.10.0\\\",Content-Type:\\\"application/json; charset=UTF-8\\\",Content-Length:28}\",\n \"method\": \"POST\",\n \"body\": \"{\\\"articleId\\\":0,\\\"feedId\\\":105}\"\n}"
},
{
"customOrder": 18,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/meiriyiwen.png",
"sourceName": "每日一文",
"sourceUrl": "http://47.105.79.245/v2/article/newest,{\n \"headers\": \"{User-Agent:\\\"okhttp/3.10.0\\\",Content-Type:\\\"application/json; charset=UTF-8\\\",Content-Length:27}\",\n \"method\": \"POST\",\n \"body\": \"{\\\"articleId\\\":0,\\\"feedId\\\":87}\"\n}"
},
{
"customOrder": 4,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": false,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "http://47.105.79.245/netease.jpg",
"sourceName": "网易要闻",
"sourceUrl": "http://47.105.79.245/v2/article/newest,{\n \"headers\": \"{User-Agent:\\\"okhttp/3.10.0\\\",Content-Type:\\\"application/json; charset=UTF-8\\\",Content-Length:27}\",\n \"method\": \"POST\",\n \"body\": \"{\\\"articleId\\\":0,\\\"feedId\\\":98}\"\n}"
},
{
"customOrder": 19,
"enableJs": false,
"enabled": true,
"loadWithBaseUrl": false,
"ruleArticles": "$.data.data[*]",
"ruleContent": "<h1>{$.data.title}</h1><p>时间:{$.data.createTimeString}({$.data.createTime})</p>{$.data.content}<a href=\"{$.data.url}\">原文链接</a>",
"ruleDescription": "",
"ruleImage": "$.thumbnail",
"ruleLink": "http://47.105.79.245/v2/text/{$.id}",
"rulePubDate": "$.createTimeString",
"ruleTitle": "$.title",
"sourceGroup": "",
"sourceIcon": "https://static.zhihu.com/heifetz/assets/apple-touch-icon-120.b3e6278d.png",
"sourceName": "知乎每日精选",
"sourceUrl": "http://47.105.79.245/v2/article/newest,{\n \"headers\": \"{User-Agent:\\\"okhttp/3.10.0\\\",Content-Type:\\\"application/json; charset=UTF-8\\\",Content-Length:26}\",\n \"method\": \"POST\",\n \"body\": \"{\\\"articleId\\\":0,\\\"feedId\\\":8}\"\n}"
},
{
"customOrder": 0,
"enableJs": true,
"enabled": true,
"loadWithBaseUrl": true,
"ruleArticles": "@css:.booklist-card",
"ruleContent": "",
"ruleLink": "@css:.booklist-card-content>a@href##^##http://www\\.yousuu\\.com",
"rulePubDate": "@css:.ResultBooklistItemClasses,.ResultBooklistItemUpdateAt@text##,,##,",
"ruleTitle": "@css:.booklist-card-content>a@text",
"sourceGroup": "",
"sourceIcon": "https://gitee.com/alanskycn/yuedu/raw/master/JS/youshuwang.png",
"sourceName": "优书网",
"sourceUrl": "http://www.yousuu.com/booklists?type=man&screen=latest&page=1"
}
]

@ -13,6 +13,9 @@ interface RssSourceDao {
@get:Query("SELECT * FROM rssSources") @get:Query("SELECT * FROM rssSources")
val all: List<RssSource> val all: List<RssSource>
@get:Query("select count(sourceUrl) from rssSources")
val size: Int
@Query("SELECT * FROM rssSources order by customOrder") @Query("SELECT * FROM rssSources order by customOrder")
fun liveAll(): LiveData<List<RssSource>> fun liveAll(): LiveData<List<RssSource>>

@ -68,10 +68,12 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
PermissionsCompat.Builder(this@MainActivity) PermissionsCompat.Builder(this@MainActivity)
.addPermissions(*Permissions.Group.STORAGE) .addPermissions(*Permissions.Group.STORAGE)
.rationale(R.string.tip_perm_request_storage) .rationale(R.string.tip_perm_request_storage)
.onGranted { viewModel.restore() } .onGranted { viewModel.importYueDuData() }
.request() .request()
} }
noButton { } noButton {
viewModel.initRssSource()
}
}.show().applyTint() }.show().applyTint()
} }
} }

@ -5,19 +5,22 @@ import io.legado.app.App
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.constant.BookType import io.legado.app.constant.BookType
import io.legado.app.constant.Bus import io.legado.app.constant.Bus
import io.legado.app.data.entities.RssSource
import io.legado.app.help.storage.Restore import io.legado.app.help.storage.Restore
import io.legado.app.model.WebBook import io.legado.app.model.WebBook
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonArray
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
class MainViewModel(application: Application) : BaseViewModel(application) { class MainViewModel(application: Application) : BaseViewModel(application) {
val updateList = arrayListOf<String>() val updateList = arrayListOf<String>()
fun restore() { fun importYueDuData() {
launch(IO) { execute {
Restore.importYueDuData(getApplication()) Restore.importYueDuData(getApplication())
initRssSource()
} }
} }
@ -57,4 +60,16 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
} }
} }
} }
fun initRssSource() {
execute {
if (App.db.rssSourceDao().size == 0) {
val json = String(context.assets.open("rssSource.json").readBytes())
val sources = GSON.fromJsonArray<RssSource>(json)
if (sources != null) {
App.db.rssSourceDao().insert(*sources.toTypedArray())
}
}
}
}
} }
Loading…
Cancel
Save