Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
023f648d07 | ||
|
|
9a174311d9 | ||
|
|
3edf40f533 | ||
|
|
46c10f6ffd | ||
|
|
32cb6152dd | ||
|
|
f657bbcc53 | ||
|
|
e6f5c4f472 | ||
|
|
b7e0f6f0e8 | ||
|
|
0bc083fa98 | ||
|
|
d931b75800 | ||
|
|
418ec74b7b | ||
|
|
29f9bdcdbd |
7
.github/FUNDING.yml
vendored
Normal file
7
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# These are supported funding model platforms
|
||||
# https://help.github.com/cn/github/administering-a-repository/displaying-a-sponsor-button-in-your-repository
|
||||
# github: ["AriaLyy"]
|
||||
# patreon: AriaLyy
|
||||
# liberapay: Aria
|
||||
custom: ["https://afdian.net/@arialyy/plan", "https://paypal.me/arialyy"]
|
||||
|
||||
@@ -37,12 +37,23 @@ public class M3U8Option<OP extends M3U8Option> extends BaseOption {
|
||||
private IKeyUrlConverter keyUrlConverter;
|
||||
private boolean ignoreFailureTs = false;
|
||||
private String keyPath;
|
||||
private boolean useDefConvert = true;
|
||||
|
||||
M3U8Option() {
|
||||
super();
|
||||
ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_M3U8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置使用默认的码率转换器和TS转换器,默认打开
|
||||
* @param useDefConvert true 使用默认的转换器,false 关闭默认的转换器
|
||||
*/
|
||||
public OP setUseDefConvert(boolean useDefConvert) {
|
||||
this.useDefConvert = useDefConvert;
|
||||
ALog.d(TAG, "使用默认的码率转换器和TS转换器,如果无法下载,请参考:https://github.com/AriaLyy/Aria/issues/597 定制转换器");
|
||||
return (OP) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置密钥文件的保存路径
|
||||
*
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
* 子任务管理器
|
||||
*/
|
||||
public class SubTaskManager {
|
||||
private String TAG = "SubTaskManager";
|
||||
private final String TAG = getClass().getSimpleName();
|
||||
private DGTaskWrapper mEntity;
|
||||
|
||||
public SubTaskManager(DGTaskWrapper entity) {
|
||||
|
||||
11
DEV_LOG.md
11
DEV_LOG.md
@@ -1,4 +1,15 @@
|
||||
## 开发日志
|
||||
+ 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
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/695
|
||||
+ v_3.8.9 (2020/6/14)
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/688
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/690
|
||||
- m3u8任务增加`setUseDefConvert()`方法,用于处理默认的m3u8任务
|
||||
+ v_3.8.8 (2020/6/7)
|
||||
- 修复设置了cancel(false),文件还是被删除的问题 https://github.com/AriaLyy/Aria/issues/686
|
||||
- 修复错误url的下载任务,无法删除的问题 https://github.com/AriaLyy/Aria/issues/684
|
||||
+ v_3.8.7 (2020/5/25)
|
||||
- 修复组合任务单个子任务失败后,重新恢复组合任务,组合任务状态变为完成的问题
|
||||
- 修复40x错误,会继续重试并且无法重试成功的问题 https://github.com/AriaLyy/Aria/issues/619
|
||||
|
||||
@@ -328,7 +328,7 @@ public abstract class AbsFtpInfoTask<ENTITY extends AbsEntity, TASK_WRAPPER exte
|
||||
needRetry = needRetry && !CheckUtil.ftpIsBadRequest(client.getReplyCode());
|
||||
}
|
||||
|
||||
callback.onFail(mEntity, new AriaFTPException(TAG, msg), needRetry);
|
||||
callback.onFail(mEntity, new AriaFTPException(msg), needRetry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public abstract class BaseFtpThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
int reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
client.disconnect();
|
||||
fail(new AriaFTPException(TAG,
|
||||
fail(new AriaFTPException(
|
||||
String.format("无法连接到ftp服务器,错误码为:%s,msg:%s", reply, client.getReplyString())), false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ final class FtpDFileInfoTask extends AbsFtpInfoTask<DownloadEntity, DTaskWrapper
|
||||
@Override protected void handleFile(String remotePath, FTPFile ftpFile) {
|
||||
super.handleFile(remotePath, ftpFile);
|
||||
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), ftpFile.getSize())) {
|
||||
callback.onFail(mEntity, new AriaFTPException(TAG,
|
||||
callback.onFail(mEntity, new AriaFTPException(
|
||||
String.format("获取ftp文件信息失败,内存空间不足, filePath: %s", mEntity.getFilePath())),
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
getThreadRecord().endLocation));
|
||||
client = createClient();
|
||||
if (client == null) {
|
||||
fail(new AriaFTPException(TAG, "ftp client 创建失败"), false);
|
||||
fail(new AriaFTPException("ftp client 创建失败"), false);
|
||||
return;
|
||||
}
|
||||
if (getThreadRecord().startLocation > 0) {
|
||||
@@ -65,7 +65,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
//发送第二次指令时,还需要再做一次判断
|
||||
int reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.COMMAND_OK) {
|
||||
fail(new AriaFTPException(TAG,
|
||||
fail(new AriaFTPException(
|
||||
String.format("获取文件信息错误,错误码为:%s,msg:%s", reply, client.getReplyString())), false);
|
||||
client.disconnect();
|
||||
return;
|
||||
@@ -76,7 +76,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
is = client.retrieveFileStream(remotePath);
|
||||
reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositivePreliminary(reply)) {
|
||||
fail(new AriaFTPException(TAG,
|
||||
fail(new AriaFTPException(
|
||||
String.format("获取流失败,错误码为:%s,msg:%s", reply, client.getReplyString())), true);
|
||||
client.disconnect();
|
||||
return;
|
||||
@@ -89,9 +89,9 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
handleComplete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||
fail(new AriaFTPException(String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||
} catch (Exception e) {
|
||||
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), false);
|
||||
fail(new AriaFTPException(String.format("下载失败【%s】", getThreadConfig().url), e), false);
|
||||
} finally {
|
||||
try {
|
||||
if (is != null) {
|
||||
@@ -153,7 +153,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
}
|
||||
handleComplete();
|
||||
} catch (IOException e) {
|
||||
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||
fail(new AriaFTPException(String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||
} finally {
|
||||
try {
|
||||
if (fos != null) {
|
||||
@@ -203,7 +203,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||
fail(new AriaFTPException(String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||
} finally {
|
||||
try {
|
||||
if (file != null) {
|
||||
|
||||
@@ -67,7 +67,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
client.setRestartOffset(getThreadRecord().startLocation);
|
||||
int reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.FILE_ACTION_OK) {
|
||||
fail(new AriaFTPException(TAG,
|
||||
fail(new AriaFTPException(
|
||||
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply,
|
||||
client.getReplyString(), getEntity().getFilePath())), false);
|
||||
client.disconnect();
|
||||
@@ -85,7 +85,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
return;
|
||||
}
|
||||
if (!complete) {
|
||||
fail(new AriaFTPException(TAG, "ftp文件上传失败"), false);
|
||||
fail(new AriaFTPException("ftp文件上传失败"), false);
|
||||
return;
|
||||
}
|
||||
ALog.i(TAG,
|
||||
@@ -93,11 +93,11 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
complete();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
fail(new AriaFTPException(TAG,
|
||||
fail(new AriaFTPException(
|
||||
String.format("上传失败,filePath: %s, uploadUrl: %s", getEntity().getFilePath(),
|
||||
getThreadConfig().url)), true);
|
||||
} catch (Exception e) {
|
||||
fail(new AriaFTPException(TAG, null, e), false);
|
||||
fail(new AriaFTPException(null, e), false);
|
||||
} finally {
|
||||
try {
|
||||
if (file != null) {
|
||||
@@ -136,7 +136,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
@Override public void run() {
|
||||
try {
|
||||
if (isTimeOut) {
|
||||
fail(new AriaFTPException(TAG, "socket连接失败,该问题一般出现于网络断开,客户端重新连接,"
|
||||
fail(new AriaFTPException("socket连接失败,该问题一般出现于网络断开,客户端重新连接,"
|
||||
+ "但是服务器端无法创建socket缺没有返回错误码的情况。"), false);
|
||||
if (fa != null) {
|
||||
fa.close();
|
||||
@@ -199,7 +199,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
if (e.getMessage().contains("AriaIOException caught while copying")) {
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
fail(new AriaFTPException(TAG, msg, e), !storeSuccess);
|
||||
fail(new AriaFTPException(msg, e), !storeSuccess);
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
@@ -208,7 +208,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
||||
int reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
if (reply != FTPReply.TRANSFER_ABORTED) {
|
||||
fail(new AriaFTPException(TAG,
|
||||
fail(new AriaFTPException(
|
||||
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply, client.getReplyString(),
|
||||
getEntity().getFilePath())), false);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
||||
conn.connect();
|
||||
handleConnect(conn);
|
||||
} catch (IOException e) {
|
||||
failDownload(new AriaHTTPException(TAG,
|
||||
failDownload(new AriaHTTPException(
|
||||
String.format("下载失败,filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl()),
|
||||
e), true);
|
||||
} finally {
|
||||
@@ -133,7 +133,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
||||
long len = lenAdapter.handleFileLen(conn.getHeaderFields());
|
||||
|
||||
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), len)) {
|
||||
failDownload(new AriaHTTPException(TAG,
|
||||
failDownload(new AriaHTTPException(
|
||||
String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getFilePath(),
|
||||
mEntity.getUrl())), false);
|
||||
return;
|
||||
@@ -183,8 +183,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
||||
if (!checkLen(len) && !isChunked) {
|
||||
if (len < 0) {
|
||||
failDownload(
|
||||
new AriaHTTPException(TAG,
|
||||
String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
|
||||
new AriaHTTPException(String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
|
||||
false);
|
||||
}
|
||||
return;
|
||||
@@ -211,7 +210,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
||||
} else if (!checkLen(len) && !isChunked) {
|
||||
if (len < 0) {
|
||||
failDownload(
|
||||
new AriaHTTPException(TAG,
|
||||
new AriaHTTPException(
|
||||
String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
|
||||
false);
|
||||
}
|
||||
@@ -229,10 +228,10 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
||||
|| code == 307) {
|
||||
handleUrlReTurn(conn, conn.getHeaderField("Location"));
|
||||
} else if (code >= HttpURLConnection.HTTP_BAD_REQUEST) {
|
||||
failDownload(new AriaHTTPException(TAG,
|
||||
failDownload(new AriaHTTPException(
|
||||
String.format("任务下载失败,errorCode:%s, url: %s", code, mEntity.getUrl())), false);
|
||||
} else {
|
||||
failDownload(new AriaHTTPException(TAG,
|
||||
failDownload(new AriaHTTPException(
|
||||
String.format("任务下载失败,errorCode:%s, errorMsg: %s, url: %s", code,
|
||||
conn.getResponseMessage(), mEntity.getUrl())), !CheckUtil.httpIsBadRequest(code));
|
||||
}
|
||||
@@ -311,7 +310,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
||||
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
||||
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
||||
if (callback != null) {
|
||||
callback.onFail(mEntity, new AriaHTTPException(TAG, "获取重定向链接失败"), false);
|
||||
callback.onFail(mEntity, new AriaHTTPException("获取重定向链接失败"), false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -321,7 +320,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
||||
}
|
||||
|
||||
if (!CheckUtil.checkUrl(newUrl)) {
|
||||
failDownload(new AriaHTTPException(TAG, "下载失败,重定向url错误"), false);
|
||||
failDownload(new AriaHTTPException("下载失败,重定向url错误"), false);
|
||||
return;
|
||||
}
|
||||
taskOption.setRedirectUrl(newUrl);
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class HttpDGInfoTask implements IInfoTask {
|
||||
ALog.e(TAG, String.format("获取文件信息失败,url:%s", ((DownloadEntity) entity).getUrl()));
|
||||
count.getAndIncrement();
|
||||
failCount.getAndIncrement();
|
||||
listener.onSubFail((DownloadEntity) entity, new AriaHTTPException(TAG,
|
||||
listener.onSubFail((DownloadEntity) entity, new AriaHTTPException(
|
||||
String.format("子任务获取文件长度失败,url:%s", ((DownloadEntity) entity).getUrl())));
|
||||
checkGetSizeComplete(count.get(), failCount.get());
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public final class HttpDGInfoTask implements IInfoTask {
|
||||
DownloadEntity subEntity = dTaskWrapper.getEntity();
|
||||
if (subEntity.getFileSize() > 0) {
|
||||
count.getAndIncrement();
|
||||
if (subEntity.getCurrentProgress() < subEntity.getFileSize()){
|
||||
if (subEntity.getCurrentProgress() < subEntity.getFileSize()) {
|
||||
// 如果没有完成需要拷贝一份数据
|
||||
cloneHeader(dTaskWrapper);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public final class HttpDGInfoTask implements IInfoTask {
|
||||
*/
|
||||
private void checkGetSizeComplete(int count, int failCount) {
|
||||
if (failCount == wrapper.getSubTaskWrapper().size()) {
|
||||
callback.onFail(wrapper.getEntity(), new AriaHTTPException(TAG, "获取子任务长度失败"), false);
|
||||
callback.onFail(wrapper.getEntity(), new AriaHTTPException("获取子任务长度失败"), false);
|
||||
notifyLock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -117,21 +117,17 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
||||
handleComplete();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
fail(new AriaHTTPException(TAG,
|
||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||
fail(new AriaHTTPException(String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||
} catch (IOException e) {
|
||||
fail(new AriaHTTPException(TAG,
|
||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||
getEntity().getFilePath(), getEntity().getUrl()), e), true);
|
||||
fail(new AriaHTTPException(String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||
getEntity().getFilePath(), getEntity().getUrl()), e), true);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
fail(new AriaHTTPException(TAG,
|
||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||
fail(new AriaHTTPException(String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||
} catch (Exception e) {
|
||||
fail(new AriaHTTPException(TAG,
|
||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||
fail(new AriaHTTPException(String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||
} finally {
|
||||
try {
|
||||
if (file != null) {
|
||||
@@ -171,7 +167,7 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
||||
}
|
||||
handleComplete();
|
||||
} catch (IOException e) {
|
||||
fail(new AriaHTTPException(TAG,
|
||||
fail(new AriaHTTPException(
|
||||
String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
|
||||
getThreadConfig().url), e), true);
|
||||
} finally {
|
||||
@@ -224,8 +220,7 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
||||
}
|
||||
handleComplete();
|
||||
} catch (IOException e) {
|
||||
fail(new AriaHTTPException(TAG,
|
||||
String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
|
||||
fail(new AriaHTTPException(String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
|
||||
getThreadConfig().url), e), true);
|
||||
} finally {
|
||||
try {
|
||||
|
||||
@@ -62,7 +62,7 @@ final class HttpULoader extends AbsNormalLoader<UTaskWrapper> {
|
||||
new Handler(looper, mStateManager.getHandlerCallback()));
|
||||
if (tt == null || tt.isEmpty()) {
|
||||
ALog.e(TAG, "创建线程任务失败");
|
||||
getListener().onFail(false, new AriaHTTPException(TAG, "创建线程任务失败"));
|
||||
getListener().onFail(false, new AriaHTTPException("创建线程任务失败"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
||||
@Override protected void handlerThreadTask() {
|
||||
File uploadFile = new File(getEntity().getFilePath());
|
||||
if (!uploadFile.exists()) {
|
||||
fail(new AriaHTTPException(TAG,
|
||||
fail(new AriaHTTPException(
|
||||
String.format("上传失败,文件不存在;filePath: %s, url: %s", getEntity().getFilePath(),
|
||||
getEntity().getUrl())));
|
||||
return;
|
||||
@@ -104,7 +104,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
||||
getEntity().setResponseStr(finish(writer));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(new AriaHTTPException(TAG,
|
||||
fail(new AriaHTTPException(
|
||||
String.format("上传失败,filePath: %s, url: %s", getEntity().getFilePath(),
|
||||
getEntity().getUrl()), e));
|
||||
}
|
||||
@@ -220,7 +220,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
||||
} else {
|
||||
String msg = "response msg: " + mHttpConn.getResponseMessage() + ",code: " + status;
|
||||
ALog.e(TAG, msg);
|
||||
fail(new AriaHTTPException(TAG, msg), false);
|
||||
fail(new AriaHTTPException(msg), false);
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.aria.m3u8;
|
||||
|
||||
import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
|
||||
|
||||
/**
|
||||
* 点播文件默认的码率转换器
|
||||
*/
|
||||
class BandWidthDefConverter implements IBandWidthUrlConverter {
|
||||
|
||||
@Override public String convert(String m3u8Url, String bandWidthUrl) {
|
||||
int index = m3u8Url.lastIndexOf("/");
|
||||
return m3u8Url.substring(0, index + 1) + bandWidthUrl;
|
||||
}
|
||||
}
|
||||
@@ -295,7 +295,7 @@ final public class M3U8InfoTask implements IInfoTask {
|
||||
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
||||
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onFail(mEntity, new AriaM3U8Exception(TAG, "获取重定向链接失败"), false);
|
||||
mCallback.onFail(mEntity, new AriaM3U8Exception("获取重定向链接失败"), false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -328,9 +328,10 @@ final public class M3U8InfoTask implements IInfoTask {
|
||||
* 处理码率
|
||||
*/
|
||||
private void handleBandWidth(HttpURLConnection conn, String bandWidthM3u8Url) throws IOException {
|
||||
IBandWidthUrlConverter converter = mM3U8Option.getBandWidthUrlConverter();
|
||||
IBandWidthUrlConverter converter = mM3U8Option.isUseDefConvert() ? new BandWidthDefConverter()
|
||||
: mM3U8Option.getBandWidthUrlConverter();
|
||||
if (converter != null) {
|
||||
bandWidthM3u8Url = converter.convert(bandWidthM3u8Url);
|
||||
bandWidthM3u8Url = converter.convert(mEntity.getUrl(), bandWidthM3u8Url);
|
||||
if (!bandWidthM3u8Url.startsWith("http")) {
|
||||
failDownload(String.format("码率转换器转换后的url地址无效,转换后的url:%s", bandWidthM3u8Url), false);
|
||||
return;
|
||||
@@ -353,7 +354,7 @@ final public class M3U8InfoTask implements IInfoTask {
|
||||
}
|
||||
|
||||
private void failDownload(String errorInfo, boolean needRetry) {
|
||||
mCallback.onFail(mEntity, new AriaM3U8Exception(TAG, errorInfo), needRetry);
|
||||
mCallback.onFail(mEntity, new AriaM3U8Exception(errorInfo), needRetry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -120,6 +120,19 @@ public final class M3U8TaskOption implements ITaskOption {
|
||||
*/
|
||||
private String keyPath;
|
||||
|
||||
/**
|
||||
* 是否使用默认的码率转换器和Ts转换器
|
||||
*/
|
||||
private boolean useDefConvert = false;
|
||||
|
||||
public boolean isUseDefConvert() {
|
||||
return useDefConvert;
|
||||
}
|
||||
|
||||
public void setUseDefConvert(boolean useDefConvert) {
|
||||
this.useDefConvert = useDefConvert;
|
||||
}
|
||||
|
||||
public String getKeyPath() {
|
||||
return keyPath;
|
||||
}
|
||||
|
||||
@@ -91,15 +91,15 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
|
||||
handleConn(conn);
|
||||
} catch (MalformedURLException e) {
|
||||
fail(new AriaM3U8Exception(TAG,
|
||||
fail(new AriaM3U8Exception(
|
||||
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
||||
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false);
|
||||
} catch (IOException e) {
|
||||
fail(new AriaM3U8Exception(TAG,
|
||||
fail(new AriaM3U8Exception(
|
||||
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
||||
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), true);
|
||||
} catch (Exception e) {
|
||||
fail(new AriaM3U8Exception(TAG,
|
||||
fail(new AriaM3U8Exception(
|
||||
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
||||
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false);
|
||||
} finally {
|
||||
@@ -137,7 +137,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
|| code == 307) {
|
||||
handleUrlReTurn(conn, conn.getHeaderField("Location"));
|
||||
} else {
|
||||
fail(new AriaM3U8Exception(TAG,
|
||||
fail(new AriaM3U8Exception(
|
||||
String.format("连接错误,http错误码:%s,url:%s", code, getThreadConfig().url)),
|
||||
false);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
private void handleUrlReTurn(HttpURLConnection conn, String newUrl) throws IOException {
|
||||
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
||||
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
||||
fail(new AriaM3U8Exception(TAG, "下载失败,重定向url为空"), false);
|
||||
fail(new AriaM3U8Exception("下载失败,重定向url为空"), false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
}
|
||||
|
||||
if (!CheckUtil.checkUrl(newUrl)) {
|
||||
fail(new AriaM3U8Exception(TAG, "下载失败,重定向url错误"), false);
|
||||
fail(new AriaM3U8Exception("下载失败,重定向url错误"), false);
|
||||
return;
|
||||
}
|
||||
String cookies = conn.getHeaderField("Set-Cookie");
|
||||
@@ -198,7 +198,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
}
|
||||
handleComplete();
|
||||
} catch (IOException e) {
|
||||
fail(new AriaM3U8Exception(TAG,
|
||||
fail(new AriaM3U8Exception(
|
||||
String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(),
|
||||
getThreadConfig().url), e), true);
|
||||
} finally {
|
||||
@@ -241,7 +241,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
}
|
||||
handleComplete();
|
||||
} catch (IOException e) {
|
||||
fail(new AriaM3U8Exception(TAG,
|
||||
fail(new AriaM3U8Exception(
|
||||
String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(),
|
||||
getThreadConfig().url), e), true);
|
||||
} finally {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.aria.m3u8.live;
|
||||
|
||||
import com.arialyy.aria.core.processor.ILiveTsUrlConverter;
|
||||
|
||||
/**
|
||||
* 默认的m3u8 ts转换器
|
||||
*/
|
||||
class LiveTsDefConverter implements ILiveTsUrlConverter {
|
||||
@Override public String convert(String m3u8Url, String tsUrl) {
|
||||
int index = m3u8Url.lastIndexOf("/");
|
||||
String parentUrl = m3u8Url.substring(0, index + 1);
|
||||
return parentUrl + tsUrl;
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@ import com.arialyy.aria.core.processor.ILiveTsUrlConverter;
|
||||
import com.arialyy.aria.core.processor.ITsMergeHandler;
|
||||
import com.arialyy.aria.core.task.ThreadTask;
|
||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.exception.AriaM3U8Exception;
|
||||
import com.arialyy.aria.exception.AriaException;
|
||||
import com.arialyy.aria.exception.AriaM3U8Exception;
|
||||
import com.arialyy.aria.m3u8.BaseM3U8Loader;
|
||||
import com.arialyy.aria.m3u8.IdGenerator;
|
||||
import com.arialyy.aria.m3u8.M3U8InfoTask;
|
||||
@@ -265,7 +265,9 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
|
||||
return;
|
||||
}
|
||||
mPeerUrls.add(url);
|
||||
ILiveTsUrlConverter converter = mM3U8Option.getLiveTsUrlConverter();
|
||||
ILiveTsUrlConverter converter = mM3U8Option.isUseDefConvert() ?
|
||||
new LiveTsDefConverter() :
|
||||
mM3U8Option.getLiveTsUrlConverter();
|
||||
if (converter != null) {
|
||||
if (TextUtils.isEmpty(mM3U8Option.getBandWidthUrl())) {
|
||||
url = converter.convert(getEntity().getUrl(), url);
|
||||
@@ -274,7 +276,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(url) || !url.startsWith("http")) {
|
||||
fail(new AriaM3U8Exception(TAG, String.format("ts地址错误,url:%s", url)), false);
|
||||
fail(new AriaM3U8Exception(String.format("ts地址错误,url:%s", url)), false);
|
||||
return;
|
||||
}
|
||||
offerPeer(new M3U8LiveLoader.ExtInfo(url, extInf));
|
||||
@@ -295,13 +297,13 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
|
||||
if (generateIndexFile(true)) {
|
||||
getListener().onComplete();
|
||||
} else {
|
||||
getListener().onFail(false, new AriaM3U8Exception(TAG, "创建索引文件失败"));
|
||||
getListener().onFail(false, new AriaM3U8Exception("创建索引文件失败"));
|
||||
}
|
||||
} else if (mM3U8Option.isMergeFile()) {
|
||||
if (mergeFile()) {
|
||||
getListener().onComplete();
|
||||
} else {
|
||||
getListener().onFail(false, new AriaM3U8Exception(TAG, "合并文件失败"));
|
||||
getListener().onFail(false, new AriaM3U8Exception("合并文件失败"));
|
||||
}
|
||||
} else {
|
||||
getListener().onComplete();
|
||||
|
||||
@@ -504,7 +504,9 @@ final class M3U8VodLoader extends BaseM3U8Loader {
|
||||
final List<String> urls = new ArrayList<>();
|
||||
mInfoTask.setCallback(new IInfoTask.Callback() {
|
||||
@Override public void onSucceed(String key, CompleteInfo info) {
|
||||
IVodTsUrlConverter converter = mM3U8Option.getVodUrlConverter();
|
||||
IVodTsUrlConverter converter = mM3U8Option.isUseDefConvert() ?
|
||||
new VodTsDefConverter() :
|
||||
mM3U8Option.getVodUrlConverter();
|
||||
if (converter != null) {
|
||||
if (TextUtils.isEmpty(mM3U8Option.getBandWidthUrl())) {
|
||||
urls.addAll(
|
||||
@@ -517,10 +519,10 @@ final class M3U8VodLoader extends BaseM3U8Loader {
|
||||
urls.addAll((Collection<? extends String>) info.obj);
|
||||
}
|
||||
if (urls.isEmpty()) {
|
||||
fail(new AriaM3U8Exception(TAG, "获取地址失败"), false);
|
||||
fail(new AriaM3U8Exception("获取地址失败"), false);
|
||||
return;
|
||||
} else if (!urls.get(0).startsWith("http")) {
|
||||
fail(new AriaM3U8Exception(TAG, "地址错误,请使用IVodTsUrlConverter处理你的url信息"), false);
|
||||
fail(new AriaM3U8Exception("地址错误,请使用IVodTsUrlConverter处理你的url信息"), false);
|
||||
return;
|
||||
}
|
||||
mM3U8Option.setUrls(urls);
|
||||
|
||||
@@ -149,7 +149,7 @@ public final class VodStateManager implements IThreadStateManager {
|
||||
if (loader.generateIndexFile(false)) {
|
||||
listener.onComplete();
|
||||
} else {
|
||||
listener.onFail(false, new AriaM3U8Exception(TAG, "创建索引文件失败"));
|
||||
listener.onFail(false, new AriaM3U8Exception("创建索引文件失败"));
|
||||
}
|
||||
} else if (m3U8Option.isMergeFile()) {
|
||||
if (mergeFile()) {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.aria.m3u8.vod;
|
||||
|
||||
import com.arialyy.aria.core.processor.IVodTsUrlConverter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 默认的m3u8 ts转换器
|
||||
*/
|
||||
class VodTsDefConverter implements IVodTsUrlConverter {
|
||||
@Override public List<String> convert(String m3u8Url, List<String> tsUrls) {
|
||||
int index = m3u8Url.lastIndexOf("/");
|
||||
List<String> convertedTsUrl = new ArrayList<>();
|
||||
|
||||
String parentUrl = m3u8Url.substring(0, index + 1);
|
||||
for (String temp : tsUrls) {
|
||||
convertedTsUrl.add(parentUrl + temp);
|
||||
}
|
||||
return convertedTsUrl;
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,14 @@ package com.arialyy.aria.core.group;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.TaskRecord;
|
||||
import com.arialyy.aria.core.config.Configuration;
|
||||
import com.arialyy.aria.core.inf.IThreadStateManager;
|
||||
import com.arialyy.aria.core.loader.IRecordHandler;
|
||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||
import com.arialyy.aria.exception.AriaException;
|
||||
import com.arialyy.aria.exception.ExceptionFactory;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.NetUtils;
|
||||
@@ -71,7 +73,7 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
mGState.listener.onSubRunning(loaderUtil.getEntity(), range);
|
||||
break;
|
||||
case IThreadStateManager.STATE_PRE:
|
||||
mGState.listener.onSubPre(loaderUtil.getEntity( ));
|
||||
mGState.listener.onSubPre(loaderUtil.getEntity());
|
||||
mGState.updateCount(loaderUtil.getKey());
|
||||
break;
|
||||
case IThreadStateManager.STATE_START:
|
||||
@@ -103,8 +105,11 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
* @param needRetry true 需要重试,false 不需要重试
|
||||
*/
|
||||
private synchronized void handleFail(final AbsSubDLoadUtil loaderUtil, boolean needRetry) {
|
||||
Configuration config = Configuration.getInstance();
|
||||
Log.d(TAG, String.format("handleFail, size = %s, completeNum = %s, failNum = %s, stopNum = %s",
|
||||
mGState.getSubSize(), mGState.getCompleteNum(), mGState.getFailNum(),
|
||||
mGState.getSubSize()));
|
||||
|
||||
Configuration config = Configuration.getInstance();
|
||||
int num = config.dGroupCfg.getSubReTryNum();
|
||||
boolean isNotNetRetry = config.appCfg.isNotNetRetry();
|
||||
|
||||
@@ -113,25 +118,27 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
|| loaderUtil.getLoader() == null // 如果获取不到文件信息,loader为空
|
||||
|| loaderUtil.getEntity().getFailNum() > num) {
|
||||
mQueue.removeTaskFromExecQ(loaderUtil);
|
||||
mGState.listener.onSubFail(loaderUtil.getEntity(), new AriaException(TAG,
|
||||
String.format("任务组子任务【%s】下载失败,下载地址【%s】", loaderUtil.getEntity().getFileName(),
|
||||
loaderUtil.getEntity().getUrl())));
|
||||
mGState.listener.onSubFail(loaderUtil.getEntity(),
|
||||
ExceptionFactory.getException(ExceptionFactory.TYPE_GROUP,
|
||||
String.format("任务组子任务【%s】下载失败,下载地址【%s】", loaderUtil.getEntity().getFileName(),
|
||||
loaderUtil.getEntity().getUrl()), null));
|
||||
mGState.countFailNum(loaderUtil.getKey());
|
||||
if (mGState.getFailNum() == mGState.getSubSize()
|
||||
|| mGState.getStopNum() + mGState.getFailNum() + mGState.getCompleteNum()
|
||||
== mGState.getSubSize()) {
|
||||
mQueue.clear();
|
||||
mGState.isRunning.set(false);
|
||||
if (mGState.getCompleteNum() > 0&&Configuration.getInstance().dGroupCfg.isSubFailAsStop()) {
|
||||
if (mGState.getCompleteNum() > 0
|
||||
&& Configuration.getInstance().dGroupCfg.isSubFailAsStop()) {
|
||||
ALog.e(TAG, String.format("任务组【%s】停止", mGState.getGroupHash()));
|
||||
mGState.listener.onStop(mGState.getProgress());
|
||||
} else {
|
||||
mGState.listener.onFail(false, new AriaException(TAG,
|
||||
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
startNext();
|
||||
mGState.listener.onFail(false,
|
||||
ExceptionFactory.getException(ExceptionFactory.TYPE_GROUP,
|
||||
String.format("任务组【%s】下载失败", mGState.getGroupHash()), null));
|
||||
return;
|
||||
}
|
||||
startNext();
|
||||
return;
|
||||
}
|
||||
SimpleSubRetryQueue.getInstance().offer(loaderUtil);
|
||||
@@ -143,6 +150,10 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
* 2、completeNum + failNum + stopNum = subSize,则认为组合任务停止
|
||||
*/
|
||||
private synchronized void handleStop(AbsSubDLoadUtil loadUtil, long curLocation) {
|
||||
Log.d(TAG, String.format("handleStop, size = %s, completeNum = %s, failNum = %s, stopNum = %s",
|
||||
mGState.getSubSize(), mGState.getCompleteNum(), mGState.getFailNum(),
|
||||
mGState.getSubSize()));
|
||||
|
||||
mGState.listener.onSubStop(loadUtil.getEntity(), curLocation);
|
||||
mGState.countStopNum(loadUtil.getKey());
|
||||
if (mGState.getStopNum() == mGState.getSubSize()
|
||||
@@ -151,12 +162,11 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
+ mGState.getFailNum()
|
||||
+ mQueue.getCacheSize()
|
||||
== mGState.getSubSize()) {
|
||||
mQueue.clear();
|
||||
mGState.isRunning.set(false);
|
||||
mGState.listener.onStop(mGState.getProgress());
|
||||
} else {
|
||||
startNext();
|
||||
return;
|
||||
}
|
||||
startNext();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,32 +179,37 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
*/
|
||||
private synchronized void handleComplete(AbsSubDLoadUtil loader) {
|
||||
ALog.d(TAG, String.format("子任务【%s】完成", loader.getEntity().getFileName()));
|
||||
if (loader.getRecord().isBlock) {
|
||||
Log.d(TAG,
|
||||
String.format("handleComplete, size = %s, completeNum = %s, failNum = %s, stopNum = %s",
|
||||
mGState.getSubSize(), mGState.getCompleteNum(), mGState.getFailNum(),
|
||||
mGState.getSubSize()));
|
||||
|
||||
TaskRecord record = loader.getRecord();
|
||||
if (record != null && record.isBlock) {
|
||||
File partFile =
|
||||
new File(String.format(IRecordHandler.SUB_PATH, loader.getRecord().filePath, 0));
|
||||
partFile.renameTo(new File(loader.getRecord().filePath));
|
||||
new File(String.format(IRecordHandler.SUB_PATH, record.filePath, 0));
|
||||
partFile.renameTo(new File(record.filePath));
|
||||
}
|
||||
ThreadTaskManager.getInstance().removeTaskThread(loader.getKey());
|
||||
mGState.listener.onSubComplete(loader.getEntity());
|
||||
mQueue.removeTaskFromExecQ(loader);
|
||||
mGState.updateCompleteNum();
|
||||
ALog.d(TAG, String.format("总任务数:%s,完成的任务数:%s,失败的任务数:%s,停止的任务数:%s", mGState.getSubSize(),
|
||||
mGState.getCompleteNum(), mGState.getFailNum(), mGState.getStopNum()));
|
||||
if (mGState.getCompleteNum() + mGState.getFailNum() + mGState.getStopNum()
|
||||
== mGState.getSubSize()) {
|
||||
if (mGState.getStopNum() == 0 && mGState.getFailNum() == 0) {
|
||||
mGState.listener.onComplete();
|
||||
} else if(mGState.getStopNum() == 0&&!Configuration.getInstance().dGroupCfg.isSubFailAsStop() ){
|
||||
mGState.listener.onFail(false, new AriaException(TAG,
|
||||
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
|
||||
} else if (mGState.getStopNum() == 0
|
||||
&& !Configuration.getInstance().dGroupCfg.isSubFailAsStop()) {
|
||||
mGState.listener.onFail(false,
|
||||
ExceptionFactory.getException(ExceptionFactory.TYPE_GROUP,
|
||||
String.format("任务组【%s】下载失败", mGState.getGroupHash()), null));
|
||||
} else {
|
||||
mGState.listener.onStop(mGState.getProgress());
|
||||
}
|
||||
mQueue.clear();
|
||||
mGState.isRunning.set(false);
|
||||
} else {
|
||||
startNext();
|
||||
return;
|
||||
}
|
||||
startNext();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,8 +223,8 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
if (next != null) {
|
||||
ALog.d(TAG, String.format("启动任务:%s", next.getEntity().getFileName()));
|
||||
mQueue.startTask(next);
|
||||
} else {
|
||||
ALog.i(TAG, "没有下一子任务");
|
||||
return;
|
||||
}
|
||||
ALog.i(TAG, "没有下一子任务");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ import com.arialyy.aria.util.CommonUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 组合任务队列,该队列生命周期和{@link AbsGroupLoaderUtil}生命周期一致
|
||||
@@ -34,11 +34,11 @@ final class SimpleSubQueue implements ISubQueue<AbsSubDLoadUtil> {
|
||||
/**
|
||||
* 缓存下载器
|
||||
*/
|
||||
private Map<String, AbsSubDLoadUtil> mCache = new LinkedHashMap<>();
|
||||
private Map<String, AbsSubDLoadUtil> mCache = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* 执行中的下载器
|
||||
*/
|
||||
private Map<String, AbsSubDLoadUtil> mExec = new LinkedHashMap<>();
|
||||
private Map<String, AbsSubDLoadUtil> mExec = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 最大执行任务数
|
||||
@@ -85,12 +85,13 @@ final class SimpleSubQueue implements ISubQueue<AbsSubDLoadUtil> {
|
||||
if (mExec.size() < mExecSize) {
|
||||
mCache.remove(fileer.getKey());
|
||||
mExec.put(fileer.getKey(), fileer);
|
||||
ALog.d(TAG, String.format("开始执行子任务:%s", fileer.getEntity().getFileName()));
|
||||
ALog.d(TAG,
|
||||
String.format("开始执行子任务:%s,key: %s", fileer.getEntity().getFileName(), fileer.getKey()));
|
||||
fileer.run();
|
||||
} else {
|
||||
ALog.d(TAG, String.format("执行队列已满,任务进入缓存器中,key: %s", fileer.getKey()));
|
||||
addTask(fileer);
|
||||
return;
|
||||
}
|
||||
ALog.d(TAG, String.format("执行队列已满,任务进入缓存器中,key: %s", fileer.getKey()));
|
||||
addTask(fileer);
|
||||
}
|
||||
|
||||
@Override public void stopTask(AbsSubDLoadUtil fileer) {
|
||||
@@ -144,15 +145,16 @@ final class SimpleSubQueue implements ISubQueue<AbsSubDLoadUtil> {
|
||||
addTask(t);
|
||||
}
|
||||
}
|
||||
} else { // 处理队列变大的情况,该情况下将增加任务
|
||||
if (mExec.size() < num) {
|
||||
for (int i = 0; i < diff; i++) {
|
||||
AbsSubDLoadUtil next = getNextTask();
|
||||
if (next != null) {
|
||||
startTask(next);
|
||||
} else {
|
||||
ALog.d(TAG, "子任务中没有缓存任务");
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 处理队列变大的情况,该情况下将增加任务
|
||||
if (mExec.size() < num) {
|
||||
for (int i = 0; i < diff; i++) {
|
||||
AbsSubDLoadUtil next = getNextTask();
|
||||
if (next != null) {
|
||||
startTask(next);
|
||||
} else {
|
||||
ALog.d(TAG, "子任务中没有缓存任务");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.arialyy.aria.core.listener;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.inf.TaskSchedulerType;
|
||||
@@ -125,7 +124,7 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
|
||||
if (e != null) {
|
||||
String error = ALog.getExceptionString(e);
|
||||
ALog.e(TAG, error);
|
||||
ErrorHelp.saveError(e.getTag(), e.getMessage(), error);
|
||||
ErrorHelp.saveError(e.getMessage(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class DownloadGroupListener
|
||||
sendInState2Target(ISchedulers.SUB_FAIL, subEntity);
|
||||
if (e != null) {
|
||||
e.printStackTrace();
|
||||
ErrorHelp.saveError(e.getTag(), "", ALog.getExceptionString(e));
|
||||
ErrorHelp.saveError("", ALog.getExceptionString(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,11 @@ public final class SubLoader implements ILoader, ILoaderVisitor {
|
||||
}
|
||||
|
||||
record = recordHandler.getRecord(wrapper.getEntity().getFileSize());
|
||||
if (record == null) {
|
||||
ALog.d(TAG, "子任务记录为空");
|
||||
sendFailState(false);
|
||||
return;
|
||||
}
|
||||
if (record.threadRecords != null
|
||||
&& !TextUtils.isEmpty(record.filePath)
|
||||
&& new File(record.filePath).exists()
|
||||
@@ -163,9 +168,9 @@ public final class SubLoader implements ILoader, ILoaderVisitor {
|
||||
for (IThreadTask iThreadTask : mTask) {
|
||||
iThreadTask.call();
|
||||
}
|
||||
} else {
|
||||
ALog.e(TAG, "子任务的线程任务为空");
|
||||
return;
|
||||
}
|
||||
ALog.e(TAG, "子任务的线程任务为空");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -258,9 +263,9 @@ public final class SubLoader implements ILoader, ILoaderVisitor {
|
||||
}
|
||||
if (needGetInfo) {
|
||||
infoTask.run();
|
||||
} else {
|
||||
handlerTask();
|
||||
return;
|
||||
}
|
||||
handlerTask();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,8 +27,9 @@ public interface IBandWidthUrlConverter extends IEventHandler {
|
||||
* 转换码率地址为可用的http地址,对于某些服务器,返回的切片信息有可能是相对地址,也可能是处理过的,
|
||||
* 对于这种情况,你需要使用url转换器将地址转换为可正常访问的http地址
|
||||
*
|
||||
* @param m3u8Url m3u8url地址
|
||||
* @param bandWidthUrl 原始码率地址
|
||||
* @return 可正常访问的http地址
|
||||
*/
|
||||
String convert(String bandWidthUrl);
|
||||
String convert(String m3u8Url, String bandWidthUrl);
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ public interface ILiveTsUrlConverter extends IEventHandler {
|
||||
* @param tsUrl ts文件下载地址
|
||||
* @return 转换后的http地址
|
||||
*/
|
||||
public String convert(String m3u8Url, String tsUrl);
|
||||
String convert(String m3u8Url, String tsUrl);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.ThreadRecord;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
@@ -259,16 +258,15 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
if (mTaskWrapper.getRequestType() == ITaskWrapper.M3U8_VOD) {
|
||||
writeConfig(false, getConfig().tempFile.length());
|
||||
ALog.i(TAG, String.format("任务【%s】已停止", getFileName()));
|
||||
} else {
|
||||
if (mTaskWrapper.isSupportBP()) {
|
||||
ALog.d(TAG,
|
||||
String.format("任务【%s】thread__%s__停止【当前线程停止位置:%s】", getFileName(),
|
||||
mRecord.threadId, stopLocation));
|
||||
writeConfig(false, stopLocation);
|
||||
} else {
|
||||
ALog.i(TAG, String.format("任务【%s】已停止", getFileName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mTaskWrapper.isSupportBP()) {
|
||||
ALog.d(TAG, String.format("任务【%s】thread__%s__停止【当前线程停止位置:%s】", getFileName(),
|
||||
mRecord.threadId, stopLocation));
|
||||
writeConfig(false, stopLocation);
|
||||
return;
|
||||
}
|
||||
ALog.i(TAG, String.format("任务【%s】已停止", getFileName()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,16 +402,18 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
if (mTaskWrapper.getRequestType() == ITaskWrapper.M3U8_VOD) {
|
||||
writeConfig(false, 0);
|
||||
retryM3U8Peer(needRetry);
|
||||
} else {
|
||||
if (mTaskWrapper.isSupportBP()) {
|
||||
writeConfig(false, subCurrentLocation);
|
||||
retryBlockTask(needRetry && mConfig.startThreadNum != 1);
|
||||
} else {
|
||||
ALog.e(TAG, String.format("任务【%s】执行失败", getFileName()));
|
||||
ErrorHelp.saveError(TAG, "", ALog.getExceptionString(ex));
|
||||
sendFailMsg(null, needRetry);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mTaskWrapper.isSupportBP()) {
|
||||
writeConfig(false, subCurrentLocation);
|
||||
retryBlockTask(needRetry);
|
||||
return;
|
||||
}
|
||||
|
||||
ALog.e(TAG, String.format("任务【%s】执行失败", getFileName()));
|
||||
ErrorHelp.saveError("", ALog.getExceptionString(ex));
|
||||
sendFailMsg(null, needRetry);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,9 +434,9 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
FileUtil.deleteFile(mConfig.tempFile);
|
||||
FileUtil.createFile(mConfig.tempFile);
|
||||
ThreadTaskManager.getInstance().retryThread(this);
|
||||
} else {
|
||||
sendFailMsg(null, false);
|
||||
return;
|
||||
}
|
||||
sendFailMsg(null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,10 +456,10 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
mFailTimes++;
|
||||
handleBlockRecord();
|
||||
ThreadTaskManager.getInstance().retryThread(this);
|
||||
} else {
|
||||
ALog.e(TAG, String.format("任务【%s】执行失败", getFileName()));
|
||||
sendFailMsg(null, needRetry);
|
||||
return;
|
||||
}
|
||||
ALog.e(TAG, String.format("任务【%s】执行失败", getFileName()));
|
||||
sendFailMsg(null, needRetry);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,10 +511,8 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
b.putBoolean(IThreadStateManager.DATA_RETRY, needRetry);
|
||||
if (e != null) {
|
||||
b.putSerializable(IThreadStateManager.DATA_ERROR_INFO, e);
|
||||
updateState(IThreadStateManager.STATE_FAIL, b);
|
||||
} else {
|
||||
updateState(IThreadStateManager.STATE_FAIL, b);
|
||||
}
|
||||
updateState(IThreadStateManager.STATE_FAIL, b);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,20 +17,12 @@ package com.arialyy.aria.exception;
|
||||
|
||||
public class AriaException extends Exception {
|
||||
|
||||
private String tag;
|
||||
|
||||
public AriaException(String tag, String message) {
|
||||
public AriaException(String message) {
|
||||
super(message);
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public AriaException(String tag, String message, Exception e) {
|
||||
super(String.format("%s, %s\n%s", tag, message == null ? "" : message,
|
||||
public AriaException(String message, Exception e) {
|
||||
super(String.format("%s\n%s", message == null ? "" : message,
|
||||
e == null ? "" : e.getMessage()));
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ package com.arialyy.aria.exception;
|
||||
public class AriaFTPException extends AriaException {
|
||||
private static final String FTP_EXCEPTION = "Aria FTP Exception:";
|
||||
|
||||
public AriaFTPException(String tag, String message) {
|
||||
super(tag, String.format("%s\n%s", FTP_EXCEPTION, message));
|
||||
public AriaFTPException(String message) {
|
||||
super(String.format("%s\n%s", FTP_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaFTPException(String tag, String message, Exception e) {
|
||||
super(tag, message, e);
|
||||
public AriaFTPException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.aria.exception;
|
||||
|
||||
public class AriaGroupException extends AriaException {
|
||||
private static final String FTP_EXCEPTION = "Aria Group Exception:";
|
||||
|
||||
public AriaGroupException(String message) {
|
||||
super(String.format("%s\n%s", FTP_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaGroupException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,11 @@ package com.arialyy.aria.exception;
|
||||
public class AriaHTTPException extends AriaException {
|
||||
private static final String HTTP_EXCEPTION = "Aria HTTP Exception:";
|
||||
|
||||
public AriaHTTPException(String tag, String message) {
|
||||
super(tag, String.format("%s\n%s", HTTP_EXCEPTION, message));
|
||||
public AriaHTTPException( String message) {
|
||||
super(String.format("%s\n%s", HTTP_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaHTTPException(String tag, String message, Exception e) {
|
||||
super(tag, message, e);
|
||||
public AriaHTTPException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ package com.arialyy.aria.exception;
|
||||
public class AriaM3U8Exception extends AriaException {
|
||||
private static final String M3U8_EXCEPTION = "Aria M3U8 Exception:";
|
||||
|
||||
public AriaM3U8Exception(String tag, String message) {
|
||||
super(tag, String.format("%s\n%s", M3U8_EXCEPTION, message));
|
||||
public AriaM3U8Exception(String message) {
|
||||
super(String.format("%s\n%s", M3U8_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaM3U8Exception(String tag, String message, Exception e){
|
||||
super(tag, message, e);
|
||||
public AriaM3U8Exception(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ package com.arialyy.aria.exception;
|
||||
public class AriaSFTPException extends AriaException {
|
||||
private static final String SFTP_EXCEPTION = "Aria SFTP Exception:";
|
||||
|
||||
public AriaSFTPException(String tag, String message) {
|
||||
super(tag, String.format("%s\n%s", SFTP_EXCEPTION, message));
|
||||
public AriaSFTPException(String message) {
|
||||
super(String.format("%s\n%s", SFTP_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaSFTPException(String tag, String message, Exception e) {
|
||||
super(tag, message, e);
|
||||
public AriaSFTPException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.aria.exception;
|
||||
|
||||
public class ExceptionFactory {
|
||||
public static final int TYPE_FTP = 1;
|
||||
public static final int TYPE_HTTP = 2;
|
||||
public static final int TYPE_M3U8 = 3;
|
||||
public static final int TYPE_SFTP = 4;
|
||||
public static final int TYPE_GROUP = 5;
|
||||
|
||||
public static AriaException getException(int type, String msg, Exception e) {
|
||||
switch (type) {
|
||||
case TYPE_FTP: {
|
||||
return e == null ? new AriaFTPException(msg) : new AriaFTPException(msg, e);
|
||||
}
|
||||
case TYPE_HTTP: {
|
||||
return e == null ? new AriaHTTPException(msg) : new AriaHTTPException(msg, e);
|
||||
}
|
||||
case TYPE_M3U8: {
|
||||
return e == null ? new AriaM3U8Exception(msg) : new AriaM3U8Exception(msg, e);
|
||||
}
|
||||
case TYPE_SFTP: {
|
||||
return e == null ? new AriaSFTPException(msg) : new AriaSFTPException(msg, e);
|
||||
}
|
||||
case TYPE_GROUP: {
|
||||
return e == null ? new AriaGroupException(msg) : new AriaGroupException(msg, e);
|
||||
}
|
||||
}
|
||||
return e == null ? new AriaException(msg) : new AriaException(msg, e);
|
||||
}
|
||||
}
|
||||
@@ -171,8 +171,11 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
|
||||
private void createDbCacheDir() {
|
||||
String cacheDir = mContext.getCacheDir().getPath() + "/AriaDbCacheDir";
|
||||
boolean rs = new File(cacheDir).mkdir();
|
||||
ALog.d(TAG, rs + "");
|
||||
File cacheFile = new File(cacheDir);
|
||||
if (!cacheFile.exists()){
|
||||
boolean rs = cacheFile.mkdirs();
|
||||
ALog.d(TAG, rs + "");
|
||||
}
|
||||
super.getReadableDatabase()
|
||||
.execSQL("PRAGMA temp_store_directory = '" + cacheDir + "'");
|
||||
mainTmpDirSet = true;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class AriaCrashHandler implements Thread.UncaughtExceptionHandler {
|
||||
mExecutorService.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ErrorHelp.saveError(name, "", ALog.getExceptionString(ex));
|
||||
ErrorHelp.saveError("", ALog.getExceptionString(ex));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ public class DeleteDRecord implements IDeleteRecord {
|
||||
private String TAG = CommonUtil.getClassName(this);
|
||||
private static volatile DeleteDRecord INSTANCE = null;
|
||||
|
||||
private DeleteDRecord(){
|
||||
private DeleteDRecord() {
|
||||
|
||||
}
|
||||
|
||||
public static DeleteDRecord getInstance() {
|
||||
if (INSTANCE == null){
|
||||
synchronized (DeleteDRecord.class){
|
||||
if (INSTANCE == null){
|
||||
if (INSTANCE == null) {
|
||||
synchronized (DeleteDRecord.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new DeleteDRecord();
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,8 @@ public class DeleteDRecord implements IDeleteRecord {
|
||||
File targetFile = new File(filePath);
|
||||
|
||||
// 兼容以前版本
|
||||
if (entity.getTaskType() == ITaskWrapper.M3U8_VOD || entity.getTaskType() == ITaskWrapper.M3U8_LIVE){
|
||||
if (entity.getTaskType() == ITaskWrapper.M3U8_VOD
|
||||
|| entity.getTaskType() == ITaskWrapper.M3U8_LIVE) {
|
||||
DeleteM3u8Record.getInstance().deleteRecord(entity, needRemoveFile, needRemoveEntity);
|
||||
return;
|
||||
}
|
||||
@@ -92,13 +93,18 @@ public class DeleteDRecord implements IDeleteRecord {
|
||||
TaskRecord record = DbDataHelper.getTaskRecord(entity.getFilePath(), entity.getTaskType());
|
||||
if (record == null) {
|
||||
ALog.e(TAG, "删除下载记录失败,记录为空,filePath:" + entity.getFilePath());
|
||||
FileUtil.deleteFile(targetFile);
|
||||
DbEntity.deleteData(DownloadEntity.class, "downloadPath=?", filePath);
|
||||
return;
|
||||
}
|
||||
|
||||
// 删除下载的线程记录和任务记录
|
||||
DbEntity.deleteData(ThreadRecord.class, "taskKey=? AND threadType=?", filePath,
|
||||
String.valueOf(entity.getTaskType()));
|
||||
DbEntity.deleteData(TaskRecord.class, "filePath=? AND taskType=?", filePath,
|
||||
String.valueOf(entity.getTaskType()));
|
||||
|
||||
if (needRemoveEntity || !entity.isComplete()) {
|
||||
if (needRemoveFile || !entity.isComplete()) {
|
||||
FileUtil.deleteFile(targetFile);
|
||||
if (record.isBlock) {
|
||||
removeBlockFile(record);
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.arialyy.aria.util;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.TaskRecord;
|
||||
import com.arialyy.aria.core.ThreadRecord;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.M3U8Entity;
|
||||
@@ -82,6 +83,11 @@ public class DeleteM3u8Record implements IDeleteRecord {
|
||||
}
|
||||
final String filePath = entity.getFilePath();
|
||||
|
||||
// 删除下载的线程记录和任务记录
|
||||
DbEntity.deleteData(ThreadRecord.class, "taskKey=? AND threadType=?", filePath,
|
||||
String.valueOf(entity.getTaskType()));
|
||||
DbEntity.deleteData(TaskRecord.class, "filePath=? AND taskType=?", filePath,
|
||||
String.valueOf(entity.getTaskType()));
|
||||
DbEntity.deleteData(M3U8Entity.class, "filePath=?", filePath);
|
||||
|
||||
if (needRemoveFile || !entity.isComplete()) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.arialyy.aria.util;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.TaskRecord;
|
||||
import com.arialyy.aria.core.ThreadRecord;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
@@ -76,6 +77,10 @@ public class DeleteURecord implements IDeleteRecord {
|
||||
}
|
||||
|
||||
UploadEntity entity = (UploadEntity) absEntity;
|
||||
|
||||
// 删除下载的线程记录和任务记录
|
||||
DbEntity.deleteData(ThreadRecord.class, "taskKey=? AND threadType=?", entity.getFilePath(),
|
||||
String.valueOf(entity.getTaskType()));
|
||||
DbEntity.deleteData(TaskRecord.class, "filePath=? AND taskType=?", entity.getFilePath(),
|
||||
String.valueOf(entity.getTaskType()));
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.annotation.SuppressLint;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -36,8 +35,8 @@ public class ErrorHelp {
|
||||
* @param msg 错误提示
|
||||
* @param ex 异常
|
||||
*/
|
||||
public static void saveError(String tag, String msg, String ex) {
|
||||
writeLogToFile(tag, String.format("\nmsg【%s】\nException:%s", msg, ex));
|
||||
public static void saveError(String msg, String ex) {
|
||||
writeLogToFile(String.format("\nmsg【%s】\nException:%s", msg, ex));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,12 +56,10 @@ public class ErrorHelp {
|
||||
/**
|
||||
* 把日志记录到文件
|
||||
*/
|
||||
private static int writeLogToFile(String tag, String message) {
|
||||
private static int writeLogToFile(String message) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(getData("yyyy-MM-dd HH:mm:ss"));
|
||||
stringBuffer.append(" ");
|
||||
stringBuffer.append(tag);
|
||||
stringBuffer.append(" ");
|
||||
stringBuffer.append(message);
|
||||
stringBuffer.append("\n\n");
|
||||
PrintWriter writer = null;
|
||||
|
||||
37
README.md
37
README.md
@@ -45,19 +45,19 @@ Aria有以下特点:
|
||||
|
||||
## 引入库
|
||||
[](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
|
||||
|
||||
```java
|
||||
implementation 'com.arialyy.aria:core:3.8.7'
|
||||
annotationProcessor 'com.arialyy.aria:compiler:3.8.7'
|
||||
implementation 'com.arialyy.aria:ftpComponent:3.8.7' # 如果需要使用ftp,请增加该组件
|
||||
implementation 'com.arialyy.aria:sftpComponent:3.8.7' # 如果需要使用ftp,请增加该组件
|
||||
implementation 'com.arialyy.aria:m3u8Component:3.8.7' # 如果需要使用m3u8下载功能,请增加该组件
|
||||
implementation 'com.arialyy.aria:core:3.8.10'
|
||||
annotationProcessor 'com.arialyy.aria:compiler:3.8.10'
|
||||
implementation 'com.arialyy.aria:ftpComponent:3.8.10' # 如果需要使用ftp,请增加该组件
|
||||
implementation 'com.arialyy.aria:sftpComponent:3.8.10' # 如果需要使用ftp,请增加该组件
|
||||
implementation 'com.arialyy.aria:m3u8Component:3.8.10' # 如果需要使用m3u8下载功能,请增加该组件
|
||||
```
|
||||
|
||||
如果你使用的是kotlin,请使用kotlin官方提供的方法配置apt,[kotlin kapt官方配置传送门](https://www.kotlincn.net/docs/reference/kapt.html)
|
||||
@@ -138,17 +138,10 @@ protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
||||
### 版本日志
|
||||
+ v_3.8.7 (2020/5/25)
|
||||
- 修复组合任务单个子任务失败后,重新恢复组合任务,组合任务状态变为完成的问题
|
||||
- 修复40x错误,会继续重试并且无法重试成功的问题 https://github.com/AriaLyy/Aria/issues/619
|
||||
- 修复wait模式下,resume(true)无效问题
|
||||
- 修复now模式下的一些问题 https://github.com/AriaLyy/Aria/issues/620
|
||||
- 修复组任务,其中一个子任务在获取文件长度失败后,重新恢复组合任务,组合任务状态变为完成的问题 https://github.com/AriaLyy/Aria/issues/628
|
||||
- 修复组任务中,其中一个子任务是30x地址,导致调度器无法出现该子任务状态的问题
|
||||
- 增加组任务groupHash冲突检查 https://github.com/AriaLyy/Aria/issues/635
|
||||
- 修复task.cancel(false)还是把本地文件删除的问题 https://github.com/AriaLyy/Aria/issues/646
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/670
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/664
|
||||
+ 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
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/695
|
||||
|
||||
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
||||
|
||||
@@ -178,7 +171,7 @@ protected void onCreate(Bundle savedInstanceState) {
|
||||
在提交问题前,希望你已经查看过[wiki](https://aria.laoyuyu.me/aria_doc/)或搜索过[issues](https://github.com/AriaLyy/Aria/issues)。</br>
|
||||
|
||||
## 打赏
|
||||
如果觉得框架写的不错并且帮助到了你,可以请我喝杯热茶。`^_^`</br>
|
||||
如果觉得框架写的不错并且帮助到了你,可以请我瓶快乐水。`^_^`</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/>
|
||||
|
||||
|
||||
@@ -54,11 +54,11 @@ public abstract class AbsSFtpInfoTask<WP extends AbsTaskWrapper> implements IInf
|
||||
}
|
||||
getFileInfo(session);
|
||||
} catch (JSchException e) {
|
||||
fail(new AriaSFTPException(TAG, "jsch错误", e), false);
|
||||
fail(new AriaSFTPException("jsch错误", e), false);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
|
||||
fail(new AriaSFTPException("字符编码错误", e), false);
|
||||
} catch (SftpException e) {
|
||||
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
|
||||
fail(new AriaSFTPException("sftp错误,错误类型:" + e.id, e), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ final class SFtpDInfoTask extends AbsSFtpInfoTask<DTaskWrapper> {
|
||||
callback.onSucceed(getWrapper().getKey(), info);
|
||||
} else {
|
||||
callback.onFail(getWrapper().getEntity(),
|
||||
new AriaSFTPException(TAG, String.format("文件不存在,remotePath:%s", remotePath)), false);
|
||||
new AriaSFTPException(String.format("文件不存在,remotePath:%s", remotePath)), false);
|
||||
}
|
||||
channel.disconnect();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ final class SFtpDThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
|
||||
@Override protected void handlerThreadTask() {
|
||||
if (session == null) {
|
||||
fail(new AriaSFTPException(TAG, "session 为空"), false);
|
||||
fail(new AriaSFTPException("session 为空"), false);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -74,13 +74,13 @@ final class SFtpDThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
CommonUtil.convertSFtpChar(charSet, option.getUrlEntity().remotePath);
|
||||
download(remotePath);
|
||||
} catch (SftpException e) {
|
||||
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
|
||||
fail(new AriaSFTPException("sftp错误,错误类型:" + e.id, e), false);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
|
||||
fail(new AriaSFTPException("字符编码错误", e), false);
|
||||
} catch (IOException e) {
|
||||
fail(new AriaSFTPException(TAG, "", e), true);
|
||||
fail(new AriaSFTPException("", e), true);
|
||||
} catch (JSchException e) {
|
||||
fail(new AriaSFTPException(TAG, "jsch 错误", e), false);
|
||||
fail(new AriaSFTPException("jsch 错误", e), false);
|
||||
} finally {
|
||||
channelSftp.disconnect();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ final class SFtpUThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
|
||||
@Override protected void handlerThreadTask() {
|
||||
if (session == null) {
|
||||
fail(new AriaSFTPException(TAG, "session 为空"), false);
|
||||
fail(new AriaSFTPException("session 为空"), false);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -75,13 +75,13 @@ final class SFtpUThreadTaskAdapter extends AbsThreadTaskAdapter {
|
||||
channelSftp.cd(remotePath);
|
||||
upload(remotePath);
|
||||
} catch (SftpException e) {
|
||||
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
|
||||
fail(new AriaSFTPException("sftp错误,错误类型:" + e.id, e), false);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
|
||||
fail(new AriaSFTPException("字符编码错误", e), false);
|
||||
} catch (IOException e) {
|
||||
fail(new AriaSFTPException(TAG, "", e), true);
|
||||
fail(new AriaSFTPException("", e), true);
|
||||
} catch (JSchException e) {
|
||||
fail(new AriaSFTPException(TAG, "jsch 错误", e), false);
|
||||
fail(new AriaSFTPException("jsch 错误", e), false);
|
||||
} finally {
|
||||
channelSftp.disconnect();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<download>
|
||||
|
||||
<!--设置任务最大下载速度,0表示不限速,单位为:kb-->
|
||||
<maxSpeed value="0"/>
|
||||
<maxSpeed value="128"/>
|
||||
|
||||
<!--
|
||||
多线程下载是否使用块下载模式,{@code true}使用,{@code false}不使用
|
||||
@@ -41,10 +41,10 @@
|
||||
3、从3.4.1开始,如果线程数为1,文件初始化时将不再预占用对应长度的空间,下载多少byte,则占多大的空间;
|
||||
对于采用多线程的任务或旧任务,依然采用原来的文件空间占用方式;
|
||||
-->
|
||||
<threadNum value="3"/>
|
||||
<threadNum value="1"/>
|
||||
|
||||
<!--设置下载队列最大任务数, 默认为2-->
|
||||
<maxTaskNum value="2"/>
|
||||
<maxTaskNum value="1"/>
|
||||
|
||||
<!--设置下载失败,重试次数,默认为10-->
|
||||
<reTryNum value="5"/>
|
||||
@@ -68,7 +68,7 @@
|
||||
<convertSpeed value="true"/>
|
||||
|
||||
<!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait-->
|
||||
<queueMod value="now"/>
|
||||
<queueMod value="wait"/>
|
||||
|
||||
<!--进度更新更新间隔,默认1000毫秒-->
|
||||
<updateInterval value="1000"/>
|
||||
|
||||
@@ -55,10 +55,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://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://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://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";
|
||||
|
||||
@@ -118,7 +118,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
}
|
||||
|
||||
@Override public void cancel(View v, AbsEntity entity) {
|
||||
Aria.download(this).load(mTaskId).cancel(true);
|
||||
Aria.download(this).load(mTaskId).cancel(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -159,7 +159,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
}
|
||||
if (speed > -1) {
|
||||
msg = item.getTitle().toString();
|
||||
Aria.download(this).setMaxSpeed(speed);
|
||||
T.showShort(this, msg);
|
||||
}
|
||||
return true;
|
||||
@@ -191,7 +190,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
@Download.onTaskRunning
|
||||
protected void running(DownloadTask task) {
|
||||
if (task.getKey().equals(mUrl)) {
|
||||
ALog.d(TAG, "isRunning" + "; state = " + task.getEntity().getState());
|
||||
//ALog.d(TAG, "isRunning" + "; state = " + task.getEntity().getState());
|
||||
getBinding().pl.setInfo(task.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.arialyy.simple.core.download.group;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.arialyy.annotations.DownloadGroup;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
@@ -82,6 +83,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
||||
//.setFileSize(114981416)
|
||||
//.updateUrls(temp)
|
||||
.create();
|
||||
Log.d(TAG, "taskId = " + mTaskId);
|
||||
}
|
||||
|
||||
@Override public void stop(View v, AbsEntity entity) {
|
||||
|
||||
@@ -32,19 +32,9 @@ public class GroupModule extends BaseModule {
|
||||
|
||||
public List<String> getUrls() {
|
||||
List<String> urls = new ArrayList<>();
|
||||
//String[] str = getContext().getResources().getStringArray(R.array.group_urls_1);
|
||||
//Collections.addAll(urls, str);
|
||||
//urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-9/fr/cp0/e15/q65/85148967_168821394550033_6164348723502514176_n.jpg?_nc_cat=105&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQni9wIDOcxkQGfqH7jFwLuRWV3cIi0We11MXp1V0_vfrQ3-SBV4Ue034aJXzzIzdNI&_nc_ht=scontent-hkt1-1.xx&_nc_tp=14&oh=37829bbfd4f7179fcc3527a7a7971f53&oe=5F00FC35");
|
||||
//urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/84206444_168821471216692_7979166053252988928_n.jpg?_nc_cat=106&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQny1ZTkxw-sq4mSH2TThaQNRJB89uKG2cW9e3DgcI78qXE7b8Jlyox749lXkcngYBs&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=6714e2c9b3d76e12eff960b6aa22cdfb&oe=5EEE640F");
|
||||
//urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/86702402_168821534550019_6064732312896012288_n.jpg?_nc_cat=101&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQnfJfW55cqVfs0lzZOjEa8kGoxvrA--\\brjaelZgcf8MzqQUhjH3moqGoekMQlATXRM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=96f4f776c05b2c200cfb720fa36f938b&oe=5EFA310D");
|
||||
//urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/85236032_168821577883348_2800973234302877696_n.jpg?_nc_cat=106&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQlNvaTlYUspquMWBLnkgVOHdzG4pX2XW3NSHYxvVYsaJF8Ehy9tGn6R6Ned5UwcwAM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=6fd5e6442712e4da111d09e8902c68c5&oe=5EFE1528");
|
||||
//urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-1/cp0/e15/q65/p120x120/80398195_141232180642288_3692820603451998208_n.jpg?_nc_cat=109&_nc_sid=dbb9e7&efg=eyJpIjoidCJ9&_nc_oc=AQmsZxgvLgoObkqHbcKS8qIZ3w_QhssRwLSF5o-8P6q_kf962w32kmjLqcg6lH9qxWI&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=269e655e7b901e8d07d9362142a0fdda&oe=5EF43734");
|
||||
urls.add(
|
||||
"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");
|
||||
urls.add(
|
||||
"https://scontent-hkt1-1.xx.fbcdn.net/v/t15.5256-10/fr/cp0/e15/q65/83913248_211240646743277_4802581788427812864_n.jpg?_nc_cat=103&_nc_sid=f2c4d5&_nc_oc=AQkT-0QmghK66vtY6tfr01niqxjePFuU-6JAYcAW7MKJoC8MgQDSRXg_iXW6FUZZa3A&_nc_ht=scontent-hkt1-1.xx&_nc_tp=14&oh=6f020a513d181256b98edc3896b1c3c7&oe=5E8FE498");
|
||||
urls.add(
|
||||
"https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-1/cp0/e15/q65/p480x480/75642413_2805764969481542_7020281898245029888_n.jpg?_nc_cat=1&_nc_sid=dbb9e7&_nc_oc=AQmgACYknk9eS0cgeReiSuYuB2qfybLSQwqH98trPB1AFh9dSKXHn7cCcKcKO6YDKdM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=78e0717a056391e1f9c917f290f74aab&oe=5E9433B8");
|
||||
urls.add("http://61.155.99.75:88/sdkdown.muzhiwan.com/openfile/2019/10/26/com.mrxz.mzw_5db3eeef782b1.apk");
|
||||
urls.add("http://cpsdown.muzhiwan.com/2020/05/07/com.kaihei.wufan.mars_5eb3947b4341b.apk");
|
||||
urls.add("http://113.143.35.118:88/sdkdown.muzhiwan.com/openfile/2019/11/27/com.droidhang.ad.mzw_5dde4ffe2b2e5.apk");
|
||||
return urls;
|
||||
}
|
||||
List<String> getUrls1() {
|
||||
@@ -60,9 +50,9 @@ public class GroupModule extends BaseModule {
|
||||
List<String> names = new ArrayList<>();
|
||||
//String[] str = getContext().getResources().getStringArray(R.array.group_names);
|
||||
//Collections.addAll(names, str);
|
||||
names.add("1.mp4");
|
||||
names.add("2.png");
|
||||
names.add("3.png");
|
||||
names.add("末日血战.apk");
|
||||
names.add("开黑三国.apk");
|
||||
names.add("放置奇兵.apk");
|
||||
//names.add("4.png");
|
||||
//names.add("5.png");
|
||||
return names;
|
||||
|
||||
@@ -266,15 +266,10 @@ public class M3U8LiveDLoadActivity extends BaseActivity<ActivityM3u8LiveBinding>
|
||||
}
|
||||
|
||||
static class BandWidthUrlConverter implements IBandWidthUrlConverter {
|
||||
String url;
|
||||
|
||||
BandWidthUrlConverter(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override public String convert(String bandWidthUrl) {
|
||||
int peerIndex = url.lastIndexOf("/");
|
||||
return url.substring(0, peerIndex + 1) + bandWidthUrl;
|
||||
@Override public String convert(String m3u8Url, String bandWidthUrl) {
|
||||
int peerIndex = m3u8Url.lastIndexOf("/");
|
||||
return m3u8Url.substring(0, peerIndex + 1) + bandWidthUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,14 +304,15 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
||||
|
||||
private M3U8VodOption getM3U8Option() {
|
||||
M3U8VodOption option = new M3U8VodOption();
|
||||
option
|
||||
.setBandWidth(200000)
|
||||
//option.setBandWidth(200000);
|
||||
//.generateIndexFile()
|
||||
//.merge(true)
|
||||
.setVodTsUrlConvert(new VodTsUrlConverter());
|
||||
//.setVodTsUrlConvert(new VodTsUrlConverter());
|
||||
//.setMergeHandler(new TsMergeHandler());
|
||||
option.setUseDefConvert(false);
|
||||
option.setKeyUrlConverter(new KeyUrlConverter());
|
||||
option.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl));
|
||||
option.setBandWidthUrlConverter(new BandWidthUrlConverter());
|
||||
option.setUseDefConvert(true);
|
||||
return option;
|
||||
}
|
||||
|
||||
@@ -327,7 +328,8 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
||||
static class VodTsUrlConverter implements IVodTsUrlConverter {
|
||||
@Override public List<String> convert(String m3u8Url, List<String> tsUrls) {
|
||||
Uri uri = Uri.parse(m3u8Url);
|
||||
String parentUrl = "http://devimages.apple.com/iphone/samples/bipbop/gear1/";
|
||||
//String parentUrl = "http://devimages.apple.com/iphone/samples/bipbop/gear1/";
|
||||
String parentUrl = "http://youku.cdn7-okzy.com/20200123/16815_fbe419ed/1000k/hls/";
|
||||
//String parentUrl = "http://" + uri.getHost() + "/gear1/";
|
||||
//int index = m3u8Url.lastIndexOf("/");
|
||||
//String parentUrl = m3u8Url.substring(0, index + 1);
|
||||
@@ -351,15 +353,10 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
||||
|
||||
static class BandWidthUrlConverter implements IBandWidthUrlConverter {
|
||||
|
||||
private String url;
|
||||
|
||||
BandWidthUrlConverter(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override public String convert(String bandWidthUrl) {
|
||||
int index = url.lastIndexOf("/");
|
||||
return url.substring(0, index + 1) + bandWidthUrl;
|
||||
@Override public String convert(String m3u8Url, String bandWidthUrl) {
|
||||
int index = m3u8Url.lastIndexOf("/");
|
||||
return m3u8Url.substring(0, index + 1) + bandWidthUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ public class M3U8VodModule extends BaseViewModule {
|
||||
//private final String defUrl = "https://www.gaoya123.cn/2019/1557993797897.m3u8";
|
||||
// 多码率地址:
|
||||
private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.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";
|
||||
//private final String defUrl = "https://youku.cdn7-okzy.com/20191213/16167_c3592a02/index.m3u8";
|
||||
//private final String defUrl = "http://qn.shytong.cn/b83137769ff6b555/11b0c9970f9a3fa0.mp4.m3u8";
|
||||
|
||||
@@ -157,7 +157,7 @@ public class ProgressLayout extends RelativeLayout implements View.OnClickListen
|
||||
this.currentState = entity.getState();
|
||||
if (entity instanceof AbsNormalEntity) {
|
||||
AbsNormalEntity normalEntity = (AbsNormalEntity) entity;
|
||||
ALog.d(TAG, "fileName = " + ((AbsNormalEntity) entity).getFileName());
|
||||
//ALog.d(TAG, "fileName = " + ((AbsNormalEntity) entity).getFileName());
|
||||
fileName.setText(normalEntity.getFileName());
|
||||
} else if (entity instanceof AbsGroupEntity) {
|
||||
AbsGroupEntity groupEntity = (AbsGroupEntity) entity;
|
||||
|
||||
@@ -44,8 +44,8 @@ task clean(type: Delete) {
|
||||
}
|
||||
|
||||
ext {
|
||||
versionCode = 387
|
||||
versionName = '3.8.7'
|
||||
versionCode = 390
|
||||
versionName = '3.8.10'
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = versionName
|
||||
|
||||
Reference in New Issue
Block a user