diff --git a/app/src/main/java/com/github/catvod/spider/Market.java b/app/src/main/java/com/github/catvod/spider/Market.java index ce439fb0..6e29e2f6 100644 --- a/app/src/main/java/com/github/catvod/spider/Market.java +++ b/app/src/main/java/com/github/catvod/spider/Market.java @@ -61,20 +61,24 @@ public class Market extends Spider { Utils.notify("正在下載..."); Response response = OkHttp.newCall(url); File file = FileUtil.getCacheFile(Uri.parse(url).getLastPathSegment()); - download(file, response.body().byteStream()); + download(file, response.body().byteStream(), Double.parseDouble(response.header("Content-Length", "1"))); FileUtil.openFile(FileUtil.chmod(file)); } catch (Exception e) { Utils.notify(e.getMessage()); } } - private void download(File file, InputStream is) throws Exception { + private void download(File file, InputStream is, double length) throws Exception { FileOutputStream os = new FileOutputStream(file); try (BufferedInputStream input = new BufferedInputStream(is)) { byte[] buffer = new byte[4096]; int readBytes; + long totalBytes = 0; while ((readBytes = input.read(buffer)) != -1) { + totalBytes += readBytes; os.write(buffer, 0, readBytes); + int progress = (int) (totalBytes / length * 100.0); + if (progress % 10 < 5) Utils.notify("正在下載..." + progress + "%"); } } } diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index ab8d8c31..18f864ee 100644 Binary files a/jar/custom_spider.jar and b/jar/custom_spider.jar differ diff --git a/jar/custom_spider.jar.md5 b/jar/custom_spider.jar.md5 index e9c94d93..5461222c 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -f78dde289126840ebdd4abaf0cb7841d +e387f38428b7c337475b2827c56949f5 diff --git a/json/adult.json b/json/adult.json index 5ff2596d..cc66f6d4 100644 --- a/json/adult.json +++ b/json/adult.json @@ -1,5 +1,5 @@ { - "spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;f78dde289126840ebdd4abaf0cb7841d", + "spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;e387f38428b7c337475b2827c56949f5", "wallpaper": "https://gao.chuqiuyu.tk", "sites": [ { diff --git a/json/config.json b/json/config.json index 54115214..0c1a0e78 100644 --- a/json/config.json +++ b/json/config.json @@ -1,5 +1,5 @@ { - "spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;f78dde289126840ebdd4abaf0cb7841d", + "spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;e387f38428b7c337475b2827c56949f5", "wallpaper": "http://饭太硬.top/深色壁纸/api.php", "sites": [ {