From 86aeac0ad83faac9f4b07ea32411e49571f81a83 Mon Sep 17 00:00:00 2001
From: laoyuyu <511455842@qq.com>
Date: Thu, 13 Aug 2020 21:06:06 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dm3u8gzip=E7=9A=84=E9=97=AE?=
=?UTF-8?q?=E9=A2=98=EF=BC=8Chttps://github.com/AriaLyy/Aria/issues/639=20?=
=?UTF-8?q?m3u8=E4=BD=BF=E7=94=A8`ignoreFailureTs`=E5=90=8E=E5=B0=86?=
=?UTF-8?q?=E4=B8=8D=E4=BC=9A=E8=87=AA=E5=8A=A8=E9=87=8D=E8=AF=95=E5=A4=B1?=
=?UTF-8?q?=E8=B4=A5=E7=9A=84=E5=88=87=E7=89=87=20https://github.com/AriaL?=
=?UTF-8?q?yy/Aria/issues/662?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.github/stale.yml | 2 +-
DEV_LOG.md | 2 ++
.../http/upload/HttpUThreadTaskAdapter.java | 4 +++-
.../com/arialyy/aria/m3u8/M3U8InfoTask.java | 5 +++--
.../arialyy/aria/m3u8/live/M3U8LiveLoader.java | 1 +
.../arialyy/aria/m3u8/vod/M3U8VodLoader.java | 1 +
.../aria/core/common/SubThreadConfig.java | 2 ++
.../com/arialyy/aria/core/task/ThreadTask.java | 5 +++++
.../core/download/HttpDownloadModule.java | 17 ++++-------------
.../core/download/SingleTaskActivity.java | 4 +++-
10 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/.github/stale.yml b/.github/stale.yml
index 32ceb3f1..8488e668 100644
--- a/.github/stale.yml
+++ b/.github/stale.yml
@@ -1,5 +1,5 @@
# Number of days of inactivity before an issue becomes stale
-daysUntilStale: 30
+daysUntilStale: 7
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
diff --git a/DEV_LOG.md b/DEV_LOG.md
index dbd25655..c452717a 100644
--- a/DEV_LOG.md
+++ b/DEV_LOG.md
@@ -4,9 +4,11 @@
- 修复一个匿名内部类中的内存溢出的问题 https://github.com/AriaLyy/Aria/issues/705
- 修复同一个url地址的任务提示路径冲突的问题
- 修复m3u8任务地址错误时,无法删除实体的问题 https://github.com/AriaLyy/Aria/issues/712
+ - 修复m3u8gzip的问题,https://github.com/AriaLyy/Aria/issues/639
- 增加m3u8密钥下载地址转换器增加ts列表的url地址 https://github.com/AriaLyy/Aria/issues/718
- 增加现在http文件下载将使用HEAD请求获取文件大小,配置文件增加
- 增加允许不使用apt直接通过实现监听器来回调下载进度更新,该功能由[chenfei0928](https://github.com/chenfei0928)提交,感谢他的pr。如果注解不生效,只需要实现`DownloadListener`接口便可
+ - m3u8使用`ignoreFailureTs`后将不会自动重试失败的切片 https://github.com/AriaLyy/Aria/issues/662
+ v_3.8.10 (2020/6/26)
- fix bug https://github.com/AriaLyy/Aria/issues/703
- fix bug https://github.com/AriaLyy/Aria/issues/702
diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java b/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java
index 77104a91..4b496236 100644
--- a/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java
+++ b/HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java
@@ -20,6 +20,7 @@ import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.exception.AriaHTTPException;
import com.arialyy.aria.http.BaseHttpThreadTaskAdapter;
+import com.arialyy.aria.http.ConnectionHelp;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import java.io.BufferedReader;
@@ -209,7 +210,8 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
int status = mHttpConn.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(mHttpConn.getInputStream()));
+ BufferedReader reader =
+ new BufferedReader(new InputStreamReader(ConnectionHelp.convertInputStream(mHttpConn)));
String line;
while (getThreadTask().isLive() && (line = reader.readLine()) != null) {
response.append(line);
diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java
index b105efea..b68c2e87 100644
--- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java
+++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java
@@ -118,7 +118,8 @@ final public class M3U8InfoTask implements IInfoTask {
private void handleConnect(String tsListUrl, HttpURLConnection conn) throws IOException {
int code = conn.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+ BufferedReader reader =
+ new BufferedReader(new InputStreamReader(ConnectionHelp.convertInputStream(conn)));
String line = reader.readLine();
if (TextUtils.isEmpty(line) || !line.equalsIgnoreCase("#EXTM3U")) {
failDownload("读取M3U8信息失败,读取不到#EXTM3U标签", false);
@@ -394,7 +395,7 @@ final public class M3U8InfoTask implements IInfoTask {
ConnectionHelp.setConnectParam(mHttpOption, conn);
conn.setConnectTimeout(mConnectTimeOut);
conn.connect();
- InputStream is = conn.getInputStream();
+ InputStream is = ConnectionHelp.convertInputStream(conn);
fos = new FileOutputStream(keyF);
byte[] buffer = new byte[1024];
int len;
diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java
index 85363a74..71409417 100644
--- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java
+++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java
@@ -196,6 +196,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
config.peerIndex = indexId;
config.threadType = SubThreadConfig.getThreadType(ITaskWrapper.M3U8_LIVE);
config.updateInterval = SubThreadConfig.getUpdateInterval(ITaskWrapper.M3U8_LIVE);
+ config.ignoreFailure = mM3U8Option.isIgnoreFailureTs();
if (!config.tempFile.exists()) {
FileUtil.createFile(config.tempFile);
}
diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java
index 14e0e1dc..bbe78c47 100644
--- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java
+++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java
@@ -486,6 +486,7 @@ final class M3U8VodLoader extends BaseM3U8Loader {
config.peerIndex = index;
config.threadType = SubThreadConfig.getThreadType(ITaskWrapper.M3U8_LIVE);
config.updateInterval = SubThreadConfig.getUpdateInterval(ITaskWrapper.M3U8_LIVE);
+ config.ignoreFailure = mM3U8Option.isIgnoreFailureTs();
if (!config.tempFile.exists()) {
FileUtil.createFile(config.tempFile);
}
diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/common/SubThreadConfig.java b/PublicComponent/src/main/java/com/arialyy/aria/core/common/SubThreadConfig.java
index 37e140db..3c49c334 100644
--- a/PublicComponent/src/main/java/com/arialyy/aria/core/common/SubThreadConfig.java
+++ b/PublicComponent/src/main/java/com/arialyy/aria/core/common/SubThreadConfig.java
@@ -51,6 +51,8 @@ public class SubThreadConfig {
public long updateInterval = 1000;
// 扩展数据
public Object obj;
+ // 忽略失败
+ public boolean ignoreFailure = false;
/**
* 转换线程任务类型
diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java
index f5097e87..fc896aee 100644
--- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java
+++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java
@@ -420,6 +420,11 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
* 重试ts分片
*/
private void retryM3U8Peer(boolean needRetry) {
+ if (mConfig.ignoreFailure){
+ ALog.d(TAG, "忽略失败的切片");
+ sendFailMsg(null, false);
+ return;
+ }
boolean isConnected = NetUtils.isConnected(AriaConfig.getInstance().getAPP());
if (!isConnected && !isNotNetRetry) {
ALog.w(TAG, String.format("ts切片【%s】重试失败,网络未连接", getFileName()));
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 7674964e..85d25c41 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
@@ -49,21 +49,12 @@ public class HttpDownloadModule extends BaseViewModule {
*/
LiveData getHttpDownloadInfo(Context context) {
//String url = AppUtil.getConfigValue(context, HTTP_URL_KEY, defUrl);
- //String url =
- // "http://sdkdown.muzhiwan.com/openfile/2019/05/21/com.netease.tom.mzw_5ce3ef8754d05.apk";
- //String url = "http://image.totwoo.com/totwoo-TOTWOO-v3.5.6.apk";
//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://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a9e671b9a551f3dedcb2bf64a4eff0ec/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg";
- //String url = "https://imtt.dd.qq.com/16891/apk/70BFFDB05AB8686F2A4CF3E07588A377.apk?fsname=com.tencent.tmgp.speedmobile_1.16.0.33877_1160033877.apk&csr=1bbd";
- //String url = "https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a9e671b9a551f3dedcb2bf64a4eff0ec/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg";
- //String filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath);
- String url = "https://y.qq.com/download/import/QQMusic-import-1.2.1.zip";
- //String url = "https://video-hkt1-1.xx.fbcdn.net/v/t42.9040-2/89465702_658301101378505_5469280744218034176_n.mp4?_nc_cat=107&_nc_sid=985c63&efg=eyJ2ZW5jb2RlX3RhZyI6ImxlZ2FjeV9zZCJ9&_nc_oc=AQmzYwQG9vccyqr7S44-cfHc4wJ9010O1nvspG2DPV4cTct1pLrjKl1e1UmOJV99bJw&_nc_ht=video-hkt1-1.xx&oh=49bd04435aaa8b4459b8d5cb7d1e7c79&oe=5E672E37";
- //String url = "http://donuts.aigauss.com/doc_fPhW2DBGj3_1578932414.png";
- String filePath = "/mnt/sdcard/update.mp4";
- //String url = "https://dhfspace.360drm.com/1_12809_1543904946_VID_20180808_212829.vep?e=1578554567&token=gUBmfZgZS5wy4wdQIDZG8UVxlNCyVSjvksIb13K5:WYSZRgmLbH1_9hjgqOAGmqR27JM=";
- //String filePath = "/mnt/sdcard/sssss.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 filePath = "/mnt/sdcard/update.mp4";
+ String filePath = "/mnt/sdcard/update.jpg";
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 d83d7e95..0e73526f 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
@@ -161,6 +161,7 @@ public class SingleTaskActivity extends BaseActivity {
if (speed > -1) {
msg = item.getTitle().toString();
T.showShort(this, msg);
+ Aria.get(this).getDownloadConfig().setMaxSpeed(speed);
}
return true;
}
@@ -244,7 +245,8 @@ public class SingleTaskActivity extends BaseActivity {
if (task.getKey().equals(mUrl)) {
Toast.makeText(SingleTaskActivity.this, getString(R.string.download_success),
Toast.LENGTH_SHORT).show();
- ALog.d(TAG, "md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
+ ALog.d(TAG, "文件md5: 9886e90f014d462b560dcec9c327bdb7");
+ ALog.d(TAG, "下载完成的文件md5: " + CommonUtil.getFileMD5(new File(task.getFilePath())));
getBinding().pl.setInfo(task.getEntity());
}
}