From 61423861f6780d666da883a2781edc00e4f1d743 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Tue, 16 Feb 2021 21:37:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81DIY=E4=B9=A6=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/caches/build_file_checksums.ser | Bin 537 -> 537 bytes app/build.gradle | 2 +- app/src/main/assets/ReferenceSources.json | 237 ++++++++++++++++++ .../model/source/BookSourceManager.java | 14 +- .../myreader/ui/dialog/ReplaceDialog.java | 5 +- .../ui/fragment/DIYSourceFragment.java | 7 + .../fycz/myreader/util/utils/FileUtils.java | 23 +- app/version_code.properties | 4 +- 8 files changed, 281 insertions(+), 11 deletions(-) create mode 100644 app/src/main/assets/ReferenceSources.json diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 4c1c04b7cec75685a4ce1e4b3c1e1a85951b7637..c2504db526fec0592004aa54d6601f19830f4ef7 100644 GIT binary patch delta 35 tcmV+;0NnqX1epYom;|czpW>06cMz=u8>8jSi|M?%&>2##@r(

因某些原因.*回家的路!,);@r(

喜欢.*最快。,)" + }, + "enable": true, + "infoRule": { + "updateTime": "" + }, + "orderNum": 1, + "searchRule": { + "author": "作者:", + "desc": "

", + "imgUrl": "\"", + "lastChapter": "最新章节:", + "list": "
", + "name": "

", + "relatedWithInfo": false, + "searchUrl": "/search.html,searchtype=all&searchkey={key}", + "status": "状态:", + "tocUrl": "
\">", + "type": "分类:", + "updateTime": "更新时间:", + "wordCount": "字数:" + }, + "sourceCharset": "utf-8", + "sourceComment": "", + "sourceGroup": "Matcher; 参考书源", + "sourceName": "笔下文学", + "sourceType": "Matcher", + "sourceUrl": "https://www.bxwxorg.com", + "tocRule": { + "chapterList": "
", + "chapterName": "
\"></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 + } +] \ No newline at end of file diff --git a/app/src/main/java/xyz/fycz/myreader/model/source/BookSourceManager.java b/app/src/main/java/xyz/fycz/myreader/model/source/BookSourceManager.java index 3f045d9..e596bfb 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/source/BookSourceManager.java +++ b/app/src/main/java/xyz/fycz/myreader/model/source/BookSourceManager.java @@ -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")); } } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/dialog/ReplaceDialog.java b/app/src/main/java/xyz/fycz/myreader/ui/dialog/ReplaceDialog.java index c825353..e5cf28c 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/dialog/ReplaceDialog.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/dialog/ReplaceDialog.java @@ -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()]; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java index 9230c83..bb39552 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/DIYSourceFragment.java @@ -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 -> { diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/FileUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/FileUtils.java index 0da3466..74d9288 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/FileUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/FileUtils.java @@ -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 ""; + } + /** * 向手机写图片 diff --git a/app/version_code.properties b/app/version_code.properties index 6015e92..02d0b4d 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -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