From 07a1f45f1e572d06e8378e0cc03a3229fba597df Mon Sep 17 00:00:00 2001
From: laoyuyu <511455842@qq.com>
Date: Fri, 14 Aug 2020 20:31:17 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dm3u8=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=94=99=E8=AF=AF=E6=97=B6=EF=BC=8C=E6=97=A0?=
=?UTF-8?q?=E6=B3=95=E5=88=A0=E9=99=A4=E5=AE=9E=E4=BD=93=E7=9A=84=E9=97=AE?=
=?UTF-8?q?=E9=A2=98=20https://github.com/AriaLyy/Aria/issues/712=20?=
=?UTF-8?q?=E4=BF=AE=E5=A4=8D0kb=E7=9A=84=E6=96=87=E4=BB=B6=E4=B8=8D?=
=?UTF-8?q?=E5=8F=AF=E4=B8=8B=E8=BD=BD=E7=9A=84=E9=97=AE=E9=A2=98=20https:?=
=?UTF-8?q?//github.com/AriaLyy/Aria/issues/711?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DEV_LOG.md | 1 +
.../com/arialyy/aria/http/download/HttpDFileInfoTask.java | 5 +++++
README.md | 3 +--
.../com/arialyy/simple/core/download/HttpDownloadModule.java | 5 +++--
.../com/arialyy/simple/core/download/SingleTaskActivity.java | 2 ++
.../com/arialyy/simple/core/download/m3u8/M3U8VodModule.java | 3 ++-
6 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/DEV_LOG.md b/DEV_LOG.md
index cc252064..f32eb872 100644
--- a/DEV_LOG.md
+++ b/DEV_LOG.md
@@ -6,6 +6,7 @@
- 修复m3u8任务地址错误时,无法删除实体的问题 https://github.com/AriaLyy/Aria/issues/712
- 修复m3u8gzip的问题,https://github.com/AriaLyy/Aria/issues/639
- 修复http表单上传,本地md5和上传的服务的的文件md5不一致的问题 https://github.com/AriaLyy/Aria/issues/730
+ - 修复0kb的文件不可下载的问题 https://github.com/AriaLyy/Aria/issues/711
- 增加m3u8密钥下载地址转换器增加ts列表的url地址 https://github.com/AriaLyy/Aria/issues/718
- 增加现在http文件下载将使用HEAD请求获取文件大小,配置文件增加
- 增加允许不使用apt直接通过实现监听器来回调下载进度更新,该功能由[chenfei0928](https://github.com/chenfei0928)提交,感谢他的pr。如果注解不生效,只需要实现`DownloadListener`接口便可
diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java
index c63e4f52..0ef1ea92 100644
--- a/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java
+++ b/HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java
@@ -232,6 +232,11 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|| code == HttpURLConnection.HTTP_CREATED // 201 跳转
|| code == 307) {
handleUrlReTurn(conn, conn.getHeaderField("Location"));
+ }else if (code == 416){ // 处理0k长度的文件的情况
+ ALog.w(TAG, "文件长度为0,不支持断点");
+ mTaskWrapper.setSupportBP(false);
+ mTaskWrapper.setNewTask(true);
+ end = true;
} else if (code >= HttpURLConnection.HTTP_BAD_REQUEST) {
failDownload(new AriaHTTPException(
String.format("任务下载失败,errorCode:%s, url: %s", code, mEntity.getUrl())), false);
diff --git a/README.md b/README.md
index 80ae9395..bb89c22d 100644
--- a/README.md
+++ b/README.md
@@ -171,8 +171,7 @@ protected void onCreate(Bundle savedInstanceState) {
有任何问题,可以在[issues](https://github.com/AriaLyy/Aria/issues)给我留言反馈。
在提交问题前,希望你已经查看过[wiki](https://aria.laoyuyu.me/aria_doc/)或搜索过[issues](https://github.com/AriaLyy/Aria/issues)。
-## 打赏
- 如果觉得框架写的不错并且帮助到了你,可以请我瓶快乐水。`^_^`
+## 请我喝瓶快乐水
diff --git a/app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java b/app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java
index 85d25c41..8a4c6724 100644
--- a/app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java
+++ b/app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java
@@ -52,9 +52,10 @@ public class HttpDownloadModule extends BaseViewModule {
//String url = "http://fdfs.speedata.cn:9989/group1/M00/00/05/rBGFrl3fdAKAVJwfMtSa9R18wLU139.zip";
//String url = "http://9.9.9.28:8088/files/update.zip";
//String url = "https://y.qq.com/download/import/QQMusic-import-1.2.1.zip";
- String url = "https://static.runoob.com/images/demo/demo2.jpg";
+ //String url = "https://static.runoob.com/images/demo/demo2.jpg";
+ String url = "https://22-1251738822.cos.ap-chengdu.myqcloud.com/1111111.docx";
//String filePath = "/mnt/sdcard/update.mp4";
- String filePath = "/mnt/sdcard/update.jpg";
+ String filePath = "/mnt/sdcard/xxx.docx";
singDownloadInfo = Aria.download(context).getFirstDownloadEntity(url);
if (singDownloadInfo == null) {
diff --git a/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
index 5d1d70ef..f78770c5 100644
--- a/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
+++ b/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
@@ -248,6 +248,7 @@ public class SingleTaskActivity extends BaseActivity {
//ALog.d(TAG, "文件md5: 9886e90f014d462b560dcec9c327bdb7");
ALog.d(TAG, "下载完成的文件md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
getBinding().pl.setInfo(task.getEntity());
+ getBinding().pl.setProgress(100);
}
}
@@ -258,6 +259,7 @@ public class SingleTaskActivity extends BaseActivity {
private void startD() {
HttpOption option = new HttpOption();
+ option.useServerFileName(true);
option.addHeader("1", "@")
.useServerFileName(true)
.setFileLenAdapter(new FileLenAdapter());
diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java
index 2a4fcae0..afd73706 100644
--- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java
+++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java
@@ -34,7 +34,8 @@ public class M3U8VodModule extends BaseViewModule {
// m3u8测试集合:http://www.voidcn.com/article/p-snaliarm-ct.html
//private final String defUrl = "https://www.gaoya123.cn/2019/1557993797897.m3u8";
// 多码率地址:
- private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u811";
+ //private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
+ private final String defUrl = "http://pp3zvsk2n.bkt.clouddn.com/20200806/sd/15967206011811803/38475fadd55e4ecea3.m3u8";
//private final String defUrl = "http://youku.cdn7-okzy.com/20200123/16815_fbe419ed/index.m3u8";
//private final String defUrl = "https://cn7.kankia.com/hls/20200108/e1eaec074274c64fe46a3bdb5d2ba487/1578488360/index.m3u8";