修复加密的m3u8下载,并且使用索引模式时,key的uri没有使用双引号的问题 https://github.com/AriaLyy/Aria/issues/731

修复删除m3u8索引文件后,下载完成回调无法触发的问题
pull/789/head
laoyuyu 4 years ago
parent 07a1f45f1e
commit 428fbab9d2
  1. 4
      DEV_LOG.md
  2. 2
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java
  3. 2
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java
  4. 6
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java
  5. 51
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java
  6. 3
      README.md
  7. 7
      app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java

@ -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请求获取文件大小,配置文件增加 <useHeadRequest value="true"/>
- 增加现在http文件下载将使用HEAD请求获取文件大小,配置文件增加 <useHeadRequest value="true"/>。慎用,并不是所有服务器都支持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)

@ -95,7 +95,7 @@ public abstract class BaseM3U8Loader extends AbsNormalLoader<DTaskWrapper> {
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 {

@ -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) {

@ -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() {

@ -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);

@ -171,7 +171,8 @@ protected void onCreate(Bundle savedInstanceState) {
有任何问题,可以在[issues](https://github.com/AriaLyy/Aria/issues)给我留言反馈。</br>
在提交问题前,希望你已经查看过[wiki](https://aria.laoyuyu.me/aria_doc/)或搜索过[issues](https://github.com/AriaLyy/Aria/issues)。</br>
## 请我喝瓶快乐水
## 捐赠
Aria是作业利用业余时间开发的一个项目,如果你喜欢我写的软件,可以考虑给我捐赠以支持我的工作</br>
<img src="https://raw.githubusercontent.com/AriaLyy/Aria/master/img/ali_pay.png" width=336 height=336/>
<img src="https://raw.githubusercontent.com/AriaLyy/Aria/master/img/wx_pay.png" width=336 height=336/>

@ -311,9 +311,10 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
//.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;
}

Loading…
Cancel
Save