laoyuyu 5 years ago
parent 22c81369b5
commit 1e2f52daca
  1. 1
      .gitignore
  2. 6
      AppFrame/build.gradle
  3. 2
      Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
  4. 11
      Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java
  5. 8
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  6. 5
      Aria/src/main/java/com/arialyy/aria/core/common/BaseListener.java
  7. 6
      Aria/src/main/java/com/arialyy/aria/core/common/ftp/FtpTaskConfig.java
  8. 6
      Aria/src/main/java/com/arialyy/aria/core/common/http/HttpTaskConfig.java
  9. 2
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8InfoThread.java
  10. 9
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8TaskConfig.java
  11. 2
      DEV_LOG.md
  12. 2
      README.md
  13. 2
      app/build.gradle
  14. 8
      app/src/main/java/com/arialyy/simple/core/download/FtpDownloadActivity.java
  15. 2
      app/src/main/java/com/arialyy/simple/core/download/FtpDownloadModule.java
  16. 43
      app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
  17. 5
      app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java
  18. 4
      app/src/main/java/com/arialyy/simple/core/download/mutil/MultiDownloadActivity.java
  19. 15
      py/.vscode/launch.json
  20. 6
      py/.vscode/settings.json
  21. 26
      py/TcpDownload.py
  22. 7
      py/download.py

1
.gitignore vendored

@ -16,3 +16,4 @@
*.log *.log
uml uml
*.swp *.swp
py/.history

@ -24,11 +24,11 @@ android {
} }
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) api fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', { androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
testCompile 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
api 'androidx.appcompat:appcompat:1.0.2' api 'androidx.appcompat:appcompat:1.0.2'
api 'com.google.code.gson:gson:2.8.2' api 'com.google.code.gson:gson:2.8.2'
api 'io.reactivex:rxandroid:1.2.0' api 'io.reactivex:rxandroid:1.2.0'

