支持DIY书源

pull/5/head
fengyuecanzhu 4 years ago
parent 9eb59883e8
commit 61423861f6
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. 2
      app/build.gradle
  3. 237
      app/src/main/assets/ReferenceSources.json
  4. 14
      app/src/main/java/xyz/fycz/myreader/model/source/BookSourceManager.java
  5. 5
      app/src/main/java/xyz/fycz/myreader/ui/dialog/ReplaceDialog.java
  6. 7
      app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java
  7. 23
      app/src/main/java/xyz/fycz/myreader/util/utils/FileUtils.java
  8. 4
      app/version_code.properties

@ -44,7 +44,7 @@ def getVersionName(){
def hun = (version / 100).toInteger()
def ten = (version / 10).toInteger() % 10
def one = version % 10
return hun + "." + ten + "." + one
return hun + "." + ten + "." + one + "-beta"
}
def versionN = getVersionName()

@ -0,0 +1,237 @@
[
{
"contentRule": {
"content": "<div id=\"content\"><html></div>##@r(<p>因某些原因.*回家的路!,);@r(<p>喜欢.*最快。,)"
},
"enable": true,
"infoRule": {
"updateTime": ""
},
"orderNum": 1,
"searchRule": {
"author": "作者:<span><text></span>",
"desc": "<dd class=\"book_des\"><text></dd>",
"imgUrl": "<img src=\"<text>\"",
"lastChapter": "最新章节:<a href=\"(*)\"><text></a>",
"list": "<div id=\"sitembox\"><text><div class=\"update_title\">",
"name": "<h3><a href=\"(*)\"><text></a>",
"relatedWithInfo": false,
"searchUrl": "/search.html,searchtype=all&searchkey={key}",
"status": "状态:<span><text></span>",
"tocUrl": "<dt><a href=\"<text>\">",
"type": "分类:<span><text></span>",
"updateTime": "更新时间:<span><text></span>",
"wordCount": "字数:<span><text></span>"
},
"sourceCharset": "utf-8",
"sourceComment": "",
"sourceGroup": "Matcher; 参考书源",
"sourceName": "笔下文学",
"sourceType": "Matcher",
"sourceUrl": "https://www.bxwxorg.com",
"tocRule": {
"chapterList": "<div id=\"list\"><text></div>",
"chapterName": "<dd><a href=\"<link>\"><title></a></dd>##!12"
},
"weight": 0
},
{
"contentRule": {
"content": "<dd id=\"contents\"><html></dd>##@r(,最快(*)最新章节!,)"
},
"enable": true,
"infoRule": {
"author": "小说作者:<a href=\"(*)\"><text></a>",
"desc": "<div class=\"intro_info\"><html></div>##@r(简介:,)",
"imgUrl": "<img src=\"<text>\"",
"lastChapter": "最新:<a href=\"(*)\"><text></a>",
"name": "<h3 id=\"_55_h1\"><text> 520小说吧</h3>",
"tocUrl": "<p><a href=\"<text>\"><h2>##@r(info-,read/);@a(<text>+index.html)",
"type": "小说分类:<a href=\"(*)\"><text></a>"
},
"orderNum": 2,
"searchRule": {
"author": "<a href=\"/author/(*)\"><text></a>",
"charset": "",
"infoUrl": "</a><a href=\"<text>\" class=\"blue\">",
"list": "<div class=\"cover\"><text></div>",
"name": "<a href=\"(*)\" class=\"blue\"><text></a>",
"relatedWithInfo": true,
"searchUrl": "/modules/article/waps.php,searchtype=articlename&searchkey={key}&submit=",
"tocUrl": "</a><a href=\"<text>\" class=\"blue\">##@r(info-,read/);@a(<text>+index.html)",
"type": "<a href=\"/sort-(*)/\"><text></a>##@r((\\[|\\]),)"
},
"sourceCharset": "gbk",
"sourceGroup": "💗 女频; Matcher; 参考书源",
"sourceName": "💗 520小说",
"sourceType": "Matcher",
"sourceUrl": "http://www.520xsb.com",
"tocRule": {
"chapterBaseUrl": "<h1><a href=\"<text>\">##@r(index.html,)",
"chapterList": "<table cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#E4E4E4\" id=\"at\"><text></ul></table>",
"chapterName": "<td class=\"L\"><a href=\"<link>\"><title></a></td>"
},
"weight": 0
},
{
"contentRule": {
"content": "<div id=\"content\"><html></div>"
},
"enable": true,
"infoRule": {
"author": "<meta name=\"og:novel:author\" content=\"<text>\" />",
"desc": "<div id=\"intro\"><html></div>",
"imgUrl": "<meta property=\"og:image\" content=\"<text>\" />",
"lastChapter": "<meta name=\"og:novel:latest_chapter_name\" content=\"<text>\" />",
"name": "<meta property=\"og:title\" content=\"<text>\" />",
"status": "<meta name=\"og:novel:status\" content=\"<text>\" />",
"tocUrl": "<meta name=\"og:novel:read_url\" content=\"<text>\" />",
"type": "<meta name=\"og:novel:category\" content=\"<text>\" />",
"updateTime": "<meta name=\"og:novel:update_time\" content=\"<text>\" />"
},
"orderNum": 3,
"searchRule": {
"author": "<td class=\"odd\"><text></td>##@nc(<a)",
"charset": "",
"lastChapter": "<a href=\"(*)\" target=\"_blank\"><text></a>",
"list": "<table class=\"grid\" width=\"100%\" align=\"center\"><text></table>",
"name": "<td class=\"odd\"><a href=\"(*)\"><text></a></td>",
"relatedWithInfo": true,
"searchUrl": "/modules/article/search.php?searchkey={key}",
"status": "<td class=\"even\" align=\"center\"><text></td>",
"tocUrl": "<td class=\"odd\"><a href=\"<text>\">",
"updateTime": "<td class=\"odd\" align=\"center\"><text></td>",
"wordCount": "<td class=\"even\"><text></td>##@nc(<a)"
},
"sourceCharset": "gbk",
"sourceComment": "",
"sourceGroup": "Matcher; 参考书源",
"sourceName": "顶点小说",
"sourceType": "Matcher",
"sourceUrl": "https://www.23wx.cc",
"tocRule": {
"chapterBaseUrl": "<meta name=\"og:novel:read_url\" content=\"<text>\" />",
"chapterList": "<div id=\"list\"><text></div>",
"chapterName": "<dd><a href=\"<link>\"><title></a></dd>"
},
"weight": 0
},
{
"contentRule": {
"content": "//*[@class=\"content\"]/html()##@r(您可以(*)最新章节!,);@r(<p>(*)</p>,)"
},
"enable": true,
"infoRule": {
"desc": "//*[@id=\"intro\"]/text()",
"imgUrl": "//meta[@property=\"og:image\"]/@content",
"status": ""
},
"orderNum": 4,
"searchRule": {
"author": "/span[4]/text()",
"lastChapter": "/span[3]/a/text()",
"list": "//*[@id=\"main\"]/div[1]/ul/li",
"name": "/span[2]/a/text()",
"relatedWithInfo": true,
"searchUrl": "/search.html,searchkey={key}",
"status": "/span[6]/text()",
"tocUrl": "/span[2]/a/@href",
"type": "/span[1]/a/text()",
"updateTime": "/span[5]/text()"
},
"sourceGroup": "Xpath; 参考书源",
"sourceName": "搜书网",
"sourceType": "Xpath",
"sourceUrl": "https://www.soshuw.com",
"tocRule": {
"chapterList": "//*[@class=\"novel_list\"][2]//dd/a",
"chapterName": "/text()",
"chapterUrl": "/@href"
},
"weight": 0
},
{
"contentRule": {
"content": "//*[@id=\"content\"]/html()##@r(你是天才,一秒记住:红甘泉小说网:,);@r(www.hgq26.com,)"
},
"enable": true,
"infoRule": {
"author": "//*[@id=\"author\"]/a/text()",
"desc": "//*[@id=\"bookintro\"]/p/text()[1]",
"imgUrl": "//*[@id=\"bookimg\"]/img/@src",
"lastChapter": "//*[@id=\"newlist\"]/ul/li[1]/a/text()",
"name": "//*[@id=\"bookinfo\"]/div[2]/h1/text()",
"status": "//*[@id=\"count\"]/span[6]/text()",
"tocUrl": "//*[@id=\"newlist\"]/div/strong/a/@href",
"type": "//*[@id=\"count\"]/span[1]/text()",
"updateTime": "//*[@id=\"bookinfo\"]/div[2]/div[5]/span[1]/text()##@r(最后更新:,)",
"wordCount": "//*[@id=\"count\"]/span[5]/text()"
},
"orderNum": 5,
"searchRule": {
"author": "/td[3]/text()",
"infoUrl": "/td[1]/a/@href",
"lastChapter": "/td[2]/a/text()",
"list": "//*[@id=\"nr\"]",
"name": "/td[1]/a/text()",
"relatedWithInfo": true,
"searchUrl": "/modules/article/search.php,searchkey={key}",
"status": "/td[6]/text()",
"tocUrl": "/td[1]/a/@href##@r(book,0);@r(.html,/)",
"type": "",
"updateTime": "/td[5]/text()",
"wordCount": "/td[4]/text()"
},
"sourceCharset": "gbk",
"sourceGroup": "Xpath; 参考书源",
"sourceName": "红甘泉",
"sourceType": "Xpath",
"sourceUrl": "https://www.hgq26.com",
"tocRule": {
"chapterBaseUrl": "",
"chapterList": "//*[@id=\"readerlist\"]/ul/li/a",
"chapterName": "/text()",
"chapterUrl": "/@href"
},
"weight": 0
},
{
"contentRule": {
"content": "//*[@id=\"content\"]/html()##@r(本章未完.*继续阅读--.*$,)",
"contentBaseUrl": "//a[@id=\"backToDirButton\"]/@href",
"contentUrlNext": "//a[@id=\"nextChapterButton\" and @title=\"下一页\"]/@href"
},
"enable": true,
"infoRule": {
"imgUrl": "//meta[@property=\"og:image\"]/@content",
"lastChapter": "//*[@id=\"info\"]/p[4]/a/text()",
"type": "//div[@class=\"con_top\"]/a[2]/text()"
},
"orderNum": 6,
"searchRule": {
"author": "/td[3]/a/text()",
"desc": "/td[2]/text()",
"list": "//*[@id=\"nr\"]",
"name": "/td[1]/a/text()",
"relatedWithInfo": true,
"searchUrl": "http://www.kandashuw.com/plus/search.php?q={key}&searchtype=articlename",
"status": "/td[6]/text()",
"tocUrl": "/td[1]/a/@href",
"type": "",
"updateTime": "/td[5]/text()",
"wordCount": "/td[4]/text()"
},
"sourceCharset": "gbk",
"sourceGroup": "Xpath; 参考书源",
"sourceName": "看大书网",
"sourceType": "Xpath",
"sourceUrl": "http://www.kandashuw.com",
"tocRule": {
"chapterBaseUrl": "//div[@class=\"con_top\"]/a[3]/@href",
"chapterList": "//*[@id=\"list\"]/dl/dd/a",
"chapterName": "/text()",
"chapterUrl": "/@href"
},
"weight": 0
}
]

