From 428fbab9d2cb2d41bb50f0974a80aba0f861f416 Mon Sep 17 00:00:00 2001
From: laoyuyu <511455842@qq.com>
Date: Fri, 14 Aug 2020 22:17:13 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=A0=E5=AF=86=E7=9A=84m3?=
=?UTF-8?q?u8=E4=B8=8B=E8=BD=BD=EF=BC=8C=E5=B9=B6=E4=B8=94=E4=BD=BF?=
=?UTF-8?q?=E7=94=A8=E7=B4=A2=E5=BC=95=E6=A8=A1=E5=BC=8F=E6=97=B6=EF=BC=8C?=
=?UTF-8?q?key=E7=9A=84uri=E6=B2=A1=E6=9C=89=E4=BD=BF=E7=94=A8=E5=8F=8C?=
=?UTF-8?q?=E5=BC=95=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98=20https://github.?=
=?UTF-8?q?com/AriaLyy/Aria/issues/731=20=E4=BF=AE=E5=A4=8D=E5=88=A0?=
=?UTF-8?q?=E9=99=A4m3u8=E7=B4=A2=E5=BC=95=E6=96=87=E4=BB=B6=E5=90=8E?=
=?UTF-8?q?=EF=BC=8C=E4=B8=8B=E8=BD=BD=E5=AE=8C=E6=88=90=E5=9B=9E=E8=B0=83?=
=?UTF-8?q?=E6=97=A0=E6=B3=95=E8=A7=A6=E5=8F=91=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DEV_LOG.md | 4 +-
.../com/arialyy/aria/m3u8/BaseM3U8Loader.java | 2 +-
.../com/arialyy/aria/m3u8/M3U8InfoTask.java | 2 +-
.../arialyy/aria/m3u8/vod/M3U8VodLoader.java | 6 +++
.../aria/m3u8/vod/VodStateManager.java | 51 +++++++++++--------
README.md | 3 +-
.../download/m3u8/M3U8VodDLoadActivity.java | 7 +--
7 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/DEV_LOG.md b/DEV_LOG.md
index f32eb872..33b7ae68 100644
--- a/DEV_LOG.md
+++ b/DEV_LOG.md
@@ -7,8 +7,10 @@
- 修复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下载,并且使用索引模式时,key的uri没有使用双引号的问题 https://github.com/AriaLyy/Aria/issues/731
+ - 修复删除m3u8索引文件后,下载完成回调无法触发的问题
- 增加m3u8密钥下载地址转换器增加ts列表的url地址 https://github.com/AriaLyy/Aria/issues/718
- - 增加现在http文件下载将使用HEAD请求获取文件大小,配置文件增加
+ - 增加现在http文件下载将使用HEAD请求获取文件大小,配置文件增加 。慎用,并不是所有服务器都支持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)
diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java
index 8d974e99..3b06165a 100644
--- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java
+++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java
@@ -95,7 +95,7 @@ public abstract class BaseM3U8Loader extends AbsNormalLoader {
i++;
} else if (line.startsWith("#EXT-X-KEY")) {
M3U8Entity m3U8Entity = getEntity().getM3U8Entity();
- String keyInfo = String.format("#EXT-X-KEY:METHOD=%s,URI=%s,IV=%s\r\n", m3U8Entity.method,
+ String keyInfo = String.format("#EXT-X-KEY:METHOD=%s,URI=\"%s\",IV=%s\r\n", m3U8Entity.method,
m3U8Entity.keyPath, m3U8Entity.iv);
bytes = keyInfo.getBytes(Charset.forName("UTF-8"));
} else {
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 b68c2e87..84a6b7e8 100644
--- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java
+++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java
@@ -141,7 +141,7 @@ final public class M3U8InfoTask implements IInfoTask {
}
fos = new FileOutputStream(indexFile);
ALog.d(TAG, line);
- addIndexInfo(isGenerateIndexFile, fos, line);
+ addIndexInfo(true, fos, line);
}
while ((line = reader.readLine()) != null) {
if (isStop) {
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 bbe78c47..a3d26062 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
@@ -18,6 +18,7 @@ package com.arialyy.aria.m3u8.vod;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
+import android.util.Log;
import android.util.SparseArray;
import com.arialyy.aria.core.ThreadRecord;
import com.arialyy.aria.core.common.AbsEntity;
@@ -160,6 +161,11 @@ final class M3U8VodLoader extends BaseM3U8Loader {
// 启动定时器
startTimer();
+ if (getStateManager().isComplete()){
+ Log.d(TAG, "任务已完成");
+ getStateManager().handleTaskComplete();
+ return;
+ }
// 启动线程开始下载ts切片
Thread th = new Thread(new Runnable() {
diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java
index 44f22549..ccdbe186 100644
--- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java
+++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java
@@ -139,28 +139,7 @@ public final class VodStateManager implements IThreadStateManager {
loader.notifyWaitLock(true);
}
if (isComplete()) {
- ALog.d(TAG, String.format(
- "startThreadNum = %s, stopNum = %s, cancelNum = %s, failNum = %s, completeNum = %s, flagQueueSize = %s",
- startThreadNum, stopNum, cancelNum, failNum, loader.getCompleteNum(),
- loader.getCurrentFlagSize()));
- ALog.d(TAG, String.format("vod任务【%s】完成", loader.getTempFile().getName()));
-
- if (m3U8Option.isGenerateIndexFile()) {
- if (loader.generateIndexFile(false)) {
- listener.onComplete();
- } else {
- listener.onFail(false, new AriaM3U8Exception("创建索引文件失败"));
- }
- } else if (m3U8Option.isMergeFile()) {
- if (mergeFile()) {
- listener.onComplete();
- } else {
- listener.onFail(false, null);
- }
- } else {
- listener.onComplete();
- }
- quitLooper();
+ handleTaskComplete();
}
break;
case STATE_RUNNING:
@@ -175,6 +154,34 @@ public final class VodStateManager implements IThreadStateManager {
}
};
+ /**
+ * 处理m3u8以完成
+ */
+ void handleTaskComplete() {
+ ALog.d(TAG, String.format(
+ "startThreadNum = %s, stopNum = %s, cancelNum = %s, failNum = %s, completeNum = %s, flagQueueSize = %s",
+ startThreadNum, stopNum, cancelNum, failNum, loader.getCompleteNum(),
+ loader.getCurrentFlagSize()));
+ ALog.d(TAG, String.format("vod任务【%s】完成", loader.getTempFile().getName()));
+
+ if (m3U8Option.isGenerateIndexFile()) {
+ if (loader.generateIndexFile(false)) {
+ listener.onComplete();
+ } else {
+ listener.onFail(false, new AriaM3U8Exception("创建索引文件失败"));
+ }
+ } else if (m3U8Option.isMergeFile()) {
+ if (mergeFile()) {
+ listener.onComplete();
+ } else {
+ listener.onFail(false, null);
+ }
+ } else {
+ listener.onComplete();
+ }
+ quitLooper();
+ }
+
void updateStateCount() {
cancelNum.set(0);
stopNum.set(0);
diff --git a/README.md b/README.md
index bb89c22d..6699a293 100644
--- a/README.md
+++ b/README.md
@@ -171,7 +171,8 @@ 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)。
-## 请我喝瓶快乐水
+## 捐赠
+ Aria是作业利用业余时间开发的一个项目,如果你喜欢我写的软件,可以考虑给我捐赠以支持我的工作
diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
index c8c92d35..25ac01d2 100644
--- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
+++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
@@ -311,9 +311,10 @@ public class M3U8VodDLoadActivity extends BaseActivity {
//.setVodTsUrlConvert(new VodTsUrlConverter());
//.setMergeHandler(new TsMergeHandler());
option.setUseDefConvert(true);
- option.setKeyUrlConverter(new KeyUrlConverter());
- option.setVodTsUrlConvert(new VodTsUrlConverter());
- option.setBandWidthUrlConverter(new BandWidthUrlConverter());
+ option.generateIndexFile();
+ //option.setKeyUrlConverter(new KeyUrlConverter());
+ //option.setVodTsUrlConvert(new VodTsUrlConverter());
+ //option.setBandWidthUrlConverter(new BandWidthUrlConverter());
//option.setUseDefConvert(true);
return option;
}