@ -200,7 +200,7 @@ import org.xml.sax.SAXException;
Class[] clazzs = new Class[] { Class[] clazzs = new Class[] {
DownloadEntity.class, UploadEntity.class, DownloadGroupEntity.class DownloadEntity.class, UploadEntity.class, DownloadGroupEntity.class
}; };
String sql = "UPDATE %s SET state=2 WHERE state IN (3,4,5,6)"; String sql = "UPDATE %s SET state=2 WHERE state IN (4,5,6)";
for (Class clazz : clazzs) { for (Class clazz : clazzs) {
if (!mDbWrapper.tableExists(clazz)) { if (!mDbWrapper.tableExists(clazz)) {
continue; continue;

@ -5,6 +5,7 @@ import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupEntity; import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.AbsTaskWrapper; import com.arialyy.aria.core.inf.AbsTaskWrapper;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
@ -104,7 +105,11 @@ final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
*/ */
private void resumeWaitTask() { private void resumeWaitTask() {
int maxTaskNum = mQueue.getMaxTaskNum(); int maxTaskNum = mQueue.getMaxTaskNum();
if (mWaitList == null || mWaitList.isEmpty()) return; if (mWaitList == null || mWaitList.isEmpty()) {
return;
}
List<AbsEntity> resumeEntities = new ArrayList<>();
for (AbsTaskWrapper te : mWaitList) { for (AbsTaskWrapper te : mWaitList) {
if (te instanceof DTaskWrapper) { if (te instanceof DTaskWrapper) {
mQueue = DownloadTaskQueue.getInstance(); mQueue = DownloadTaskQueue.getInstance();
@ -119,7 +124,11 @@ final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
te.getEntity().setState(IEntity.STATE_WAIT); te.getEntity().setState(IEntity.STATE_WAIT);
AbsTask task = createTask(te); AbsTask task = createTask(te);
sendWaitState(task); sendWaitState(task);
resumeEntities.add(te.getEntity());
} }
} }
if (!resumeEntities.isEmpty()) {
DbEntity.updateManyData(resumeEntities);
}
} }
} }

@ -145,10 +145,10 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_WRAPPER ext
|| mStateManager.isFail() || mStateManager.isFail()
|| !isRunning() || !isRunning()
|| isBreak()) { || isBreak()) {
ALog.d(TAG, "isComplete = " + mStateManager.isComplete() //ALog.d(TAG, "isComplete = " + mStateManager.isComplete()
+ "; isFail = " + mStateManager.isFail() // + "; isFail = " + mStateManager.isFail()
+ "; isRunning = " + isRunning() // + "; isRunning = " + isRunning()
+ "; isBreak = " + isBreak()); // + "; isBreak = " + isBreak());
ThreadTaskManager.getInstance().removeTaskThread(mTaskWrapper.getKey()); ThreadTaskManager.getInstance().removeTaskThread(mTaskWrapper.getKey());
closeTimer(); closeTimer();
onDestroy(); onDestroy();

@ -28,6 +28,7 @@ import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.ErrorHelp; import com.arialyy.aria.util.ErrorHelp;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>, public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>,
@ -35,7 +36,7 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
implements IEventListener { implements IEventListener {
protected static String TAG; protected static String TAG;
protected static final int RUN_SAVE_INTERVAL = 5 * 1000; //5s保存一次下载中的进度 protected static final int RUN_SAVE_INTERVAL = 5 * 1000; //5s保存一次下载中的进度
protected WeakReference<Handler> outHandler; protected SoftReference<Handler> outHandler;
private long mLastLen; //上一次发送长度 private long mLastLen; //上一次发送长度
private boolean isFirst = true; private boolean isFirst = true;
private TASK mTask; private TASK mTask;
@ -46,7 +47,7 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
private long mUpdateInterval; private long mUpdateInterval;
protected BaseListener(TASK task, Handler outHandler) { protected BaseListener(TASK task, Handler outHandler) {
this.outHandler = new WeakReference<>(outHandler); this.outHandler = new SoftReference<>(outHandler);
mTask = new WeakReference<>(task).get(); mTask = new WeakReference<>(task).get();
mEntity = mTask.getTaskWrapper().getEntity(); mEntity = mTask.getTaskWrapper().getEntity();
mTaskWrapper = mTask.getTaskWrapper(); mTaskWrapper = mTask.getTaskWrapper();

@ -18,7 +18,7 @@ package com.arialyy.aria.core.common.ftp;
import aria.apache.commons.net.ftp.FTPClientConfig; import aria.apache.commons.net.ftp.FTPClientConfig;
import com.arialyy.aria.core.FtpUrlEntity; import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.inf.ITaskConfig; import com.arialyy.aria.core.inf.ITaskConfig;
import java.lang.ref.WeakReference; import java.lang.ref.SoftReference;
import java.net.Proxy; import java.net.Proxy;
/** /**
@ -41,7 +41,7 @@ public class FtpTaskConfig implements ITaskConfig {
/** /**
* 上传拦截器 * 上传拦截器
*/ */
private WeakReference<IFtpUploadInterceptor> uploadInterceptor; private SoftReference<IFtpUploadInterceptor> uploadInterceptor;
/** /**
* 上传到服务器文件的新文件名{@link FtpInterceptHandler#getNewFileName()} * 上传到服务器文件的新文件名{@link FtpInterceptHandler#getNewFileName()}
@ -74,7 +74,7 @@ public class FtpTaskConfig implements ITaskConfig {
} }
public void setUploadInterceptor(IFtpUploadInterceptor uploadInterceptor) { public void setUploadInterceptor(IFtpUploadInterceptor uploadInterceptor) {
this.uploadInterceptor = new WeakReference<>(uploadInterceptor); this.uploadInterceptor = new SoftReference<>(uploadInterceptor);
} }
public FtpUrlEntity getUrlEntity() { public FtpUrlEntity getUrlEntity() {

@ -19,7 +19,7 @@ package com.arialyy.aria.core.common.http;
import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.inf.IHttpFileLenAdapter; import com.arialyy.aria.core.inf.IHttpFileLenAdapter;
import com.arialyy.aria.core.inf.ITaskConfig; import com.arialyy.aria.core.inf.ITaskConfig;
import java.lang.ref.WeakReference; import java.lang.ref.SoftReference;
import java.net.CookieManager; import java.net.CookieManager;
import java.net.Proxy; import java.net.Proxy;
import java.util.HashMap; import java.util.HashMap;
@ -78,7 +78,7 @@ public class HttpTaskConfig implements ITaskConfig {
*/ */
private Map<String, String> formFields = new HashMap<>(); private Map<String, String> formFields = new HashMap<>();
private WeakReference<IHttpFileLenAdapter> fileLenAdapter; private SoftReference<IHttpFileLenAdapter> fileLenAdapter;
public IHttpFileLenAdapter getFileLenAdapter() { public IHttpFileLenAdapter getFileLenAdapter() {
return fileLenAdapter == null ? null : fileLenAdapter.get(); return fileLenAdapter == null ? null : fileLenAdapter.get();
@ -88,7 +88,7 @@ public class HttpTaskConfig implements ITaskConfig {
* 如果是匿名内部类完成后需要将adapter设置为空否则会出现内存泄漏 * 如果是匿名内部类完成后需要将adapter设置为空否则会出现内存泄漏
*/ */
public void setFileLenAdapter(IHttpFileLenAdapter fileLenAdapter) { public void setFileLenAdapter(IHttpFileLenAdapter fileLenAdapter) {
this.fileLenAdapter = new WeakReference<>(fileLenAdapter); this.fileLenAdapter = new SoftReference<>(fileLenAdapter);
} }
public Map<String, String> getFormFields() { public Map<String, String> getFormFields() {

@ -133,7 +133,7 @@ final class M3U8InfoThread implements Runnable {
if (line.startsWith("#EXT-X-ENDLIST")) { if (line.startsWith("#EXT-X-ENDLIST")) {
break; break;
} }
//ALog.d(TAG, line); ALog.d(TAG, line);
if (line.startsWith("#EXTINF")) { if (line.startsWith("#EXTINF")) {
String info = reader.readLine(); String info = reader.readLine();
mInfos.add(info); mInfos.add(info);

@ -16,7 +16,6 @@
package com.arialyy.aria.core.download.m3u8; package com.arialyy.aria.core.download.m3u8;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
/** /**
@ -67,7 +66,7 @@ public class M3U8TaskConfig {
/** /**
* 码率url转换器 * 码率url转换器
*/ */
private WeakReference<IBandWidthUrlConverter> bandWidthUrlConverter; private SoftReference<IBandWidthUrlConverter> bandWidthUrlConverter;
/** /**
* 码率地址 * 码率地址
@ -77,7 +76,7 @@ public class M3U8TaskConfig {
/** /**
* 直播下载ts url转换器 * 直播下载ts url转换器
*/ */
private WeakReference<ILiveTsUrlConverter> liveTsUrlConverter; private SoftReference<ILiveTsUrlConverter> liveTsUrlConverter;
/** /**
* 直播的m3u8文件更新间隔 * 直播的m3u8文件更新间隔
@ -136,7 +135,7 @@ public class M3U8TaskConfig {
} }
public void setLiveTsUrlConverter(ILiveTsUrlConverter liveTsUrlConverter) { public void setLiveTsUrlConverter(ILiveTsUrlConverter liveTsUrlConverter) {
this.liveTsUrlConverter = new WeakReference<>(liveTsUrlConverter); this.liveTsUrlConverter = new SoftReference<>(liveTsUrlConverter);
} }
public String getBandWidthUrl() { public String getBandWidthUrl() {
@ -152,7 +151,7 @@ public class M3U8TaskConfig {
} }
public void setBandWidthUrlConverter(IBandWidthUrlConverter bandWidthUrlConverter) { public void setBandWidthUrlConverter(IBandWidthUrlConverter bandWidthUrlConverter) {
this.bandWidthUrlConverter = new WeakReference<>(bandWidthUrlConverter); this.bandWidthUrlConverter = new SoftReference<>(bandWidthUrlConverter);
} }
public int getBandWidth() { public int getBandWidth() {

@ -3,6 +3,8 @@
- fix bug https://github.com/AriaLyy/Aria/issues/450 - fix bug https://github.com/AriaLyy/Aria/issues/450
- fix bug https://github.com/AriaLyy/Aria/issues/466 - fix bug https://github.com/AriaLyy/Aria/issues/466
- fix bug https://github.com/AriaLyy/Aria/issues/454 - fix bug https://github.com/AriaLyy/Aria/issues/454
- fix bug https://github.com/AriaLyy/Aria/issues/467
- fix bug https://github.com/AriaLyy/Aria/issues/459
- 移除隐藏api的反射 https://github.com/AriaLyy/Aria/issues/456 - 移除隐藏api的反射 https://github.com/AriaLyy/Aria/issues/456
- 新增ftp免证书登陆功能h ttps://github.com/AriaLyy/Aria/issues/455 - 新增ftp免证书登陆功能h ttps://github.com/AriaLyy/Aria/issues/455
- 适配androidX - 适配androidX

@ -12,7 +12,7 @@ Aria有以下特点:
- 支持下载FTP文件夹 - 支持下载FTP文件夹
- 支持HTTP表单上传 - 支持HTTP表单上传
- 支持文件FTP断点续传上传 - 支持文件FTP断点续传上传
- 支持FTPS/SFTP断点续传,[see](https://aria.laoyuyu.me/aria_doc/download/ftps.html) - 支持FTPS断点续传,[see](https://aria.laoyuyu.me/aria_doc/download/ftps.html)
+ 支持https地址下载 + 支持https地址下载
- 在配置文件中很容易就可以设置CA证书的信息 - 在配置文件中很容易就可以设置CA证书的信息
+ 支持[多线程分块下载](https://aria.laoyuyu.me/aria_doc/start/config.html),能更有效的发挥机器IO性能 + 支持[多线程分块下载](https://aria.laoyuyu.me/aria_doc/start/config.html),能更有效的发挥机器IO性能

@ -69,7 +69,7 @@ dependencies {
// annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.14' // annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.14'
api 'com.github.PhilJay:MPAndroidChart:v3.0.3' api 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation project(':AppFrame') implementation project(':AppFrame')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4' debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
implementation 'com.github.bumptech.glide:glide:3.7.0' implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.pddstudio:highlightjs-android:1.5.0' implementation 'com.pddstudio:highlightjs-android:1.5.0'
implementation 'org.greenrobot:eventbus:3.1.1' implementation 'org.greenrobot:eventbus:3.1.1'

@ -23,6 +23,7 @@ import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
import com.arialyy.annotations.Download; import com.arialyy.annotations.Download;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.common.ProtocolType;
import com.arialyy.aria.core.common.controller.ControllerType; import com.arialyy.aria.core.common.controller.ControllerType;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
@ -47,6 +48,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
private String mUrl, mFilePath; private String mUrl, mFilePath;
private FtpDownloadModule mModule; private FtpDownloadModule mModule;
private long mTaskId; private long mTaskId;
private String user = "tester", passw = "password";
@Override protected void init(Bundle savedInstanceState) { @Override protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState); super.init(savedInstanceState);
@ -94,7 +96,8 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
mTaskId = Aria.download(this).loadFtp(mUrl) mTaskId = Aria.download(this).loadFtp(mUrl)
.setFilePath(mFilePath, true) .setFilePath(mFilePath, true)
.option() .option()
.login("lao", "123456") //.login("lao", "123456")
.login(user, passw)
.asFtps() .asFtps()
.controller(ControllerType.CREATE_CONTROLLER) .controller(ControllerType.CREATE_CONTROLLER)
.create(); .create();
@ -108,8 +111,9 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
Aria.download(this) Aria.download(this)
.loadFtp(mTaskId) .loadFtp(mTaskId)
.option() .option()
.login("lao", "123456") .login(user, passw)
.asFtps() .asFtps()
.setProtocol(ProtocolType.SSL)
.controller(ControllerType.TASK_CONTROLLER) .controller(ControllerType.TASK_CONTROLLER)
.resume(); .resume();
getBinding().setStateStr(getString(R.string.stop)); getBinding().setStateStr(getString(R.string.stop));

@ -33,7 +33,7 @@ public class FtpDownloadModule extends BaseViewModule {
private final String FTP_URL_KEY = "FTP_URL_KEY"; private final String FTP_URL_KEY = "FTP_URL_KEY";
private final String FTP_PATH_KEY = "FTP_PATH_KEY"; private final String FTP_PATH_KEY = "FTP_PATH_KEY";
private final String ftpDefUrl = "ftp://9.9.9.50:2121/Cyberduck-6.9.4.30164.zip"; private final String ftpDefUrl = "ftp://9.9.9.50:22/Cyberduck-6.9.4.30164.zip";
private final String ftpDefPath = private final String ftpDefPath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath(); Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath();

@ -16,6 +16,7 @@
package com.arialyy.simple.core.download.m3u8; package com.arialyy.simple.core.download.m3u8;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
@ -29,11 +30,10 @@ import androidx.lifecycle.ViewModelProviders;
import com.arialyy.annotations.Download; import com.arialyy.annotations.Download;
import com.arialyy.annotations.M3U8; import com.arialyy.annotations.M3U8;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.common.controller.ControllerType;
import com.arialyy.aria.core.common.controller.BuilderController; import com.arialyy.aria.core.common.controller.BuilderController;
import com.arialyy.aria.core.common.controller.ControllerType;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.core.download.m3u8.IBandWidthUrlConverter;
import com.arialyy.aria.core.download.m3u8.ITsMergeHandler; import com.arialyy.aria.core.download.m3u8.ITsMergeHandler;
import com.arialyy.aria.core.download.m3u8.IVodTsUrlConverter; import com.arialyy.aria.core.download.m3u8.IVodTsUrlConverter;
import com.arialyy.aria.core.download.m3u8.M3U8Entity; import com.arialyy.aria.core.download.m3u8.M3U8Entity;
@ -281,16 +281,17 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
Aria.download(this) Aria.download(this)
.load(mTaskId) .load(mTaskId)
.asM3U8() .asM3U8()
.setBandWidthUrlConverter(new IBandWidthUrlConverter() { //.setBandWidthUrlConverter(new IBandWidthUrlConverter() {
@Override public String convert(String bandWidthUrl) { // @Override public String convert(String bandWidthUrl) {
int index = mUrl.lastIndexOf("/"); // int index = mUrl.lastIndexOf("/");
return mUrl.substring(0, index + 1) + bandWidthUrl; // return mUrl.substring(0, index + 1) + bandWidthUrl;
} // }
}) //})
.setTsUrlConvert(new IVodTsUrlConverter() { .setTsUrlConvert(new IVodTsUrlConverter() {
@Override public List<String> convert(String m3u8Url, List<String> tsUrls) { @Override public List<String> convert(String m3u8Url, List<String> tsUrls) {
int index = m3u8Url.lastIndexOf("/");
String parentUrl = m3u8Url.substring(0, index + 1); Uri uri = Uri.parse(m3u8Url);
String parentUrl = uri.getAuthority() + "://" + uri.getHost();
List<String> newUrls = new ArrayList<>(); List<String> newUrls = new ArrayList<>();
for (String url : tsUrls) { for (String url : tsUrls) {
newUrls.add(parentUrl + url); newUrls.add(parentUrl + url);
@ -316,16 +317,22 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
.useServerFileName(true) .useServerFileName(true)
.setFilePath(mFilePath, true) .setFilePath(mFilePath, true)
.asM3U8() .asM3U8()
.setBandWidthUrlConverter(new IBandWidthUrlConverter() { //.setBandWidthUrlConverter(new IBandWidthUrlConverter() {
@Override public String convert(String bandWidthUrl) { // @Override public String convert(String bandWidthUrl) {
int index = mUrl.lastIndexOf("/"); // int index = mUrl.lastIndexOf("/");
return mUrl.substring(0, index + 1) + bandWidthUrl; // return mUrl.substring(0, index + 1) + bandWidthUrl;
} // }
}) //})
.setTsUrlConvert(new IVodTsUrlConverter() { .setTsUrlConvert(new IVodTsUrlConverter() {
@Override public List<String> convert(String m3u8Url, List<String> tsUrls) { @Override public List<String> convert(String m3u8Url, List<String> tsUrls) {
int index = m3u8Url.lastIndexOf("/"); //int index = m3u8Url.lastIndexOf("/");
String parentUrl = m3u8Url.substring(0, index + 1); //String parentUrl = m3u8Url.substring(0, index + 1);
//List<String> newUrls = new ArrayList<>();
//for (String url : tsUrls) {
// newUrls.add(parentUrl + url);
//}
Uri uri = Uri.parse(m3u8Url);
String parentUrl = uri.getScheme() + "://" + uri.getHost();
List<String> newUrls = new ArrayList<>(); List<String> newUrls = new ArrayList<>();
for (String url : tsUrls) { for (String url : tsUrls) {
newUrls.add(parentUrl + url); newUrls.add(parentUrl + url);

@ -34,10 +34,11 @@ public class M3U8VodModule extends BaseViewModule {
// m3u8测试集合:http://www.voidcn.com/article/p-snaliarm-ct.html // m3u8测试集合:http://www.voidcn.com/article/p-snaliarm-ct.html
//private final String defUrl = "https://www.gaoya123.cn/2019/1557993797897.m3u8"; //private final String defUrl = "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://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
private final String defUrl = "http://cn1.fa1244.cn/hls/20190516/6d271eaa73b2e4cb51d13831b0c1ab4c/1557976262/index.m3u8";
private final String filePath = private final String filePath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
+ "/1557993797897.ts"; + "/道士下山.ts";
private MutableLiveData<DownloadEntity> liveData = new MutableLiveData<>(); private MutableLiveData<DownloadEntity> liveData = new MutableLiveData<>();
private DownloadEntity singDownloadInfo; private DownloadEntity singDownloadInfo;

@ -53,6 +53,10 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
setTitle("下载列表"); setTitle("下载列表");
List<AbsEntity> temps = Aria.download(this).getTotalTaskList(); List<AbsEntity> temps = Aria.download(this).getTotalTaskList();
if (temps != null && !temps.isEmpty()) { if (temps != null && !temps.isEmpty()) {
for (AbsEntity temp : temps){
ALog.d(TAG, "state = " + temp.getState());
}
mData.addAll(temps); mData.addAll(temps);
} }
mAdapter = new DownloadAdapter(this, mData); mAdapter = new DownloadAdapter(this, mData);

@ -0,0 +1,15 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}

@ -0,0 +1,6 @@
{
"python.linting.pylintEnabled": false,
"python.linting.pep8Enabled": true,
"python.linting.enabled": true,
"python.pythonPath": "/usr/local/bin/python3.7"
}

@ -0,0 +1,26 @@
import socketserver
class TCPHandler(socketserver.StreamRequestHandler):
BASE_PATH = "/Users/aria/temp/tcp/"
def handle(self):
data = self.request.recv(1024).strip()
file_name = data.decode("utf-8")
print("file_name: %s" % file_name)
print("{} wrote:".format(self.client_address[0]))
with open(self.BASE_PATH + file_name, "rb") as f:
b = f.read(1024)
if b:
self.wfile.write(b)
else:
print("发送成功")
if __name__ == "__main__":
HOST, PORT = "localhost", 9999
with socketserver.TCPServer((HOST, PORT), TCPHandler) as server:
server.serve_forever()

@ -15,7 +15,8 @@ def downloader(filename):
data = request.values.get('key') data = request.values.get('key')
print(data) print(data)
dirpath = '/Users/aria/dev/ftp' dirpath = '/Users/aria/dev/ftp'
return send_from_directory(dirpath, filename, as_attachment=True) # as_attachment=True 一定要写,不然会变成打开,而不是下载 # as_attachment=True 一定要写,不然会变成打开,而不是下载
return send_from_directory(dirpath, filename, as_attachment=True)
@app.route("/download1", methods=['POST', 'GET']) @app.route("/download1", methods=['POST', 'GET'])
@ -27,7 +28,9 @@ def downloader1():
data = request.values.get('key') data = request.values.get('key')
print(data) print(data)
dirpath = 'D:/test' dirpath = 'D:/test'
return send_from_directory(dirpath, filename, as_attachment=True) # as_attachment=True 一定要写,不然会变成打开,而不是下载 # as_attachment=True 一定要写,不然会变成打开,而不是下载
return send_from_directory(dirpath, filename, as_attachment=True)
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True) # 需要关闭防火墙 app.run(host='0.0.0.0', debug=True) # 需要关闭防火墙

Loading…
Cancel
Save