From 6d770fa296e196ae93fad582f8e061fec04f102f Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Sun, 9 May 2021 09:38:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=E3=80=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BD=93=E9=AA=8C?= 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 .../myreader/ExampleInstrumentedTest.java | 78 +++++++++++++++--- .../fycz/myreader/util/utils/OkHttpUtils.java | 51 +++++++++++- .../crawler/read/JiuTaoReadCrawler.java | 2 +- app/src/test/java/File1.java | 78 ++++++++++++++++++ app/src/test/java/Test.java | 22 +++++ app/version_code.properties | 2 +- 7 files changed, 216 insertions(+), 17 deletions(-) create mode 100644 app/src/test/java/File1.java diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 55032dede84b54344c2392b8f8af2e008c971b71..8711bc69ed9a1e8b2c38d98db5f7aee6adcc949e 100644 GIT binary patch delta 35 tcmV+;0NnqX1epYom;_G0Bf^oKcMvYsKz_N9d(eT|CoWeMQ+1Og0rm?c4)Fj0 delta 35 tcmV+;0NnqX1epYom;?fOM0k;$cMy<)abv6R_P+zx$^9Kug-Mem0rm|25D)+W diff --git a/app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java b/app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java index a4db67c..ad2bc3a 100644 --- a/app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/xyz/fycz/myreader/ExampleInstrumentedTest.java @@ -1,18 +1,30 @@ package xyz.fycz.myreader; import android.content.Context; +import android.util.Log; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; +import com.liulishuo.filedownloader.BaseDownloadTask; +import com.liulishuo.filedownloader.FileDownloadLargeFileListener; +import com.liulishuo.filedownloader.FileDownloader; + import org.junit.Test; import org.junit.runner.RunWith; +import java.io.File; import java.io.IOException; +import java.util.List; +import xyz.fycz.myreader.common.APPCONST; +import xyz.fycz.myreader.common.URLCONST; import xyz.fycz.myreader.model.source.MatcherAnalyzer; +import xyz.fycz.myreader.util.utils.GsonUtils; import xyz.fycz.myreader.util.utils.OkHttpUtils; +import xyz.fycz.myreader.webapi.CommonApi; +import xyz.fycz.myreader.webapi.callback.ResultCallback; import static org.junit.Assert.assertEquals; @@ -32,18 +44,62 @@ public class ExampleInstrumentedTest { @Test public void test() { - try { - String str = OkHttpUtils.getHtml("https://www.xiaobiquge.com/29/29787/101469886.html", "gbk"); - MatcherAnalyzer analyzer = new MatcherAnalyzer(); - String rule = "
##@e(,小笔趣阁){@a( + 风月读书)}"; - /*List list = analyzer.matcherInnerString(rule, str); - for (String s : list) { - System.out.println(s); - }*/ - System.out.println(analyzer.getInnerText(rule, str)); - } catch (IOException e) { - e.printStackTrace(); + String json = "[{\"icon\":\"apk\",\"t\":0,\"id\":\"i6b1horcnde\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.4-\\u53bb\\u66f4\\u65b0\\u3001\\u5e7f\\u544a\\u7248.apk\",\"size\":\"10.2 M\",\"time\":\"5 \\u5929\\u524d\",\"duan\":\"iorcnd\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i0Jokohm6gf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.4.apk\",\"size\":\"14.9 M\",\"time\":\"12 \\u5929\\u524d\",\"duan\":\"iohm6g\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ivyijmwfdqd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.3.apk\",\"size\":\"10.0 M\",\"time\":\"2021-03-13\",\"duan\":\"imwfdq\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iMpIkmcv9dc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.2.apk\",\"size\":\"10.0 M\",\"time\":\"2021-03-02\",\"duan\":\"imcv9d\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ijJsnmcfwja\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.1.apk\",\"size\":\"10.0 M\",\"time\":\"2021-03-01\",\"duan\":\"imcfwj\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ixI19lqnscf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.0-beta.apk\",\"size\":\"10.0 M\",\"time\":\"2021-02-16\",\"duan\":\"ilqnsc\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iEy9kldwrpi\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.8.2.apk\",\"size\":\"9.6 M\",\"time\":\"2021-02-06\",\"duan\":\"ildwrp\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i5vu3l6pcuj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.8.1.apk\",\"size\":\"9.6 M\",\"time\":\"2021-02-01\",\"duan\":\"il6pcu\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i4pMekkx9zc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.8.0.apk\",\"size\":\"9.7 M\",\"time\":\"2021-01-19\",\"duan\":\"ikkx9z\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iu2FYkkvjyj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.7.9.apk\",\"size\":\"9.7 M\",\"time\":\"2021-01-19\",\"duan\":\"ikkvjy\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"icrU3kkqrud\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.7.9.apk\",\"size\":\"9.7 M\",\"time\":\"2021-01-19\",\"duan\":\"ikkqru\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ieSvwk7vucf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.7.8.apk\",\"size\":\"9.6 M\",\"time\":\"2021-01-09\",\"duan\":\"ik7vuc\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iGTvFk7ugmf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.7.8.apk\",\"size\":\"9.6 M\",\"time\":\"2021-01-09\",\"duan\":\"ik7ugm\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iwIrojatw9e\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.121218.apk\",\"size\":\"9.5 M\",\"time\":\"2020-12-12\",\"duan\":\"ijatw9\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i9W2Gj3mera\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.120612.apk\",\"size\":\"9.8 M\",\"time\":\"2020-12-06\",\"duan\":\"ij3mer\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iNFGZj3m4xg\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.120612.apk\",\"size\":\"9.8 M\",\"time\":\"2020-12-06\",\"duan\":\"ij3m4x\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iqvwqj3kr5e\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.120612.apk\",\"size\":\"9.8 M\",\"time\":\"2020-12-06\",\"duan\":\"ij3kr5\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ib8ZJivckmd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112822.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-28\",\"duan\":\"iivckm\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iPzSWipk1wb\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112410.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-24\",\"duan\":\"iipk1w\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"itfplio73ob\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112309.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-23\",\"duan\":\"iio73o\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ikhkGinehwj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112216.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-22\",\"duan\":\"iinehw\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iB8Xsin8tgj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112213.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-22\",\"duan\":\"iin8tg\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iJ9qwin5qeb\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112212.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-22\",\"duan\":\"iin5qe\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iHgbpin5b3a\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112212.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-22\",\"duan\":\"iin5b3\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iowiDiecicj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111420.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-14\",\"duan\":\"iiecic\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iGu0Mibqpni\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111217.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-12\",\"duan\":\"iibqpn\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i3wzXib1eaj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111209.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-12\",\"duan\":\"iib1ea\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iVjH6ib15hc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111208.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-12\",\"duan\":\"iib15h\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iEAaUiamvub\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111121.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-11\",\"duan\":\"iiamvu\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"inaPWi6fy6j\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.110811.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-08\",\"duan\":\"ii6fy6\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iGMHPi0c7pc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.110311.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-03\",\"duan\":\"ii0c7p\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iDjPghnbxod\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.102217.apk\",\"size\":\"8.2 M\",\"time\":\"2020-10-22\",\"duan\":\"ihnbxo\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iTmLPh4t2wj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.100316.apk\",\"size\":\"7.9 M\",\"time\":\"2020-10-03\",\"duan\":\"ih4t2w\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"icVyfh4lnsd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.100313.apk\",\"size\":\"7.9 M\",\"time\":\"2020-10-03\",\"duan\":\"ih4lns\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iBofFh42pxg\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.100220.apk\",\"size\":\"7.2 M\",\"time\":\"2020-10-02\",\"duan\":\"ih42px\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iG2tPh3akej\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.100123.apk\",\"size\":\"7.2 M\",\"time\":\"2020-10-01\",\"duan\":\"ih3ake\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iMIWSgz5eaf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.092718.apk\",\"size\":\"7.2 M\",\"time\":\"2020-09-27\",\"duan\":\"igz5ea\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"itWVmgxz3ob\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.092617.apk\",\"size\":\"7.2 M\",\"time\":\"2020-09-26\",\"duan\":\"igxz3o\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iYYzdgrtkda\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.091922.apk\",\"size\":\"7.2 M\",\"time\":\"2020-09-19\",\"duan\":\"igrtkd\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ivi6Sgrrj2b\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.091921.apk\",\"size\":\"7.2 M\",\"time\":\"2020-09-19\",\"duan\":\"igrrj2\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iviXVgfksuj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.090722.apk\",\"size\":\"7.0 M\",\"time\":\"2020-09-07\",\"duan\":\"igfksu\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i1HYEg0q8je\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.082422.apk\",\"size\":\"6.9 M\",\"time\":\"2020-08-24\",\"duan\":\"ig0q8j\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i2m6vfnvvfa\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.081523.apk\",\"size\":\"6.8 M\",\"time\":\"2020-08-15\",\"duan\":\"ifnvvf\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iUQ0Zfka1bc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.081221.apk\",\"size\":\"6.8 M\",\"time\":\"2020-08-12\",\"duan\":\"ifka1b\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"igzNbfdbc2d\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.080709.apk\",\"size\":\"6.7 M\",\"time\":\"2020-08-07\",\"duan\":\"ifdbc2\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iHXgWf67zqj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.073120.apk\",\"size\":\"6.7 M\",\"time\":\"2020-07-31\",\"duan\":\"if67zq\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iXaHUf5uyyd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.073114.apk\",\"size\":\"6.7 M\",\"time\":\"2020-07-31\",\"duan\":\"if5uyy\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"il7HPezefjc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.072519.apk\",\"size\":\"6.7 M\",\"time\":\"2020-07-25\",\"duan\":\"iezefj\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iUmNAevkyhg\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.072221.apk\",\"size\":\"6.2 M\",\"time\":\"2020-07-22\",\"duan\":\"ievkyh\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iviG9evcn5a\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.072217.apk\",\"size\":\"6.2 M\",\"time\":\"2020-07-22\",\"duan\":\"ievcn5\",\"p_ico\":0}]"; + List files = GsonUtils.parseJArray(json, File1.class); + for (File1 file : files){ + CommonApi.getUrl(URLCONST.LAN_ZOUS_URL + "/" + file.getId(), new ResultCallback() { + @Override + public void onFinish(Object o, int code) { + String downloadUrl = (String) o; + startDownloading(downloadUrl, file.getName_all()); + } + + @Override + public void onError(Exception e) { + + } + }); } } + private void startDownloading(String decodeUrl, String name) { + String path = APPCONST.UPDATE_APK_FILE_DIR + name; + BaseDownloadTask baseDownloadTask = FileDownloader.getImpl() + .create(decodeUrl) + .setPath(path, new File(path).isDirectory()) + .setCallbackProgressMinInterval(100) + .setListener(new FileDownloadLargeFileListener() { + @Override + protected void pending(BaseDownloadTask task, long soFarBytes, long totalBytes) { + Log.e("downloadApk" + name, "pending-------"); + } + + @Override + protected void progress(BaseDownloadTask task, long soFarBytes, long totalBytes) { + float percent = 1f * soFarBytes / totalBytes * 100; + Log.e("downloadApk" + name, "progress-------" + percent); + } + @Override + protected void paused(BaseDownloadTask task, long soFarBytes, long totalBytes) { + Log.e("downloadApk" + name, "paused-------"); + } + + @Override + protected void completed(BaseDownloadTask task) { + Log.e("downloadApk" + name, "completed-------"); + } + + @Override + protected void error(BaseDownloadTask task, Throwable e) { + Log.e("downloadApk" + name, "error-------" + e.toString()); + } + + @Override + protected void warn(BaseDownloadTask task) { + Log.e("downloadApk" + name, "warn-------"); + } + }); + baseDownloadTask.setAutoRetryTimes(3); + baseDownloadTask.start(); + } } \ No newline at end of file diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java index 7f98a8e..a4a0fd7 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java @@ -1,7 +1,15 @@ package xyz.fycz.myreader.util.utils; +import android.content.Context; import android.util.Log; + +import org.json.JSONException; +import org.json.JSONObject; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; + import okhttp3.*; +import xyz.fycz.myreader.application.App; import xyz.fycz.myreader.application.TrustAllCerts; import xyz.fycz.myreader.util.HttpUtil; import xyz.fycz.myreader.util.StringHelper; @@ -9,8 +17,10 @@ import xyz.fycz.myreader.util.StringHelper; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; + import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.security.SecureRandom; public class OkHttpUtils { @@ -23,6 +33,7 @@ public class OkHttpUtils { public static String getHtml(String url) throws IOException { return getHtml(url, "utf-8"); } + public static String getHtml(String url, String encodeType) throws IOException { return getHtml(url, null, encodeType); } @@ -39,13 +50,13 @@ public class OkHttpUtils { //.addHeader("Charsert", "utf-8") .addHeader("Cache-Control", "no-cache") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"); - if (cookie != null){ + if (cookie != null) { builder.addHeader("Cookie", cookie); } if (requestBody != null) { builder.post(requestBody); Log.d("HttpPost URl", url); - }else { + } else { Log.d("HttpGet URl", url); } Request request = builder @@ -54,7 +65,7 @@ public class OkHttpUtils { Response response = okHttpClient .newCall(request) .execute(); - ResponseBody body=response.body(); + ResponseBody body = response.body(); if (body == null) { return ""; } else { @@ -85,9 +96,41 @@ public class OkHttpUtils { Response response = okHttpClient .newCall(request) .execute(); - if (response.body() == null){ + if (response.body() == null) { return null; } return response.body().byteStream(); } + + public static String getUpdateInfo() throws IOException, JSONException { + String key = "ryvwiq"; + if (App.isApkInDebug(App.getmContext())) { + key = "sgak2h"; + } + String url = "https://www.yuque.com/api/docs/" + key + "?book_id=19981967&include_contributors=true&include_hits=true&include_like=true&include_pager=true&include_suggests=true"; + String referer = "https://www.yuque.com/books/share/bf61f5fb-6eff-4740-ab38-749300e79306/" + key; + Request.Builder builder = new Request.Builder() + .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4168.3 Safari/537.36") + .addHeader("Content-Type", "application/json") + .addHeader("Referer", referer); + Request request = builder + .url(url) + .build(); + Response response = okHttpClient + .newCall(request) + .execute(); + ResponseBody body = response.body(); + if (body == null) { + return ""; + } else { + String bodyStr = new String(body.bytes(), StandardCharsets.UTF_8); + JSONObject jsonObj = new JSONObject(bodyStr); + jsonObj = jsonObj.getJSONObject("data"); + String content = jsonObj.getString("content"); + Document doc = Jsoup.parse(content); + content = doc.text(); + Log.d("Http: UpdateInfo", content); + return content; + } + } } diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/JiuTaoReadCrawler.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/JiuTaoReadCrawler.java index 6f29e4d..25a1050 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/JiuTaoReadCrawler.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/JiuTaoReadCrawler.java @@ -18,7 +18,7 @@ import java.util.ArrayList; public class JiuTaoReadCrawler implements ReadCrawler { - public static final String NAME_SPACE = "https://www.9txs.com"; + public static final String NAME_SPACE = "https://www.9txs.org"; public static final String NOVEL_SEARCH = "https://so.9txs.org/www/,searchkey={key}"; public static final String CHARSET = "UTF-8"; public static final String SEARCH_CHARSET = "UTF-8"; diff --git a/app/src/test/java/File1.java b/app/src/test/java/File1.java new file mode 100644 index 0000000..bc11f65 --- /dev/null +++ b/app/src/test/java/File1.java @@ -0,0 +1,78 @@ +/** + * @author fengyue + * @date 2021/5/8 18:49 + */ +public class File1 { + private String icon; + private int t; + private String id; + private String name_all; + private String size; + private String time; + private String duan; + private int p_ico; + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public int getT() { + return t; + } + + public void setT(int t) { + this.t = t; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName_all() { + return name_all; + } + + public void setName_all(String name_all) { + this.name_all = name_all; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getDuan() { + return duan; + } + + public void setDuan(String duan) { + this.duan = duan; + } + + public int getP_ico() { + return p_ico; + } + + public void setP_ico(int p_ico) { + this.p_ico = p_ico; + } +} diff --git a/app/src/test/java/Test.java b/app/src/test/java/Test.java index 8265548..533654c 100644 --- a/app/src/test/java/Test.java +++ b/app/src/test/java/Test.java @@ -1,3 +1,9 @@ +import android.util.Log; + +import com.liulishuo.filedownloader.BaseDownloadTask; +import com.liulishuo.filedownloader.FileDownloadLargeFileListener; +import com.liulishuo.filedownloader.FileDownloader; + import org.seimicrawler.xpath.JXDocument; import java.io.File; @@ -9,8 +15,12 @@ import java.util.List; import xyz.fycz.myreader.ai.MatrixUtil; import xyz.fycz.myreader.model.source.BaseAnalyzer; import xyz.fycz.myreader.model.source.MatcherAnalyzer; +import xyz.fycz.myreader.ui.dialog.UpdateDialog; import xyz.fycz.myreader.util.utils.FileUtils; +import xyz.fycz.myreader.util.utils.GsonExtensionsKt; +import xyz.fycz.myreader.util.utils.GsonUtils; import xyz.fycz.myreader.util.utils.NetworkUtils; +import xyz.fycz.myreader.webapi.CommonApi; /** * @author fengyue @@ -123,4 +133,16 @@ public class Test { System.out.println(Arrays.deepToString(m)); } + + @org.junit.Test + public void testDownload() { + String json = "[{\"icon\":\"apk\",\"t\":0,\"id\":\"i6b1horcnde\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.4-\\u53bb\\u66f4\\u65b0\\u3001\\u5e7f\\u544a\\u7248.apk\",\"size\":\"10.2 M\",\"time\":\"5 \\u5929\\u524d\",\"duan\":\"iorcnd\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i0Jokohm6gf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.4.apk\",\"size\":\"14.9 M\",\"time\":\"12 \\u5929\\u524d\",\"duan\":\"iohm6g\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ivyijmwfdqd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.3.apk\",\"size\":\"10.0 M\",\"time\":\"2021-03-13\",\"duan\":\"imwfdq\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iMpIkmcv9dc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.2.apk\",\"size\":\"10.0 M\",\"time\":\"2021-03-02\",\"duan\":\"imcv9d\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ijJsnmcfwja\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.1.apk\",\"size\":\"10.0 M\",\"time\":\"2021-03-01\",\"duan\":\"imcfwj\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ixI19lqnscf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.9.0-beta.apk\",\"size\":\"10.0 M\",\"time\":\"2021-02-16\",\"duan\":\"ilqnsc\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iEy9kldwrpi\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.8.2.apk\",\"size\":\"9.6 M\",\"time\":\"2021-02-06\",\"duan\":\"ildwrp\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i5vu3l6pcuj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.8.1.apk\",\"size\":\"9.6 M\",\"time\":\"2021-02-01\",\"duan\":\"il6pcu\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i4pMekkx9zc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.8.0.apk\",\"size\":\"9.7 M\",\"time\":\"2021-01-19\",\"duan\":\"ikkx9z\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iu2FYkkvjyj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.7.9.apk\",\"size\":\"9.7 M\",\"time\":\"2021-01-19\",\"duan\":\"ikkvjy\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"icrU3kkqrud\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.7.9.apk\",\"size\":\"9.7 M\",\"time\":\"2021-01-19\",\"duan\":\"ikkqru\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ieSvwk7vucf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.7.8.apk\",\"size\":\"9.6 M\",\"time\":\"2021-01-09\",\"duan\":\"ik7vuc\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iGTvFk7ugmf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.7.8.apk\",\"size\":\"9.6 M\",\"time\":\"2021-01-09\",\"duan\":\"ik7ugm\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iwIrojatw9e\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.121218.apk\",\"size\":\"9.5 M\",\"time\":\"2020-12-12\",\"duan\":\"ijatw9\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i9W2Gj3mera\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.120612.apk\",\"size\":\"9.8 M\",\"time\":\"2020-12-06\",\"duan\":\"ij3mer\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iNFGZj3m4xg\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.120612.apk\",\"size\":\"9.8 M\",\"time\":\"2020-12-06\",\"duan\":\"ij3m4x\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iqvwqj3kr5e\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.120612.apk\",\"size\":\"9.8 M\",\"time\":\"2020-12-06\",\"duan\":\"ij3kr5\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ib8ZJivckmd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112822.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-28\",\"duan\":\"iivckm\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iPzSWipk1wb\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112410.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-24\",\"duan\":\"iipk1w\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"itfplio73ob\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112309.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-23\",\"duan\":\"iio73o\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ikhkGinehwj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112216.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-22\",\"duan\":\"iinehw\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iB8Xsin8tgj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112213.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-22\",\"duan\":\"iin8tg\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iJ9qwin5qeb\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112212.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-22\",\"duan\":\"iin5qe\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iHgbpin5b3a\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.112212.apk\",\"size\":\"9.1 M\",\"time\":\"2020-11-22\",\"duan\":\"iin5b3\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iowiDiecicj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111420.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-14\",\"duan\":\"iiecic\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iGu0Mibqpni\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111217.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-12\",\"duan\":\"iibqpn\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i3wzXib1eaj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111209.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-12\",\"duan\":\"iib1ea\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iVjH6ib15hc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111208.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-12\",\"duan\":\"iib15h\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iEAaUiamvub\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.111121.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-11\",\"duan\":\"iiamvu\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"inaPWi6fy6j\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.110811.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-08\",\"duan\":\"ii6fy6\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iGMHPi0c7pc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.110311.apk\",\"size\":\"8.0 M\",\"time\":\"2020-11-03\",\"duan\":\"ii0c7p\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iDjPghnbxod\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.102217.apk\",\"size\":\"8.2 M\",\"time\":\"2020-10-22\",\"duan\":\"ihnbxo\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iTmLPh4t2wj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.100316.apk\",\"size\":\"7.9 M\",\"time\":\"2020-10-03\",\"duan\":\"ih4t2w\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"icVyfh4lnsd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.100313.apk\",\"size\":\"7.9 M\",\"time\":\"2020-10-03\",\"duan\":\"ih4lns\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iBofFh42pxg\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.100220.apk\",\"size\":\"7.2 M\",\"time\":\"2020-10-02\",\"duan\":\"ih42px\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iG2tPh3akej\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.100123.apk\",\"size\":\"7.2 M\",\"time\":\"2020-10-01\",\"duan\":\"ih3ake\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iMIWSgz5eaf\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.092718.apk\",\"size\":\"7.2 M\",\"time\":\"2020-09-27\",\"duan\":\"igz5ea\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"itWVmgxz3ob\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.092617.apk\",\"size\":\"7.2 M\",\"time\":\"2020-09-26\",\"duan\":\"igxz3o\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iYYzdgrtkda\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.091922.apk\",\"size\":\"7.2 M\",\"time\":\"2020-09-19\",\"duan\":\"igrtkd\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ivi6Sgrrj2b\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.091921.apk\",\"size\":\"7.2 M\",\"time\":\"2020-09-19\",\"duan\":\"igrrj2\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iviXVgfksuj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.090722.apk\",\"size\":\"7.0 M\",\"time\":\"2020-09-07\",\"duan\":\"igfksu\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i1HYEg0q8je\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.082422.apk\",\"size\":\"6.9 M\",\"time\":\"2020-08-24\",\"duan\":\"ig0q8j\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i2m6vfnvvfa\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.081523.apk\",\"size\":\"6.8 M\",\"time\":\"2020-08-15\",\"duan\":\"ifnvvf\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iUQ0Zfka1bc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.081221.apk\",\"size\":\"6.8 M\",\"time\":\"2020-08-12\",\"duan\":\"ifka1b\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"igzNbfdbc2d\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.080709.apk\",\"size\":\"6.7 M\",\"time\":\"2020-08-07\",\"duan\":\"ifdbc2\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iHXgWf67zqj\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.073120.apk\",\"size\":\"6.7 M\",\"time\":\"2020-07-31\",\"duan\":\"if67zq\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iXaHUf5uyyd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.073114.apk\",\"size\":\"6.7 M\",\"time\":\"2020-07-31\",\"duan\":\"if5uyy\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"il7HPezefjc\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.072519.apk\",\"size\":\"6.7 M\",\"time\":\"2020-07-25\",\"duan\":\"iezefj\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iUmNAevkyhg\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.072221.apk\",\"size\":\"6.2 M\",\"time\":\"2020-07-22\",\"duan\":\"ievkyh\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iviG9evcn5a\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.072217.apk\",\"size\":\"6.2 M\",\"time\":\"2020-07-22\",\"duan\":\"ievcn5\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"ivPOBerhale\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.072010.apk\",\"size\":\"6.2 M\",\"time\":\"2020-07-20\",\"duan\":\"ierhal\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"iJYy0ep96ba\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.071809.apk\",\"size\":\"6.2 M\",\"time\":\"2020-07-18\",\"duan\":\"iep96b\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i66syem8nre\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.071509.apk\",\"size\":\"6.2 M\",\"time\":\"2020-07-15\",\"duan\":\"iem8nr\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i0YwKeel0sh\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.070809.apk\",\"size\":\"6.8 M\",\"time\":\"2020-07-08\",\"duan\":\"ieel0s\",\"p_ico\":0},{\"icon\":\"apk\",\"t\":0,\"id\":\"i1IOje8vhsd\",\"name_all\":\"\\u98ce\\u6708\\u8bfb\\u4e66v1.20.070219.apk\",\"size\":\"6.8 M\",\"time\":\"2020-07-02\",\"duan\":\"ie8vhs\",\"p_ico\":0}]"; + List files = GsonUtils.parseJArray(json, File1.class); + String basePath = "D:/风月读书"; + for (File1 file : files){ + + } + } + + } diff --git a/app/version_code.properties b/app/version_code.properties index 794e21a..d515c1c 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Sun Apr 25 18:50:43 CST 2021 +#Mon May 03 14:54:05 CST 2021 VERSION_CODE=194