@ -6,6 +6,7 @@ import android.util.Log;
import androidx.annotation.Nullable;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -22,7 +23,9 @@ import xyz.fycz.myreader.greendao.entity.rule.BookSource;
import xyz.fycz.myreader.greendao.gen.BookSourceDao;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.GsonUtils;
import xyz.fycz.myreader.util.utils.MeUtils;
import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.OkHttpUtils;
import xyz.fycz.myreader.util.utils.RxUtils;
@ -129,7 +132,7 @@ public class BookSourceManager {
private static BookSource getDefaultSource() {
BookSource bookSource = new BookSource();
bookSource.setSourceUrl("xyz.fycz.myreader.webapi.crawler.read.FYReadCrawler");
bookSource.setSourceName("风月小说");
bookSource.setSourceName("未知书源");
bookSource.setSourceEName("fynovel");
bookSource.setSourceGroup("内置书源");
return bookSource;
@ -140,7 +143,7 @@ public class BookSourceManager {
*
* @return
*/
private static BookSource getLocalSource() {
public static BookSource getLocalSource() {
BookSource bookSource = new BookSource();
bookSource.setSourceEName("local");
bookSource.setSourceName("本地书籍");
@ -367,9 +370,10 @@ public class BookSourceManager {
source1.setSourceGroup("内置书源");
source1.setEnable(isEmpty || searchSource.contains(source.toString()));
source1.setSourceUrl(ReadCrawlerUtil.getReadCrawlerClz(source.toString()));
BookSourceManager.addBookSource(source1);
source1.setOrderNum(0);
GreenDaoManager.getDaoSession().getBookSourceDao().insertOrReplace(source1);
}
BookSourceManager.addBookSource(MatcherAnalyzer.getTestSource());
BookSourceManager.addBookSource(MatcherAnalyzer.getTestSource2());
BookSourceManager.importBookSourceFromJson(FileUtils.readAssertFile(App.getmContext(),
"ReferenceSources.json"));
}
}

@ -15,6 +15,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@ -117,7 +118,9 @@ public class ReplaceDialog extends DialogFragment {
* 选择书源
*/
private void selectSource(){
List<BookSource> mSources = BookSourceManager.getAllBookSourceByOrderNum();
List<BookSource> mSources = new ArrayList<>();
mSources.add(BookSourceManager.getLocalSource());
mSources.addAll(BookSourceManager.getAllBookSourceByOrderNum());
CharSequence[] mSourcesName = new CharSequence[mSources.size()];
HashMap<CharSequence, Boolean> mSelectSources = new LinkedHashMap<>();
boolean[] isSelects = new boolean[mSources.size()];

@ -2,6 +2,7 @@ package xyz.fycz.myreader.ui.fragment;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
@ -168,6 +169,12 @@ public class DIYSourceFragment extends BaseFragment {
}).show();
});
binding.tvSourceTip.setOnClickListener(v -> {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://blog.csdn.net/fengyuecanzhu/article/details/113826962"));
startActivity(intent);
});
binding.ivGroup.setOnClickListener(this::showSourceGroupMenu);
binding.ivMenu.setOnClickListener(v -> {

@ -25,6 +25,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.text.DecimalFormat;
import java.util.ArrayList;
@ -35,6 +36,7 @@ import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.ui.dialog.DialogCreator;
import xyz.fycz.myreader.util.IOUtils;
import xyz.fycz.myreader.util.StringHelper;
@ -355,8 +357,6 @@ public class FileUtils {
outStream.write(buffer, 0, length);
}
outStream.flush();
outStream.close();
inStream.close();
return outStream.toString();
} catch (IOException e) {
Log.i("FileTest", e.getMessage());
@ -366,6 +366,25 @@ public class FileUtils {
return null;
}
public static String readAssertFile(Context context, String assetName){
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(context.getAssets().open(assetName)));
StringBuilder assetText = new StringBuilder();
String line = null;
while ((line = br.readLine()) != null) {
assetText.append(line);
assetText.append("\n");
}
return assetText.toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.close(br);
}
return "";
}
/**
* 向手机写图片

@ -1,2 +1,2 @@
#Tue Feb 16 20:54:58 CST 2021
VERSION_CODE=183
#Tue Feb 16 21:09:33 CST 2021
VERSION_CODE=190

Loading…
Cancel
Save