pull/21/head
fengyuecanzhu 3 years ago
parent 42ccafde13
commit 7d17796e55
  1. 1
      app/src/main/java/xyz/fycz/myreader/common/APPCONST.java
  2. 5
      app/src/main/java/xyz/fycz/myreader/greendao/entity/Chapter.java
  3. 9
      app/src/main/java/xyz/fycz/myreader/greendao/entity/rule/BookSource.java
  4. 13
      app/src/main/java/xyz/fycz/myreader/greendao/service/ChapterService.java
  5. 4
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeRule.kt
  6. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt
  7. 1
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookChapterList.kt
  8. 7
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookContent.kt
  9. 6
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookInfo.kt

@ -127,6 +127,7 @@ public class APPCONST {
}.getType(); }.getType();
public static final Pattern JS_PATTERN = Pattern.compile("(<js>[\\w\\W]*?</js>|@js:[\\w\\W]*$)", Pattern.CASE_INSENSITIVE); public static final Pattern JS_PATTERN = Pattern.compile("(<js>[\\w\\W]*?</js>|@js:[\\w\\W]*$)", Pattern.CASE_INSENSITIVE);
public static final Pattern JS_PATTERN_3 = Pattern.compile("<js>([\\w\\W]*?)</js>|@js:([\\w\\W]*)", Pattern.CASE_INSENSITIVE);
public static final Pattern EXP_PATTERN = Pattern.compile("\\{\\{([\\w\\W]*?)\\}\\}"); public static final Pattern EXP_PATTERN = Pattern.compile("\\{\\{([\\w\\W]*?)\\}\\}");
// public static final Pattern IMG_PATTERN = Pattern.compile("<img .*?src.*?=.*?\"(.*?(?:,\\{.*\\})?)\".*?>", Pattern.CASE_INSENSITIVE); // public static final Pattern IMG_PATTERN = Pattern.compile("<img .*?src.*?=.*?\"(.*?(?:,\\{.*\\})?)\".*?>", Pattern.CASE_INSENSITIVE);

