diff --git a/.gitignore b/.gitignore index c23ed329..039e7172 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ /cache *.log uml -*.swp \ No newline at end of file +*.swp +py/.history \ No newline at end of file diff --git a/AppFrame/build.gradle b/AppFrame/build.gradle index fbffc3a3..7ff09de7 100644 --- a/AppFrame/build.gradle +++ b/AppFrame/build.gradle @@ -24,11 +24,11 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', { + api fileTree(dir: 'libs', include: ['*.jar']) + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { 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 'com.google.code.gson:gson:2.8.2' api 'io.reactivex:rxandroid:1.2.0' diff --git a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java index 6b1e9558..6ace735b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java +++ b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java @@ -200,7 +200,7 @@ import org.xml.sax.SAXException; Class[] clazzs = new 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) { if (!mDbWrapper.tableExists(clazz)) { continue; diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java index a17dfefc..f29e79f6 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java @@ -5,6 +5,7 @@ import com.arialyy.aria.core.download.DGTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DownloadEntity; 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.AbsTaskWrapper; import com.arialyy.aria.core.inf.IEntity; @@ -104,7 +105,11 @@ final class ResumeAllCmd extends AbsNormalCmd { */ private void resumeWaitTask() { int maxTaskNum = mQueue.getMaxTaskNum(); - if (mWaitList == null || mWaitList.isEmpty()) return; + if (mWaitList == null || mWaitList.isEmpty()) { + return; + } + List resumeEntities = new ArrayList<>(); + for (AbsTaskWrapper te : mWaitList) { if (te instanceof DTaskWrapper) { mQueue = DownloadTaskQueue.getInstance(); @@ -119,7 +124,11 @@ final class ResumeAllCmd extends AbsNormalCmd { te.getEntity().setState(IEntity.STATE_WAIT); AbsTask task = createTask(te); sendWaitState(task); + resumeEntities.add(te.getEntity()); } } + if (!resumeEntities.isEmpty()) { + DbEntity.updateManyData(resumeEntities); + } } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java index 98173f05..c6988ceb 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java @@ -145,10 +145,10 @@ public abstract class AbsFileer bandWidthUrlConverter; + private SoftReference bandWidthUrlConverter; /** * 码率地址 @@ -77,7 +76,7 @@ public class M3U8TaskConfig { /** * 直播下载,ts url转换器 */ - private WeakReference liveTsUrlConverter; + private SoftReference liveTsUrlConverter; /** * 直播的m3u8文件更新间隔 @@ -136,7 +135,7 @@ public class M3U8TaskConfig { } public void setLiveTsUrlConverter(ILiveTsUrlConverter liveTsUrlConverter) { - this.liveTsUrlConverter = new WeakReference<>(liveTsUrlConverter); + this.liveTsUrlConverter = new SoftReference<>(liveTsUrlConverter); } public String getBandWidthUrl() { @@ -152,7 +151,7 @@ public class M3U8TaskConfig { } public void setBandWidthUrlConverter(IBandWidthUrlConverter bandWidthUrlConverter) { - this.bandWidthUrlConverter = new WeakReference<>(bandWidthUrlConverter); + this.bandWidthUrlConverter = new SoftReference<>(bandWidthUrlConverter); } public int getBandWidth() { diff --git a/DEV_LOG.md b/DEV_LOG.md index 70e98b6a..a5ede232 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -3,6 +3,8 @@ - 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/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 - 新增ftp免证书登陆功能h ttps://github.com/AriaLyy/Aria/issues/455 - 适配androidX diff --git a/README.md b/README.md index 76cd3b40..2143013f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Aria有以下特点: - 支持下载FTP文件夹 - 支持HTTP表单上传 - 支持文件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地址下载 - 在配置文件中很容易就可以设置CA证书的信息 + 支持[多线程分块下载](https://aria.laoyuyu.me/aria_doc/start/config.html),能更有效的发挥机器IO性能 diff --git a/app/build.gradle b/app/build.gradle index 876b7d14..76cc2bad 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -69,7 +69,7 @@ dependencies { // annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.14' api 'com.github.PhilJay:MPAndroidChart:v3.0.3' 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.pddstudio:highlightjs-android:1.5.0' implementation 'org.greenrobot:eventbus:3.1.1' diff --git a/app/src/main/java/com/arialyy/simple/core/download/FtpDownloadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/FtpDownloadActivity.java index 7afe9b0b..1c9ff07a 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/FtpDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/FtpDownloadActivity.java @@ -23,6 +23,7 @@ import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProviders; import com.arialyy.annotations.Download; 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.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadTask; @@ -47,6 +48,7 @@ public class FtpDownloadActivity extends BaseActivity { Aria.download(this) .load(mTaskId) .asM3U8() - .setBandWidthUrlConverter(new IBandWidthUrlConverter() { - @Override public String convert(String bandWidthUrl) { - int index = mUrl.lastIndexOf("/"); - return mUrl.substring(0, index + 1) + bandWidthUrl; - } - }) + //.setBandWidthUrlConverter(new IBandWidthUrlConverter() { + // @Override public String convert(String bandWidthUrl) { + // int index = mUrl.lastIndexOf("/"); + // return mUrl.substring(0, index + 1) + bandWidthUrl; + // } + //}) .setTsUrlConvert(new IVodTsUrlConverter() { @Override public List convert(String m3u8Url, List tsUrls) { - int index = m3u8Url.lastIndexOf("/"); - String parentUrl = m3u8Url.substring(0, index + 1); + + Uri uri = Uri.parse(m3u8Url); + String parentUrl = uri.getAuthority() + "://" + uri.getHost(); List newUrls = new ArrayList<>(); for (String url : tsUrls) { newUrls.add(parentUrl + url); @@ -316,16 +317,22 @@ public class M3U8VodDLoadActivity extends BaseActivity { .useServerFileName(true) .setFilePath(mFilePath, true) .asM3U8() - .setBandWidthUrlConverter(new IBandWidthUrlConverter() { - @Override public String convert(String bandWidthUrl) { - int index = mUrl.lastIndexOf("/"); - return mUrl.substring(0, index + 1) + bandWidthUrl; - } - }) + //.setBandWidthUrlConverter(new IBandWidthUrlConverter() { + // @Override public String convert(String bandWidthUrl) { + // int index = mUrl.lastIndexOf("/"); + // return mUrl.substring(0, index + 1) + bandWidthUrl; + // } + //}) .setTsUrlConvert(new IVodTsUrlConverter() { @Override public List convert(String m3u8Url, List tsUrls) { - int index = m3u8Url.lastIndexOf("/"); - String parentUrl = m3u8Url.substring(0, index + 1); + //int index = m3u8Url.lastIndexOf("/"); + //String parentUrl = m3u8Url.substring(0, index + 1); + //List newUrls = new ArrayList<>(); + //for (String url : tsUrls) { + // newUrls.add(parentUrl + url); + //} + Uri uri = Uri.parse(m3u8Url); + String parentUrl = uri.getScheme() + "://" + uri.getHost(); List newUrls = new ArrayList<>(); for (String url : tsUrls) { newUrls.add(parentUrl + url); diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java index 46140e9d..d1fec3c2 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java +++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java @@ -34,10 +34,11 @@ public class M3U8VodModule extends BaseViewModule { // 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 = "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 = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() - + "/1557993797897.ts"; + + "/道士下山.ts"; private MutableLiveData liveData = new MutableLiveData<>(); private DownloadEntity singDownloadInfo; diff --git a/app/src/main/java/com/arialyy/simple/core/download/mutil/MultiDownloadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/mutil/MultiDownloadActivity.java index 2499bbd1..4b46ddb7 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/mutil/MultiDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/mutil/MultiDownloadActivity.java @@ -53,6 +53,10 @@ public class MultiDownloadActivity extends BaseActivity temps = Aria.download(this).getTotalTaskList(); if (temps != null && !temps.isEmpty()) { + + for (AbsEntity temp : temps){ + ALog.d(TAG, "state = " + temp.getState()); + } mData.addAll(temps); } mAdapter = new DownloadAdapter(this, mData); diff --git a/py/.vscode/launch.json b/py/.vscode/launch.json new file mode 100644 index 00000000..b80908c1 --- /dev/null +++ b/py/.vscode/launch.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/py/.vscode/settings.json b/py/.vscode/settings.json new file mode 100644 index 00000000..4ca83c7f --- /dev/null +++ b/py/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "python.linting.pylintEnabled": false, + "python.linting.pep8Enabled": true, + "python.linting.enabled": true, + "python.pythonPath": "/usr/local/bin/python3.7" +} \ No newline at end of file diff --git a/py/TcpDownload.py b/py/TcpDownload.py new file mode 100644 index 00000000..41bb5549 --- /dev/null +++ b/py/TcpDownload.py @@ -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() diff --git a/py/download.py b/py/download.py index b06e9d7b..fc2c48c4 100644 --- a/py/download.py +++ b/py/download.py @@ -15,7 +15,8 @@ def downloader(filename): data = request.values.get('key') print(data) 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']) @@ -27,7 +28,9 @@ def downloader1(): data = request.values.get('key') print(data) 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__': app.run(host='0.0.0.0', debug=True) # 需要关闭防火墙