|
@@ -8,7 +8,6 @@ import io.legado.app.model.Debug
|
|
|
import io.legado.app.model.NoStackTraceException
|
|
import io.legado.app.model.NoStackTraceException
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeRule
|
|
import io.legado.app.model.analyzeRule.AnalyzeRule
|
|
|
import io.legado.app.model.analyzeRule.RuleDataInterface
|
|
import io.legado.app.model.analyzeRule.RuleDataInterface
|
|
|
-import io.legado.app.utils.GSON
|
|
|
|
|
import io.legado.app.utils.NetworkUtils
|
|
import io.legado.app.utils.NetworkUtils
|
|
|
import splitties.init.appCtx
|
|
import splitties.init.appCtx
|
|
|
import java.util.*
|
|
import java.util.*
|
|
@@ -69,7 +68,7 @@ object RssParserByRule {
|
|
|
val ruleLink = analyzeRule.splitSourceRule(rssSource.ruleLink)
|
|
val ruleLink = analyzeRule.splitSourceRule(rssSource.ruleLink)
|
|
|
for ((index, item) in collections.withIndex()) {
|
|
for ((index, item) in collections.withIndex()) {
|
|
|
getItem(
|
|
getItem(
|
|
|
- sourceUrl, item, analyzeRule, index == 0,
|
|
|
|
|
|
|
+ sourceUrl, item, analyzeRule, ruleData, index == 0,
|
|
|
ruleTitle, rulePubDate, ruleDescription, ruleImage, ruleLink
|
|
ruleTitle, rulePubDate, ruleDescription, ruleImage, ruleLink
|
|
|
)?.let {
|
|
)?.let {
|
|
|
it.sort = sortName
|
|
it.sort = sortName
|
|
@@ -88,6 +87,7 @@ object RssParserByRule {
|
|
|
sourceUrl: String,
|
|
sourceUrl: String,
|
|
|
item: Any,
|
|
item: Any,
|
|
|
analyzeRule: AnalyzeRule,
|
|
analyzeRule: AnalyzeRule,
|
|
|
|
|
+ ruleData: RuleDataInterface,
|
|
|
log: Boolean,
|
|
log: Boolean,
|
|
|
ruleTitle: List<AnalyzeRule.SourceRule>,
|
|
ruleTitle: List<AnalyzeRule.SourceRule>,
|
|
|
rulePubDate: List<AnalyzeRule.SourceRule>,
|
|
rulePubDate: List<AnalyzeRule.SourceRule>,
|
|
@@ -95,7 +95,8 @@ object RssParserByRule {
|
|
|
ruleImage: List<AnalyzeRule.SourceRule>,
|
|
ruleImage: List<AnalyzeRule.SourceRule>,
|
|
|
ruleLink: List<AnalyzeRule.SourceRule>
|
|
ruleLink: List<AnalyzeRule.SourceRule>
|
|
|
): RssArticle? {
|
|
): RssArticle? {
|
|
|
- val rssArticle = RssArticle()
|
|
|
|
|
|
|
+ val rssArticle = RssArticle(variable = ruleData.variable)
|
|
|
|
|
+ analyzeRule.ruleData = rssArticle
|
|
|
analyzeRule.setContent(item)
|
|
analyzeRule.setContent(item)
|
|
|
Debug.log(sourceUrl, "┌获取标题", log)
|
|
Debug.log(sourceUrl, "┌获取标题", log)
|
|
|
rssArticle.title = analyzeRule.getString(ruleTitle)
|
|
rssArticle.title = analyzeRule.getString(ruleTitle)
|
|
@@ -117,7 +118,6 @@ object RssParserByRule {
|
|
|
Debug.log(sourceUrl, "┌获取文章链接", log)
|
|
Debug.log(sourceUrl, "┌获取文章链接", log)
|
|
|
rssArticle.link = NetworkUtils.getAbsoluteURL(sourceUrl, analyzeRule.getString(ruleLink))
|
|
rssArticle.link = NetworkUtils.getAbsoluteURL(sourceUrl, analyzeRule.getString(ruleLink))
|
|
|
Debug.log(sourceUrl, "└${rssArticle.link}", log)
|
|
Debug.log(sourceUrl, "└${rssArticle.link}", log)
|
|
|
- rssArticle.variable = analyzeRule.ruleData?.variableMap?.let { GSON.toJson(it) }
|
|
|
|
|
if (rssArticle.title.isBlank()) {
|
|
if (rssArticle.title.isBlank()) {
|
|
|
return null
|
|
return null
|
|
|
}
|
|
}
|