@ -23,11 +23,6 @@ import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/**
* 章节
* Created by zhao on 2017/7/24.
*/
@Entity @Entity
public class Chapter implements RuleDataInterface { public class Chapter implements RuleDataInterface {
@Id @Id

@ -74,12 +74,12 @@ public class BookSource implements Parcelable, Cloneable {
@Convert(converter = FindRuleConvert.class, columnType = String.class) @Convert(converter = FindRuleConvert.class, columnType = String.class)
private FindRule findRule; private FindRule findRule;
@Generated(hash = 906128088) @Generated(hash = 798251066)
public BookSource(String sourceUrl, String sourceEName, String sourceName, String sourceGroup, public BookSource(String sourceUrl, String sourceEName, String sourceName, String sourceGroup,
String sourceCharset, String sourceType, String sourceHeaders, String loginUrl, String sourceCharset, String sourceType, String sourceHeaders, String loginUrl,
String sourceComment, String concurrentRate, Long lastUpdateTime, int orderNum, int weight, String loginCheckJs, String sourceComment, String concurrentRate, Long lastUpdateTime,
boolean enable, SearchRule searchRule, InfoRule infoRule, TocRule tocRule, int orderNum, int weight, boolean enable, SearchRule searchRule, InfoRule infoRule,
ContentRule contentRule, FindRule findRule) { TocRule tocRule, ContentRule contentRule, FindRule findRule) {
this.sourceUrl = sourceUrl; this.sourceUrl = sourceUrl;
this.sourceEName = sourceEName; this.sourceEName = sourceEName;
this.sourceName = sourceName; this.sourceName = sourceName;
@ -88,6 +88,7 @@ public class BookSource implements Parcelable, Cloneable {
this.sourceType = sourceType; this.sourceType = sourceType;
this.sourceHeaders = sourceHeaders; this.sourceHeaders = sourceHeaders;
this.loginUrl = loginUrl; this.loginUrl = loginUrl;
this.loginCheckJs = loginCheckJs;
this.sourceComment = sourceComment; this.sourceComment = sourceComment;
this.concurrentRate = concurrentRate; this.concurrentRate = concurrentRate;
this.lastUpdateTime = lastUpdateTime; this.lastUpdateTime = lastUpdateTime;

@ -39,12 +39,13 @@ public class ChapterService extends BaseService {
chapter.setBookId(cursor.getString(1)); chapter.setBookId(cursor.getString(1));
chapter.setNumber(cursor.getInt(2)); chapter.setNumber(cursor.getInt(2));
chapter.setTitle(cursor.getString(3)); chapter.setTitle(cursor.getString(3));
chapter.setIsVip(cursor.getInt(4) != 0); chapter.setUrl(cursor.getString(4));
chapter.setIsPay(cursor.getInt(5) != 0); chapter.setIsVip(cursor.getInt(5) != 0);
chapter.setUpdateTime(cursor.getString(6)); chapter.setIsPay(cursor.getInt(6) != 0);
chapter.setContent(cursor.getString(7)); chapter.setUpdateTime(cursor.getString(7));
chapter.setStart(cursor.getInt(8)); chapter.setContent(cursor.getString(8));
chapter.setEnd(cursor.getInt(9)); chapter.setStart(cursor.getInt(9));
chapter.setEnd(cursor.getInt(10));
chapters.add(chapter); chapters.add(chapter);
} }
} catch (Exception e) { } catch (Exception e) {

@ -6,7 +6,7 @@ import androidx.annotation.Keep
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.jsoup.nodes.Entities import org.jsoup.nodes.Entities
import org.mozilla.javascript.NativeObject import org.mozilla.javascript.NativeObject
import xyz.fycz.myreader.common.APPCONST.JS_PATTERN import xyz.fycz.myreader.common.APPCONST.JS_PATTERN_3
import xyz.fycz.myreader.common.APPCONST.SCRIPT_ENGINE import xyz.fycz.myreader.common.APPCONST.SCRIPT_ENGINE
import xyz.fycz.myreader.greendao.entity.Book import xyz.fycz.myreader.greendao.entity.Book
import xyz.fycz.myreader.greendao.entity.Chapter import xyz.fycz.myreader.greendao.entity.Chapter
@ -394,7 +394,7 @@ class AnalyzeRule(
mMode = Mode.Regex mMode = Mode.Regex
} }
var tmp: String var tmp: String
val jsMatcher = JS_PATTERN.matcher(ruleStr) val jsMatcher = JS_PATTERN_3.matcher(ruleStr)
while (jsMatcher.find()) { while (jsMatcher.find()) {
if (jsMatcher.start() > start) { if (jsMatcher.start() > start) {
tmp = ruleStr.substring(start, jsMatcher.start()).trim { it <= ' ' } tmp = ruleStr.substring(start, jsMatcher.start()).trim { it <= ' ' }

@ -98,7 +98,7 @@ class AnalyzeUrl(
private fun analyzeJs() { private fun analyzeJs() {
var start = 0 var start = 0
var tmp: String var tmp: String
val jsMatcher = JS_PATTERN.matcher(ruleUrl) val jsMatcher = JS_PATTERN_3.matcher(ruleUrl)
while (jsMatcher.find()) { while (jsMatcher.find()) {
if (jsMatcher.start() > start) { if (jsMatcher.start() > start) {
tmp = tmp =

@ -116,6 +116,7 @@ object BookChapterList {
/*if (!book.getReverseToc()) { /*if (!book.getReverseToc()) {
list.reverse() list.reverse()
}*/ }*/
list.reverse()
Log.d(book.source, "◇目录总数:${list.size}") Log.d(book.source, "◇目录总数:${list.size}")
list.forEachIndexed { index, bookChapter -> list.forEachIndexed { index, bookChapter ->
bookChapter.number = index bookChapter.number = index

@ -45,7 +45,12 @@ object BookContent {
val mNextChapterUrl = if (!nextChapterUrl.isNullOrEmpty()) { val mNextChapterUrl = if (!nextChapterUrl.isNullOrEmpty()) {
nextChapterUrl nextChapterUrl
} else { } else {
ChapterService.getInstance().findBookAllChapterByBookId(book.id)[bookChapter.number + 1].url val chapters = ChapterService.getInstance().findBookAllChapterByBookId(book.id)
if (chapters.size > bookChapter.number + 1) {
chapters[bookChapter.number + 1].url
} else {
null
}
} }
val content = StringBuilder() val content = StringBuilder()
val nextUrlList = arrayListOf(baseUrl) val nextUrlList = arrayListOf(baseUrl)

@ -62,7 +62,8 @@ object BookInfo {
scope.ensureActive() scope.ensureActive()
Log.d(bookSource.sourceUrl, "┌获取书名") Log.d(bookSource.sourceUrl, "┌获取书名")
BookList.formatBookName(analyzeRule.getString(infoRule.name)).let { BookList.formatBookName(analyzeRule.getString(infoRule.name)).let {
if (it.isNotEmpty() && (mCanReName || book.name.isEmpty())) { //if (it.isNotEmpty() && (mCanReName || book.name.isEmpty())) {
if (it.isNotEmpty()) {
book.name = it book.name = it
} }
Log.d(bookSource.sourceUrl, "${it}") Log.d(bookSource.sourceUrl, "${it}")
@ -70,7 +71,8 @@ object BookInfo {
scope.ensureActive() scope.ensureActive()
Log.d(bookSource.sourceUrl, "┌获取作者") Log.d(bookSource.sourceUrl, "┌获取作者")
BookList.formatBookAuthor(analyzeRule.getString(infoRule.author)).let { BookList.formatBookAuthor(analyzeRule.getString(infoRule.author)).let {
if (it.isNotEmpty() && (mCanReName || book.author.isEmpty())) { //if (it.isNotEmpty() && (mCanReName || book.author.isEmpty())) {
if (it.isNotEmpty()) {
book.author = it book.author = it
} }
Log.d(bookSource.sourceUrl, "${it}") Log.d(bookSource.sourceUrl, "${it}")

Loading…
Cancel
Save